Ilija Tovilo [Wed, 18 Mar 2020 23:51:51 +0000 (00:51 +0100)]
Make throw statement an expression
RFC: https://wiki.php.net/rfc/throw_expression
This has an open issue with temporaries that are live at the time
of the throw being leaked. Landing this now for easier testing and
will revert if we cannot resolve the issue.
Fix treatment of "self" when validating against trait method
If we're validating a class method against a trait method, we need
to treat "self" in the trait method as the class where the method
is used. To achieve this, we need to thread the proto scope through
all methods, so it can be provided separately from proto.common->scope.
This makes serialize with __sleep() behave the same as serialize()
without __sleep().
As in the non-__sleep() case, unserialize(serialize($x)) identity
may not be preserved due to replacement of uninitialized/unset
properties with default values. Fixing this will require changes to
the serialization format.
Tyson Andre [Tue, 21 Apr 2020 23:19:53 +0000 (19:19 -0400)]
Document change to ReflectionMethod->isConstructor/isDestructor
See https://externals.io/message/109377
This prevented PHPUnit's test doubles from being created for interfaces.
The reason this changed is
https://github.com/php/php-src/pull/3846/files#diff-3a8139128d4026ce0cb0c86beba4e6b9L5549-R5605
(ReflectionMethod::isConstruct checks if the method is the zend_class_entry's
constructor, etc.)
Add a single test that feeds different data types into the relevant
format specifiers, and remove tests that test full matrices of
different types with different formats and modifiers. We're just
interested in how the types are going to be interpreted, the behavior
of all the modifiers is going to stay the same.
These duplicate vprintf() variation tests. While it's useful to
test the vfprintf() and vsprintf() variants of the function, the
main formatting machinery is shared between them, and it makes
little sense to repeat the full set of format tests for all of
them.
Alex Dowad [Wed, 15 Apr 2020 13:25:14 +0000 (15:25 +0200)]
Fix bug #67369 ArrayObject serializatino drops the iterator class
When ArrayObject is round-tripped through serialize() and unserialize(),
it forgets any iterator class name which was set using ::setIteratorClass().
Fix that.
Fix #79491: Search for .user.ini extends up to root dir
The `start` parameter of `php_cgi_ini_activate_user_config` is supposed
to hold the byte offset of the doc root in the given `path`. However,
the current expression which fixes a potential type incompatibility
will ever only evaluate to zero or one, because it uses the *logical*
and operator (`&&`). Furthermore we notice that subtracting one from
`doc_root_len` is not necessary, so there is even no need for the
`start` parameter at all.
This is the change from GH-5417 but for FPM. This was stripping the
last character from the doc_root. Given how it is used, this should
be harmless, but let's make it less confusing...
Joe Cai [Sun, 19 Apr 2020 23:03:11 +0000 (09:03 +1000)]
Fix #79497: Fix php_openssl_subtract_timeval()
I stumbled upon this while debugging a strange issue with
stream_socket_client() where it randomly throws out errors when
the connection timeout is set to below 1s. The logic to calculate
time difference in php_openssl_subtract_timeval() is wrong when
a.tv_usec < b.tv_usec, causing connection errors before the timeout
is reached.
Tyson Andre [Sun, 19 Apr 2020 15:53:36 +0000 (11:53 -0400)]
Speed up ZEND_SWITCH_STRING/ZEND_SWITCH_LONG for wrong type
This has the minor benefit of avoiding loading the address of the
jump table when the expression for the switch isn't a string/long.
gcc doesn't seem to optimize that.
The previous function body is the original implementation: ad8652818a5
```
// Before: 0.267s, after: 0.265s
function test_switch($x) {
for ($i = 0; $i < 10000000; $i++) {
switch ($x) {
case 'a':
case 'b':
echo "i=$i\n";
}
}
}
test_switch(null);
```
This is only used in reflection, where doing a simple string check
is acceptable.
I'm also dropping the "dtor" printing in the reflection dump.
Dtors are just one of many magic methods, I don't think there's
a point in explicitly highlighting them, when the name is already
unambiguous.
Don't check all the remaining arguments after one check failed.
I don't think this makes an observable behavior difference,
because we already suppress duplicate exceptions in argument
type error reporting.
`func_get_args()` may return `zend_empty_array`, which has refcount 2
to enforce separation. We have to cater to that during type inference
so that the optimization in the JIT macro `SEPARATE_ARRAY` doesn't
prevent the separation.