Nikita Popov [Tue, 9 Jun 2020 08:09:48 +0000 (10:09 +0200)]
Remove some special-casing in zend_call_method()
Don't treat the !fn_proxy && !obj_ce case differently. There doesn't
seem to be any need for it, and it will result in subtly different
behavior (e.g. it will accept "Foo::bar" syntax, but break as soon
as you pass in an fn_proxy cache).
Fix #74267: segfault with streams and invalid data
If the current character is a line break character, it cannot be a tab
or space character, so we would always fail with an invalid sequence
error. Obviously, these `scan_stat == 4` conditions are meant to be
exclusive.
Furthermore, if `in_pp == NULL || in_left_p == NULL` is true, we hit a
segfault if we are not returning right away. Obviously, the additional
constraints don't make sense, so we remove them.
Tyson Andre [Sun, 7 Jun 2020 17:17:40 +0000 (13:17 -0400)]
Optimize out no-op `yield from` statements
If the array is empty, then I'd expect that the generator is never left,
and that can be converted to a no-op and the return value would always be `null`.
Make `yield from [];` as efficient as `if (false) { yield null; }`
when opcache's sccp pass is enabled.
Nikita Popov [Fri, 5 Jun 2020 14:55:20 +0000 (16:55 +0200)]
Fix bug #77966: Cannot alias a method named "namespace"
This is a bit tricky: In this cases we have "namespace as", which
means that we will only recognize "namespace" as an identifier when
the lookahead token is already at the "as". This means that
zend_lex_tstring picks up the wrong identifier.
We solve this by actually assigning the identifier as the semantic
value on the parser stack -- as in almost all cases we will not
actually need the identifier, this is just an (offset, size)
reference, not a copy of the string.
Additionally, we need to teach the lexer feedback mechanism used
by tokenizer TOKEN_PARSE mode to apply feedback to something
other than the very last token. To that purpose we pass through
the token text and check the tokens in reverse order to find the
right one.
Eliot Lear [Mon, 9 Mar 2020 15:01:20 +0000 (16:01 +0100)]
Add support for Cryptographic Message Syntax (CMS)
It add CMS (RFC 5652) support, which is an update to PKCS7. The functions
are analogous BUT NOT IDENTICAL to openssl_pkcs7*. In particular, support for
different encodings (PEM, DER, SMIME) is now available.
Gabriel Caruso [Sat, 30 May 2020 22:17:31 +0000 (00:17 +0200)]
Add $filter parameter for ReflectionClass::(getConstants|getReflectionConstants)
This solves [#79628](https://bugs.php.net/79628).
Similar to `ReflectionClass::getMethods()` and `ReflectionClass::getProperties()`,
this new `$filter` argument allows the filtering of constants defined in a class by
their visibility.
For that, we create three new constants for `ReflectionClassConstant`:
Allow defining of uname value for reproducible builds
Extend configure.ac to accept PHP_UNAME as env variable to set the value of the
PHP_UNAME define in a reproducible manner. This allows distributions to set a
fixed value for php_uname and keep the default behaviour if PHP_UNAME is not
set.
Drop hard-coded /W3 default in favor of custom CFLAGS
Building with `/W3` shows an awful lot of warnings on Windows, so it's
really hard to spot the more important ones. Since it is not possible
to override the hard-coded `/W3`, we drop it altogether, so MSVC uses
the default `/W1`. Users are encouraged to increase the warning level
via the environment variable `CFLAGS` before doing configure.
We also enable `/WX` (treat warnings as errors) for AppVeyor CI, using
`/W1` for now, since otherwise the build would fail.
`zend_llist_add_element()` and `zend_llist_prepend_element()` now
explicitly expect a *const* pointer.
We use the macro `ZEND_VOIDP()` instead of a `(void*)` cast to suppress
C4090; this should prevent accidential removal of the cast by
clarifying the intention, and makes it easier to remove the casts if
the issue[1] will be resolved sometime.
Nikita Popov [Fri, 29 May 2020 08:33:22 +0000 (10:33 +0200)]
Pass zend_string message to zend_error_cb
This makes the zend_error_cb API simpler, and avoid formatting
the same message in multiple places.
It should be noted that the passed zend_string is always
non-persistent, so if you want to store it persistently somewhere,
you may still need to duplicate it.
The last_error_message is cleared a bit more aggressive, to make
sure it doesn't hang around across allocator life-cycles.
Nikita Popov [Fri, 29 May 2020 15:27:51 +0000 (17:27 +0200)]
Fixed bug #72089: Throw Error on require failure
It should be noted that we still throw the usual fopen warnings,
but the final fatal error becomes an Error exception. Combine
with @ to suppress FS warnings.
The implementation of that RFC changed the initial value of
`zend_array.nNextFreeElement` to `-1`; we work around that by inserting
first, and retrieving the index afterwards.
We also fix the erroneous printf specifier for the unsigned integer.
Fix #79665: ini_get() and opcache_get_configuration() inconsistency
Overriding the given INI values in modifier callbacks is not possible,
so instead of enforcing "normalized" internal values, we just reject
the attempted changes.