1748 Commits
Author SHA1 Message Date
Kamil Tekiela eef0f71aa7 ext/reflection: Make properties readonly (#24282) 2026-10-22 15:34:57 +01:00
Gina Peter Banyard 84580818cf Zend/lazy_objects: drop now unused initializer_zv param in zend_object_make_lazy() 2026-10-10 18:27:38 +01:00
Gina Peter Banyard 612b1f9d22 Zend: derive lazy object initializer callble from FCC 2026-10-10 18:27:38 +01:00
Gina Peter Banyard c6f3b2ad44 reflection: no longer always inline reflection_class_new_lazy()
As per @ndossche remark: https://github.com/php/php-src/pull/23998#discussion_r4155152767
2026-10-01 13:37:35 +01:00
Gina Peter Banyard e301043f16 reflection: mark reflection_class_new_lazy as static always inline
This is a common implementation for various lazy object methods
2026-09-30 15:44:06 +01:00
Gina Peter Banyard 484d324dc7 reflection: use ZEND_FCC_INITIALIZED macro for lazy objects 2026-09-30 15:44:06 +01:00
Gina Peter Banyard baf9a0db86 Zend: use zend_object* parameter type instead of zval* for closure API (#24015) 2026-09-30 15:42:41 +01:00
Gina Peter Banyard 184402b670 Zend: replace zend_is_callable_ex with non-ex version
As the new signature is actually useful now
2026-09-29 22:51:07 +01:00
ndossche 2bb327e004 Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5:
  Fix GH-23842: skipLazyInitialization() copies unresolved constant defaults
2026-09-29 21:40:11 +02:00
ndossche c72a5cad08 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-23842: skipLazyInitialization() copies unresolved constant defaults
2026-09-29 21:39:34 +02:00
lazerg e0eea65aa4 Fix GH-23842: skipLazyInitialization() copies unresolved constant defaults
Closes GH-23843.
2026-09-29 21:39:12 +02:00
Daniel Scherzer 0da9d196b1 Reflection: print boolean constant values as true and false
Updates the output of `ReflectionClassConstant::__toString()` and
`ReflectionConstant::__toString()`, as well as the other ways that class
constants are printed, e.g. `ReflectionClass::__toString()`.
2026-09-22 13:24:10 -07:00
Daniel Scherzer 2b1f6ad52b Reflection: add regression tests for printing boolean constant values
Add regression tests for the output of `ReflectionClassConstant::__toString()`
and `ReflectionConstant::__toString()` when the value of the constant is
boolean `true` or `false`. The `true` cases are already covered by some
existing tests, but it seems that the `false` cases are currently untested.
2026-09-22 13:23:52 -07:00
Dmytro Kulyk 67135cb97b gen_stub: Conditionally include zend_attributes.h to arginfo based on usage (#21570)
Headers required by the generated code (zend_attributes.h, zend_constants.h, zend_enum.h) are collected during generation and emitted as includes at the top of the arginfo file, with the same preprocessor conditions and PHP version guards as the code that needs them.

Removes the manual zend_attributes.h and zend_enum.h includes from sources that only needed them for the arginfo file they include.
2026-09-06 21:25:20 +02:00
Gina Peter Banyard fdd2f74612 reflection: pass zend_object* to _class_string() (#23279)
Rather than a zval
2026-08-15 17:00:44 +01:00
Arshid 1f0e6ef98a ext/spl: Narrow tentative return types for DirectoryIterator methods (#22642) 2026-08-15 14:31:09 +02:00
Gina Peter Banyard 7a5e452f14 Zend: use zend_object* for this_ptr
Instead of a zval
2026-08-14 14:38:56 +01:00
Gina Peter Banyard fbb2e1f23d Zend: pass $this as a zend_object*
Instead of a zval*, this is in preparation for converting the this_ptr field of zend_closure to zend_object*
2026-08-14 14:38:56 +01:00
Daniel Scherzer d3f4eada10 [RFC] Deprecate ReflectionMethod invocation for static methods with objects
`ReflectionMethod::invoke()` and `::invokeArgs()` are affected, but share
implementation code and so are updated together.

https://wiki.php.net/rfc/deprecations_php_8_6
2026-08-12 10:09:30 -07:00
Daniel Scherzer 1b5de53960 [RFC] Deprecate ReflectionProperty::setRawValue() with wrong types
https://wiki.php.net/rfc/deprecations_php_8_6
2026-08-12 10:09:29 -07:00
Daniel Scherzer 29f351d355 [RFC] Deprecate ReflectionProperty::setValue() with wrong types
https://wiki.php.net/rfc/deprecations_php_8_6
2026-08-12 10:09:25 -07:00
NickSdotandDanielEScherzer a2640aebc9 [RFC] Allow Readonly Property Defaults (GH-22588)
Co-authored-by: DanielEScherzer <daniel.e.scherzer@gmail.com>
2026-08-11 21:01:17 +02:00
Daniel Scherzer 72c70c4d9f Reflection: use new %pS format specifier (#23005)
Even when not needed for null bytes, avoids extra `strlen` calls.
2026-08-04 12:19:48 -07:00
Daniel Scherzer f4397bd1a8 Merge branch 'PHP-8.5'
* PHP-8.5:
  NEWS for PHP 8.5
  NEWS for PHP 8.4
  GH-22905: avoid truncation on null bytes in reflection exceptions
  Reflection: Add regression tests for error messages with null bytes
2026-08-03 10:46:00 -07:00
Daniel Scherzer 74a1f21ebd Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  NEWS for PHP 8.4
  GH-22905: avoid truncation on null bytes in reflection exceptions
  Reflection: Add regression tests for error messages with null bytes
2026-08-03 10:22:50 -07:00
Daniel Scherzer 866696459a GH-22905: avoid truncation on null bytes in reflection exceptions
In addition to the fixes within the reflection extension, support for error
strings with null bytes was added to `zend_throw_error()` and
`zend_throw_exception_ex()`. The changes to `zend_throw_exception_ex()` are a
partial backport of #16684.
2026-08-03 08:51:10 -07:00
Daniel Scherzer 14b6cd3636 Reflection: Add regression tests for error messages with null bytes
So that when the outputs are fixed the changes can be confirmed in tests
2026-08-03 08:43:31 -07:00
Jorg Adam Sowa 87b510be6f Use zend_hash_find_ptr_lc() for case-insensitive name lookups (batch 2) (#22591)
Continues #22565 for four sites that were missed: _class_exists_impl(),
function_exists(), pdo_stmt.c's dbstmt_method_get(), ReflectionClass::
hasMethod()/getMethod(), and phpdbg's print func/method commands. No
behavior change.
2026-08-03 13:27:32 +01:00
Ilia Alshanetsky 8b596a28ab Merge branch 'PHP-8.5'
* PHP-8.5:
  Resolve the effective property in ReflectionProperty lazy APIs

master takes the property info and scope directly in
reflection_property_get_effective_prop() and
reflection_property_check_lazy_compatible(), so both call sites are
adapted to those signatures here.
2026-07-31 15:55:43 -04:00
Ilia Alshanetsky dc875173c2 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Resolve the effective property in ReflectionProperty lazy APIs
2026-07-31 15:50:13 -04:00
Ilia Alshanetsky ae42ecf1f3 Resolve the effective property in ReflectionProperty lazy APIs
skipLazyInitialization() and isLazy() indexed the object with the
property info of the reflected scope. When a child adds hooks to a plain
parent property the child gets its own storage slot, so a parent-scoped
ReflectionProperty read and wrote the dead parent slot: isLazy() reported
false and skipLazyInitialization() was a silent no-op. Resolve the
effective property first, as getRawValue(), setRawValue() and
setRawValueWithoutLazyInitialization() already do.

Closes GH-22969
2026-07-31 15:47:23 -04:00
Ilia Alshanetsky dfba0e8737 Merge branch 'PHP-8.5'
* PHP-8.5:
  Check object_init_ex() in ReflectionMethod::createFromMethodName()
2026-07-31 13:34:33 -04:00
Ilia Alshanetsky 2965b248c6 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Check object_init_ex() in ReflectionMethod::createFromMethodName()
2026-07-31 13:31:38 -04:00
Ilia Alshanetsky b80ef095ea Check object_init_ex() in ReflectionMethod::createFromMethodName()
The result was ignored, so calling the factory on an uninstantiable
subclass ran on a NULL zend_object: object_init_ex() throws, sets the
return value to NULL and reports FAILURE, and Z_REFLECTION_P() then
offsets backwards from that NULL. Other object_init_ex() calls in this
file already test the result.

Closes GH-22978
2026-07-31 13:28:44 -04:00
Ilia Alshanetsky d52b81e308 Merge branch 'PHP-8.5'
* PHP-8.5:
  Avoid truncation on null bytes in class and function names
2026-07-31 12:13:41 -04:00
Ilia Alshanetsky cc0ff7e0a0 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Avoid truncation on null bytes in class and function names
2026-07-31 12:11:08 -04:00
Ilia Alshanetsky 841fe26c11 Avoid truncation on null bytes in class and function names
Follow-up to GH-22681. _class_string() and _function_string() still
formatted the class name and the function name with %s, so
Reflection*::__toString() cut them at the first NUL. Anonymous class
names embed one, both directly and inside the name of a closure declared
in such a class.

Closes GH-22971
2026-07-31 12:08:11 -04:00
Ilia Alshanetsky 7c55b0d290 Merge branch 'PHP-8.5'
* PHP-8.5:
  Parse qualified reflection names with a length-aware search

Master already carries the const declarations the backport introduces, so
the resolution keeps them and takes only the two zend_memnstr() calls.
2026-07-31 12:02:52 -04:00
Ilia Alshanetsky 4a8028ce4f Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Parse qualified reflection names with a length-aware search
2026-07-31 11:59:25 -04:00
Ilia Alshanetsky 3a9d86a81b Parse qualified reflection names with a length-aware search
ReflectionMethod::__construct(), ReflectionMethod::createFromMethodName()
and ReflectionClass::getProperty() split "Class::member" with strstr(),
which stops at the first NUL. Anonymous class names embed one, so a name
obtained from ReflectionClass::getName() was rejected. Use zend_memnstr()
over the whole string instead.

Closes GH-22970
2026-07-31 11:56:18 -04:00
Ilia Alshanetsky 1da01f076b Merge branch 'PHP-8.5'
* PHP-8.5:
  Free previous state when re-calling Reflection*::__construct()

Master additionally stores the reflected closure in intern->obj for the
invoke() identity check, so the merge releases the previous object before
overwriting it and clears the slot when re-constructing onto a named
method.
2026-07-31 11:51:25 -04:00
Ilia Alshanetsky fc6b78ea2a Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Free previous state when re-calling Reflection*::__construct()
2026-07-31 11:42:14 -04:00
Ilia Alshanetsky 87f8d17426 Free previous state when re-calling Reflection*::__construct()
ReflectionMethod::__construct() overwrote intern->ptr without releasing
the previous Closure::__invoke() trampoline, and
ReflectionClassConstant::__construct() overwrote the $name and $class
slots without dropping their previous references. ReflectionFunction,
ReflectionParameter and ReflectionProperty already release prior state
on re-entry.

Closes GH-22968
2026-07-31 11:39:17 -04:00
Gina Peter Banyard a66ffb80fd Zend: move '\' and lowercase handling to zend_fetch_function() (#22966)
Rather than having the logic be repeated over and over at the call sites.
2026-07-31 12:42:43 +01:00
Gina Peter Banyard 9e9445f742 ext/reflection: add namespace methods to ReflectionAttribute
Add the ReflectionAttribute::inNamespace(), ReflectionAttribute::getNamespaceName(), and ReflectionAttribute::getShortName() methods.

Closes GH-19556
2026-07-30 21:15:35 +01:00
Gina Peter Banyard ee019fab5a ext/reflection: move ReflectionAttribute tests into subfolder 2026-07-30 21:15:35 +01:00
Daniel Scherzer a5e34c6030 ReflectionClass::setStaticPropertyValue(): update missing property error
Align with other Reflection exceptions for missing class properties (and
methods, constants, etc.) by changing the message to
"Property %s::$%s does not exist".
2026-07-27 10:36:50 -07:00
Daniel Scherzer acf7ba883f Reflection: improve error messages for lazy initialization errors
Improve error messages from `reflection_property_check_lazy_compatible()`, as
triggered by both `ReflectionProperty::setRawValueWithoutLazyInitialization()`
and `ReflectionProperty::skipLazyInitialization()`. Say "cannot" instead of
"can not", and include parentheses after the method name.
2026-07-27 10:36:50 -07:00
Daniel Scherzer e0693e9c3d Reflection: add regression tests for lazy initialization errors
Add tests for the four error cases in
`reflection_property_check_lazy_compatible()`, as triggered by both
`ReflectionProperty::setRawValueWithoutLazyInitialization()` and
`ReflectionProperty::skipLazyInitialization()`. While some of these errors are
covered by existing tests, having all of the errors in one place will make it
easier to see the changes when the error messages are improved.
2026-07-27 10:36:50 -07:00
Daniel Scherzer a1cd11ad0d ReflectionMethod::getPrototype(): add parentheses to error message 2026-07-27 10:36:46 -07:00