Commit graph

939 commits

Author SHA1 Message Date
Máté Kocsis
5b5bfd6be4
Generate class entries from stubs for phar, posix, pspell, readline, reflection, session, shmop
Closes GH-6692
2021-02-15 00:11:22 +01:00
Dmitry Stogov
4b79dba932 Added Inheritance Cache.
This is a new transparent technology that eliminates overhead of PHP class inheritance.

PHP  classes are compiled and cached (by opcahce) separately, however their "linking" was done at run-time - on each request. The process of "linking" may involve a number of compatibility checks and borrowing methods/properties/constants form parent and traits. This takes significant time, but the result is the same on each request.

Inheritance Cache performs "linking" for unique set of all the depending classes (parent, interfaces, traits, property types, method types involved into compatibility checks) once and stores result in opcache shared memory. As a part of the this patch, I removed limitations for immutable classes (unresolved constants, typed properties and covariant type checks). So now all classes stored in opcache are "immutable". They may be lazily loaded into process memory, if necessary, but this usually occurs just once (on first linking).

The patch shows 8% improvement on Symphony "Hello World" app.
2021-02-09 22:53:57 +03:00
Dmitry Stogov
c195fcd678 Avoid modification of trait info 2021-01-19 11:54:01 +03:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Christoph M. Becker
b2fba0ef62 Fix build
We cannot `RETURN_THROWS()` here, since `return_value` is not defined.
2021-01-01 17:41:48 +01:00
Máté Kocsis
b23c865d15
Use RETURN_THROWS() in a few places 2021-01-01 16:52:48 +01:00
Christoph M. Becker
82f9e004da Fix ReflectionClass::getConstants() stub
If `zval_update_constant_ex()` fails, an exception has already been
thrown, so we clarify that in the implementation as well.

Closes GH-6557.
2021-01-01 14:46:28 +01:00
Nikita Popov
70f59b3416 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix usage of casted string in ReflectionParameter ctor
2020-11-24 16:42:52 +01:00
Nikita Popov
706241f82d Fix usage of casted string in ReflectionParameter ctor
Fixes oss-fuzz #27755.
2020-11-24 16:42:16 +01:00
Benjamin Eberlei
1727d96d0e Fixed bug #80370: Segmentation fault reflecting attributes of dynamic property
Closes GH-6428.
2020-11-17 10:54:27 +01:00
Nikita Popov
d033d5c07a Fix reflection getDefaultValue() with user arg info
The default value is part of the op_array in that case, but we have
no way to access it. Fail gracefully.
2020-11-12 11:02:04 +01:00
Nikita Popov
7f462c97f9 Revert "Make ReflectionUnionType final"
This reverts commit ef6adb4e27.

Per Ondrej's comment, this is already being used by BetterReflection
adaptors, ugh.
2020-10-26 08:51:06 +01:00
Máté Kocsis
ef6adb4e27
Make ReflectionUnionType final
Closes GH-6384
2020-10-25 20:14:07 +01:00
Remi Collet
91f47ee263 don't display default value for variadic 2020-10-07 16:30:18 +02:00
Nikita Popov
dee802498e Fixed bug #80190 2020-10-06 10:20:27 +02:00
Máté Kocsis
351776eae5
Make the $filter parameter of ReflectionClass::get*Constants() nullable 2020-09-29 11:04:10 +02:00
Nikita Popov
5686c16db4 Honor strict_types=1 for attributes, improve backtraces
Make ReflectionAttribute::newInstance() respect the strict_types=1
declaration at the attribute use-site. More generally, pretend that
we are calling the attribute constructor from the place where the
attribute is used, which also means that the attribute location will
show up properly in backtraces and inside "called in" error information.

This requires us to store the attributes strict_types scope (as flags),
as well as the attribute line number. The attribute filename can be
recovered from the symbol it is used on. We might want to expose the
attribute line number via reflection as well.

See also https://externals.io/message/111915.

Closes GH-6201.
2020-09-27 10:42:58 +02:00
Máté Kocsis
e950ca13ea
Consolidate the usage of "either" and "one of" in error messages
Closes GH-6173
2020-09-20 19:41:47 +02:00
Gabriel Caruso
1a8936cde3
Check ReflectionReference::fromArrayElement with union types
ReflectionReference::fromArrayElement(array $array, int|string $key): ?ReflectionReference
is going to be its official signature for PHP 8.0.

Closes GH-5651
2020-09-15 12:56:10 +02:00
Máté Kocsis
c98d47696f
Consolidate new union type ZPP macro names
They will now follow the canonical order of types. Older macros are
left intact due to maintaining BC.

Closes GH-6112
2020-09-11 11:00:18 +02:00
Máté Kocsis
a59923befd
Refactor ReflectionMethod::__construct()
Closes GH-6098
2020-09-11 10:59:13 +02:00
Máté Kocsis
8107a1da5a
Use ZPP instead of custom type checks
We can add these types as a native type declaration to stubs as a side-effect. Closes GH-6068
2020-09-04 14:32:34 +02:00
Nikita Popov
53a87547c8 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix leak on consteval exception in ReflectionClass::__toString()
2020-08-31 15:10:53 +02:00
Nikita Popov
1f6f9c70cb Fix leak on consteval exception in ReflectionClass::__toString() 2020-08-31 15:10:09 +02:00
Nikita Popov
1036fd2a70 Merge branch 'PHP-7.4'
* PHP-7.4:
  Check update constant failure in ReflectionClassConstant::__toString()
2020-08-31 14:50:40 +02:00
Nikita Popov
8bb2f406de Check update constant failure in ReflectionClassConstant::__toString() 2020-08-31 14:50:20 +02:00
Nikita Popov
b4196ae9df Fix fetching default value of internal function with userland arginfo
"Fix" in the sense of "not crash". We aren't able to actually
display the default value for this case, as there's no way to
fetch the relevant information right now.
2020-08-31 14:03:54 +02:00
Nikita Popov
8b77c58130 Accept zend_object* in zend_update_property 2020-08-07 16:40:27 +02:00
Nikita Popov
7991fc2753 Accept zend_object in zend_read_property 2020-08-07 16:40:27 +02:00
Máté Kocsis
ec22e5aa38
Get rid of empty function entries
Closes GH-5917
2020-08-01 10:07:05 +02:00
Nikita Popov
d92229d8c7 Implement named parameters
From an engine perspective, named parameters mainly add three
concepts:

 * The SEND_* opcodes now accept a CONST op2, which is the
   argument name. For now, it is looked up by linear scan and
   runtime cached.
 * This may leave UNDEF arguments on the stack. To avoid having
   to deal with them in other places, a CHECK_UNDEF_ARGS opcode
   is used to either replace them with defaults, or error.
 * For variadic functions, EX(extra_named_params) are collected
   and need to be freed based on ZEND_CALL_HAS_EXTRA_NAMED_PARAMS.

RFC: https://wiki.php.net/rfc/named_params

Closes GH-5357.
2020-07-31 15:53:36 +02:00
Máté Kocsis
5f25618f83
Add missing RETURN_THROWS() 2020-07-30 14:55:13 +02:00
Máté Kocsis
0d330e1a02
Add a few missing parameter types in stubs
Related to GH-5627
2020-07-30 14:26:45 +02:00
Máté Kocsis
8664ff7ae1
Cleanup argument handling in ext/reflection
Closes GH-5850
2020-07-24 17:47:42 +02:00
Nikita Popov
b3ea6ce720 Make ReflectionGenerator final
This class is not safe against malicious extension / instantiation.
2020-07-21 11:53:00 +02:00
Christopher Broadbent
ee7c7a8e26 Fixed bug #79820
Similar to what is done for ReflectionType itself, copy the
type name stored inside ReflectionProperty. Also make sure the
type field is always initialized for dynamic properties.

This is a non-issue in PHP 8, because we store a pointer to the
property_info there, rather than a copy.
2020-07-15 10:58:56 +02:00
Máté Kocsis
d30cd7d7e7
Review the usage of apostrophes in error messages
Closes GH-5590
2020-07-10 21:05:28 +02:00
Nikita Popov
302933daea Remove no_separation flag 2020-07-07 09:30:24 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
Nikita Popov
344c077400 Use zend_string_equals API in a couple places 2020-07-03 17:02:28 +02:00
Nikita Popov
c2b23d8cbe Fix leak in isDefaultValueAvailable()
Exposed in Symfony due to exit changes.
2020-06-30 11:16:56 +02:00
Martin Schröder
053ef28b8d Implement Attribute Amendments.
RFC: https://wiki.php.net/rfc/attribute_amendments

Support for attribute grouping is left out, because the short
attribute syntax RFC will likely make it obsolete.

Closes GH-5751.
2020-06-29 10:45:51 +02:00
Christoph M. Becker
cbce0cbacb Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #69804: ::getStaticPropertyValue() throws on protected props
2020-06-24 11:19:17 +02:00
Christoph M. Becker
26aefb750a Fix #69804: ::getStaticPropertyValue() throws on protected props
`ReflectionClass` allows reading of the values of private and protected
constants, and also to get private and protected static methods.
Therefore getting the values of private and protected static properties
is also permissible, especially since `::getStaticProperties()` already
allows to do so.

We also allow ::setStaticPropertyValue() to modify private and
protected properties, because otherwise this method is useless, as
modifying public properties can be done directly.
2020-06-24 11:17:36 +02:00
Christoph M. Becker
1dfeb70e6b Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79487: ::getStaticProperties() ignores property modifications
2020-06-24 10:08:51 +02:00
Christoph M. Becker
ef2130db88 Fix #79487: ::getStaticProperties() ignores property modifications
When retrieving the static class properties via reflection, we have to
cater to possible modifications.
2020-06-24 10:05:51 +02:00
Christoph M. Becker
cf70026ebc Merge branch 'PHP-7.4'
* PHP-7.4:
  Revert "Fix #79487: ::getStaticProperties() ignores property modifications"
2020-06-23 19:30:12 +02:00
Christoph M. Becker
f3cccfde9e Revert "Fix #79487: ::getStaticProperties() ignores property modifications"
This reverts commit a895bb6885.
2020-06-23 19:28:51 +02:00
Christoph M. Becker
f1d0eadc4d Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79487: ::getStaticProperties() ignores property modifications
2020-06-23 18:52:16 +02:00
Christoph M. Becker
a895bb6885 Fix #79487: ::getStaticProperties() ignores property modifications
When retrieving the static class properties via reflection, we have to
cater to possible modifications.
2020-06-23 18:48:54 +02:00