« first day (1618 days earlier)      last day (3340 days later) » 

5:10 PM
class Foo implements Countable {
    function count(): int {
        return 42;
    }
}

var_dump(count(new Foo()));
> Fatal error: Declaration of Foo::count() must be compatible with Countable::count()
 
:)
 
I am fairly certain this is an implementation error. Looking into it now.
 
@LeviMorrison I don't think it is - however a partial variance implementation would allow it ;)
 
@NikiC Based on the RFC I proposed it is valid.
I am also somewhat confident it worked before scalar types was added.
(I am double-checking now)
 
@LeviMorrison ah, having typehint/no-typehint variance for returns was part of the RFC?
I thought you went for a fully invariant approach
 
5:15 PM
That's partly what I'm checking now.
My memory is notoriously bad :)
At least in the examples I have:
// Overriding a method that did not have a return type:
interface Comment {}
interface CommentsIterator extends Iterator {
    function current(): Comment;
}
I think the issue might be with internals scalar checking.
> The enforcement of the declared return type during inheritance is invariant; this means that when a sub-type overrides a parent method then the return type of the child must exactly match the parent and may not be omitted. If the parent does not declare a return type then the child is allowed to declare one.
Okay, that is what I proposed.
I'm also fairly sure that is what I implemented. I am unsure if Dmitry broke it :)
 
@LeviMorrison I'm relatively sure that the implementation of return types that landed did not support this
I remember checking this when I was suggesting to implement the reverse for argument types, to avoid a Derick.
 
@NikiC I just checked: git.php.net/…
It landed.
Wait... unless a is the commit?
(a is the parent commit?)
 
@LeviMorrison Don't try to understand non-github merge commit views
It's impossible
 
lol
Okay, to github I go then.
Notably, that test case is still there and passes.
So I suspect maybe it has to do with Countable
 
@LeviMorrison Yup, it works
 
5:24 PM
static const zend_function_entry spl_funcs_Countable[] = {
        SPL_ABSTRACT_ME(Countable, count,   arginfo_recursive_it_void)
        PHP_FE_END
};
We didn't slip in void support, did we?
 
<?php

interface A {
    public function foo();
}

interface B extends A {
    public function foo() : C;
}
^-- fatals for me
 
Then someone broke something.
I'm going to blame Anthony/Dmitry.
:)
 
@LeviMorrison I don't think so
 
I suspect the issue is the unification of the parameter and return type checks.
 
I think it never worked in the first place
 
5:26 PM
Because it's not permissible in parameter types.
 
yes
wonder why that one test works tho
will have to read some code...
 
@NikiC Possibly internals vs user-land.
    if (ZEND_LOG_XOR(fe_arg_info->class_name, proto_arg_info->class_name)) {
            /* Only one has a type hint and the other one doesn't */
            return 0;
    }
This is an error.
Wait.
I think 0 might be "passes".
/* check return type compataibility */
if ((proto->common.fn_flags | fe->common.fn_flags) & ZEND_ACC_HAS_RETURN_TYPE) {
        if ((proto->common.fn_flags ^ fe->common.fn_flags) & ZEND_ACC_HAS_RETURN_TYPE) {
                return 0;
        }
        if (!zend_do_perform_type_hint_check(fe, fe->common.arg_info - 1, proto, proto->common.arg_info - 1)) {
                return 0;
        }
}
return 1;
Yeah, I think 0 is "passes" and non-zero is "fails" here.
 
@LeviMorrison nope, 1 is passes
 
I think the issue is the code is trying to be too clever.
This code was not so clever when I wrote it.
The biggest question I have is why some work and some don't.
Why is the phpt working?
Why are the two examples we've posted here not working?
 
yeah, I'm wondering that as well
 
5:37 PM
(proto->common.fn_flags | fe->common.fn_flags) & ZEND_ACC_HAS_RETURN_TYPE => "If either the parent or the child has a return type"
 
@LeviMorrison I see it ... Iterator has no arginfo
so it won't even do any prototype checks
 
Okay. Time to fix everything else then.
(And how unlucky for me I picked something that didn't have arginfo for the test case)
(proto->common.fn_flags ^ fe->common.fn_flags) & ZEND_ACC_HAS_RETURN_TYPE
 
ok, I'll fix it
 
That line says "if one of them doesn't have a return type"
It's incorrect.
I think it should be:
(proto->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) && !(fe->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE)
If the parent has a return type and the child doesn't that's an error.
But then it calls zend_do_perform_type_hint_check anyway.
And then will fail on the same thing.
Return types and parameter types checks should not have been unified.
Especially since I want to make them covariant later on anyway.
They should have remained separate.
This annoys me :/
@NikiC When you do please make sure that you note the behavior as defined in the RFC.
Also, I'm happy to fix it; it will just take me longer than it will take you :)
 
fixing it is just a matter of removing code :D
 
5:45 PM
Just don't break parameter types though.
 
that, and writing tests
 
In parameters if the parent doesn't specify a type you can't provide one.
Ah, this has been broken since Dmitry's cleanup of my patch.
I just didn't notice it because that one case with the Iterator worked.
I've been so busy I'm just now getting around to actually using it in more stuff >.<
Also... at least initially class_name was only populated for objects.
So that check ZEND_LOG_XOR(fe_arg_info->class_name, proto_arg_info->class_name) is not completely accurate.
Also, that's the only place ZEND_LOG_XOR is used, which also has a supporting macro ZEND_TRUTH that is not used outside of ZEND_LOG_XOR.
 
Checking it out and running tests now.
 
6:01 PM
So, now that this has landed, I think we can sneak in doing the reverse for param types
 
6:12 PM
lol
 
6:28 PM
Hey
What is one doing wrong:
SELECT * FROM product WHERE age = 1 AND condition = 2 ORDER BY price
 
Well what's the error you are getting back?
 
@LeviMorrison Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'condition = 2 ORDER BY price' at line 1'
 
Semi-colon at the end?
 
$productStmt = $db->query("SELECT * FROM product WHERE age = 1 AND condition = 2 ORDER BY price");
 
Can you run SHOW CREATE TABLE product; and give the output?
 
6:32 PM
Not sure how one does that, but I'll give it a try if you show me haha
 
@RahulKhosla condition is a reserved word
 
@RonniSkansing OH!
Thanks!
 
put ` around it
 
Is it `s or 's
 
6:34 PM
`condition`
 
Thanks!
 
6:59 PM
Quick question; in SQL can you ORDER BY a AND b, giving the results of b first, then a followed after?
 
You use a comma (not AND).
Also, that is something you can surely use a search engine for :)
 
157
A: PHP MySQL Order by Two Columns

truppoDefault sorting is ascending, you need to add the keyword DESC to both your orders: ORDER BY article_rating DESC, article_time DESC

first result from google
 
Thanks, sorry! I was just trying AND
 
7:16 PM
Is Marcus Boerger still around to blame talk to?
 
Not that I know of.
(I am quite confident Marcus is no longer involved with PHP)
(but not 100% certain)
 
7:39 PM
(Whisper whisper)
 
Out of interest @LeviMorrison did you vote no on wiki.php.net/rfc/reserve_even_more_types_in_php_7 because you don't think those should be reserved, or just not for 7, or some other reason?
 
@ircmaxell um
$ sapi/cli/php -r 'function foo(int $x) { var_dump($x); } foo(INF);'

Fatal error: Argument 1 passed to foo() must be of the type integer, float given, called in Command line code on line 1 and defined in Command line code on line 1
I thought you made it use exceptions
?!
Wait, why is it in strict mode?
What the hell?
 
@Andrea apparently it's just a really bad error message....try catching TypeException?
Or whatever it is.
 
@Danack Oh, it's caught
OK, so
 
2) Why doesn't it say "uncaught exception"
It's not in strict mode, I just didn't look at my own code
foo(INF); is an error because ZPP Failure on Overflow. That's supposed to error. foo(1.0); doesn't error. Ignore me.
I should really have made that case produce a better error message, but oh well
 
@Andrea Yet to be implemented
 
@NikiC Are engine exceptions special?
 
@Andrea yes. They go through zend_error()
 
Oh I see.
 
8:44 PM
I wanna build a web application using AngularJS for front-end but I want to avoid manually writing php scripts for querys, any advice? Been looking at Slim, looks ok.
 
9:09 PM
@simpe You'll still need to write the queries - but this might be of interest: apigility.org
 
PDOThing or PdoThing?
 
I say PDOThing, like HTTPThing - but most people disagree.
 
@Patrick PDO
 
Capitals.
 
9:42 PM
@DavidGraham not up to us to decide
as for partial loads: you are just doing stupid premature optimization. If you're not building the new facebook, you should first look at getting shit done
 
the tokenizer ext port is working :)
::class is broken again because new tests were added :/
(damn ::class)
 
Silly developers. Adding tests only adds bugs to your code! Stop writing tests!
 
No, no - write the tests. Then just don't run them.
 
@AllenJB lol, you'd be surprised with the amount of holes in the test suite if you mess with essential parts of the stack
 
@marcio We follow the 90/10 rule of testing. 90% of our tests cover 10% of the functionality.
5
E.g. we have thousands of tests that test zpp functionality and nothing more
 
9:55 PM
@NikiC xD funny because it's true
 
hm
I remember reading about code generators that other languages have used to improve the tests
isn't there something like this for php?
 
And a lot of things are tested by accident.

E: only failing "string {$interpolation}" I found was actually intended to test ArrayAccess + foreach
@FlorianMargaine I've seen SQL generators to test SQL implementations
 
@marcio yep. Something similar could be done for php
which would improve the tests
iirc something like this was done for js in v8...
 
yeah, a php language fuzzer would probably turn up quite a number of issues
 
jsfunfuzz was the one I was thinking about
 
10:08 PM
@Danack I am uncertain about them. I definitely don't want to add "scalar" or "mixed" willy-nilly.
"numeric" is just a no.
I may switch to a "yes" on "object".
 
@NikiC it'd discover tons
there are bajillions of broken corner cases
that we miss and have to add tests for
a lot of these corner cases have been introduced by PHP 7
usually due to some performance hack
 
@LeviMorrison There seems to be a lot of confusion about what the RFC actually says: news.php.net/php.internals/85107
 
Remember when Dmitry broke weakly-typed arithmetic assignments operators?
Actually I think he's done that more than once
A good thing to check is to compare the results of certain operations with what another language produces
For example with integers
I did that to bug-check bigints
 
@Danack ? I don't see "a lot of confusion"?
 
> There's no language in the RFC about actually throwing errors or other code-breaking behavior.
vs
 
10:13 PM
@LeviMorrison numeric is useful
 
> This breaks any and all cases where these new reserved words are used in class, interface or trait names.
 
I don't see where the former is coming from? (The RFC says the latter)
@Andrea So is Iterable, yet it doesn't exist.
 
@LeviMorrison ?
we already have numeric internally in a sense. Not for ZPP, but for mathematical operators
 
array|Traversable
 
It would make sense to expose it
It's also not something blind unions like int|float solve well
 
10:16 PM
@LeviMorrison from the email I linked above, by the current sponsor of the RFC.
 
if you simply convert to the first possible type, "1.5" becomes an integer
What you want is the most reasonable conversion - i.e. what is_numeric_string does
 
You just implied strict types are superior kappa
 
Who, me? Sure
But with PHP you must work with what we have
PHP is weakly-typed
foo|bar with scalar support is a really bad idea
 
Anyway, I think the types Sara is proposing (except for maybe object and resource) should be added when proposals for those mechanics are added.
 
Add numeric, nullables and an enum type
@LeviMorrison BC break
 
10:19 PM
Yes.
I think all of the names I am reserving should be reserved whether we actually do anything with them or not. I can't say the same for most of those in Sara's proposal.
 
I wouldn't agree
 
Then vote differently :)
 
> This RFC adds to https://wiki.php.net/rfc/reserve_more_types_in_php_7 to prevents the use of the following additional words to be used as a class, interface or trait name:

> “resource”
> “object”
> “scalar”
> “mixed”
> “numeric”
All of those have some significant support
Not all a majority perhaps, but still
Also, even without type hints, reserving them is useful
Having all basic types be reserved class names means we can do interesting things in future
For example:
$foo instanceof int
 
Except the latter three don't exactly exist.
 
$foo instanceof object
@LeviMorrison They are superclasses
Useful ones, too, which we exploit in some places
 
10:23 PM
Weak types muddies that anyway, since string might be numeric but string isn't an instance of numeric.
 
Not really
 
@LeviMorrison are you planning to do union types in near future? I'd like to see this passing before other people come up with extra syntax for nullables etc. (targeting 7.1 obviously)
 
Well, numeric should be number really
 
@bwoebi Fortunately I'm the current RFC author for nullables :)
 
Don't push union types as an alternative to nullables
Nullables are a simple, obvious proposal with no real issues
 
10:24 PM
@Andrea They are somewhat orthogonal, I understand.
 
They do one job, do it well
 
@Andrea no, it's not an alternative for nullables, but they solve nullables at the same moment.
 
@bwoebi If you want to co-author I can probably make it happen.
(I mean make the RFC happen; no promises on the result)
 
@bwoebi They do, but they also create an awful lot of problems
 
@Andrea Please, enlighten me.
 
10:26 PM
@LeviMorrison Weak typing
 
I mean, I wouldn't like to see first nullables making it in and then union types. Which means we will have two syntaxes for the same problem.
 
@Andrea Give me a specific example.
 
@Andrea Didn't we discuss that already recently?
 
@LeviMorrison int|float
It seems simple. It's not.
 
@Andrea Already has a known solution. Next issue please.
 
10:27 PM
@LeviMorrison What known solution?
Special-casing it?
There's also the general issue that union types are open to abuse and usually aren't what you actually need
 
There was a big discussion about weak types in general here recently; @bwoebi do you remember about when?
 
Special-casing in the same way all weak scalar types are special cased
 
@NikiC Not at all
 
We have a ruleset for how to convert to one type
We do not have a ruleset for choosing between a set of types
 
10:28 PM
@Andrea We need to introduce one.
 
@bwoebi No we don't
Because any approach would be really messy
 
Implement it and find out.
 
But, as I said, union types aren't what you need in the vast majority of cases anyway
What you want are superclasses
 
You can't always make one.
If you have primitives you can't extract a superclass in user-land.
 
@Andrea And you also can't make superclasses for scalars… or how do I define int|false?
 
10:30 PM
@LeviMorrison That's looking at it the wrong way round
 
You can't make a third-party library suddenly implement your super type.
 
The question is why doesn't PHP have superclasses for this?
For example
We didn't solve the callables problem by telling you to do string|array
We solved it by adding callable
We don't solve the traversables problem by allowing you to do array|Traversable
 
That's because callables aren't really a string|array. I can't see how you'd even argue that.
 
We should solve it by adding Iterable etc.
 
@Andrea because callable actually also does a check of callable.
 
10:31 PM
@LeviMorrison Well, exactly
 
@Andrea And callable is more string|array|object(with __invoke)
 
But array|Traversable is reasonable because it isn't everything you can use in a foreach
 
You don't actually want one of two types. You want subclasses of some type
@LeviMorrison How isn't it?
 
An object is always allowed in a foreach.
It will iterate over the properties.
 
@LeviMorrison Fair point
@bwoebi Which is why you'd use a superclass rather than specifying a list of acceptable types
 
10:33 PM
(For what it is worth I think that's a really bad design point. Who knows, maybe we can deprecate and remove it sometime.)
 
@Andrea you can't add superclasses to random classes which aren't defined by you…
 
It's like the difference between the (hypothetical) RequestInterface and Symfony\blah\Request|Laravel\blah\Request|CakePHP\blah\Request
@bwoebi Sure.
 
@Andrea that's solved by PSR… but nothing the language has part of.
 
@bwoebi ?
 
(Maybe we can error when calling count when the type isn't array|Countable too)
(Returning 1 isn't helping anything)
 
10:35 PM
@LeviMorrison that's PHP trying to be Perl, which has properly implemented scalar/vector distinction
also
I'm not sure it's good API design to allow completely distinct types for the same parameter
Make a different function
If they're a superclass, use a superclass
 
@Andrea take str_replace. you can either pass a string to replace… or an array of strings. No need for two funcs there.
It's implicit overloading.
 
@LeviMorrison bug?
 
(Nevermind, it's fixed later)
 
Hmm
 
This is saddening: 3v4l.org/JaJBA
 
10:40 PM
@LeviMorrison why?
 
@LeviMorrison huh?
I don't see why
 
That's exactly how it is specified?
 
objects are scalar
 
All of that should be an error :(
 
@LeviMorrison totally
 
10:40 PM
yes
 
(or at least warning)
 
it's PHP trying to be Perl
 
Especially if you consider that sizeof is an alias of count
 
and laughably failing
 
it should be a strict-types-like warning
 
10:41 PM
E_Y_U_DO_THIS
 
PHP tries SO HARD to be Perl
and utterly, utterly fails
Really, PHP would be a lot better if it was just a set of Perl scripts
<enters time machine>
 
Not sure how PHP tries to be perl?!
 
vectors and scalars
pretending numeric strings are numbers
etc.
 
Do we have anything that says we can deprecate things in minor releases?
The release process doesn't explicitly say anything about it.
(or any kind of new warning)
 
We can do anything we want so long as an RFC gets passed for it.
There's no rules passed constraining future RFCS - and you probably don't want that.
 
10:48 PM
Sure -- in this case it's a class of RFCs.
 
@LeviMorrison yes, we can deprecate in minors
 
I know we've done this historically; any written backing for it?
 
no yes
 
40 secs ago, by NikiC
@LeviMorrison yes, we can deprecate in minors
So mote it be.
 
lmao
It is written.
Can I sneak a deprecation into 7.0? I'm tempted to try :)
 
10:51 PM
what do you want to deprecate?
 
All of those would emit deprecated notices.
(and bool too)
Essentially require array|Countable.
 
@LeviMorrison try to mark these as bugs ;)
 
@FlorianMargaine It's formally documented behavior.
:(
 
@LeviMorrison damn.
 
@LeviMorrison no problem, file a doc bug as well
 
10:53 PM
@NikiC lol
See if I can justify deprecating it still.
 
@LeviMorrison The trick is getting this in without an RFC ;)
 
@NikiC Agreed :)
 
If it's not an RFC it's probably okay
 
you can try making a refactor for STH and sneakily put this in
 
Though I fear doing it without an RFC will be met with "sneaky, sneaky" remarks.
 
10:54 PM
# It would require an explicit cast for halfway legitimate cases like
function ($var) {
    $elements = count($var);
    foreach((array) $var as $element) ...;
}
 
@bwoebi isn't that broken code?
 
no, why?
 
@FlorianMargaine yes it is
 
What... what is that doing?
 
@bwoebi $elements will always be 1
 
10:55 PM
@FlorianMargaine except an array was passed…
 
...it's relying on the cast from non-array types to array types to be array($value)?
 
@bwoebi I don't see how it's relevant then
 
@LeviMorrison yes
@LeviMorrison which is pretty commonly used
 
@bwoebi I pray that's not true.
Forgive them, Lord, for they know not what they do.
 
I don't get it :|
 
10:57 PM
@LeviMorrison I've seen and written such code myself often enough…
 
@LeviMorrison It's really not uncommon to accept a string or an array of strings and use foreach((array) $var
 
Then:
Forgive them, Lord, for they have sinned.
 
lol
no, really…
 
Okay, time to make a case for "bug fix" for this behavior.
 
I'm okay with fixing count though… just telling you ;-)
 

« first day (1618 days earlier)      last day (3340 days later) »