1282 Commits
Author SHA1 Message Date
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
Gina Peter Banyard fdd2f74612 reflection: pass zend_object* to _class_string() (#23279)
Rather than a zval
2026-08-15 17:00:44 +01: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
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
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
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 a1cd11ad0d ReflectionMethod::getPrototype(): add parentheses to error message 2026-07-27 10:36:46 -07:00
Daniel Scherzer b043ea3579 Reflection: whitespace cleanup
Avoid tabs or multiple spaces other than for indentation, remove a leading
newline from `ReflectionProperty::hasHook()`
2026-07-19 09:41:40 -07:00
Daniel Scherzer 79144103ad Reflection: remove unused parameter from get_ce_from_scope_name() 2026-07-19 09:41:40 -07:00
Daniel Scherzer c06e86d9ca Reflection: consistent pointer type declaration spacing
Put the `*` next to the name, rather than the type
2026-07-19 09:41:39 -07:00
Daniel Scherzer b8dc2a804c Reflection: replace struct _zend_arg_info with zend_arg_info 2026-07-19 09:41:39 -07:00
Daniel Scherzer 07b5905d7f Reflection: mark a whole bunch of pointers as const 2026-07-19 09:41:39 -07:00
Daniel Scherzer 6455aab46f Reflection: integer types cleanup
Use `uint32_t` for values that are really `uint32_t`, like constant module
numbers and the result from `zend_hash_num_elements()`. Use `uint32_t` for
counting up, when values should never be negative. Adjust format specifiers to
use `PRIu32` rather than `%d` for the uint32_t values.
2026-07-19 09:41:35 -07:00
Daniel Scherzer 121d19f62a Reflection: use early returns to reduce indentation 2026-07-17 11:40:43 -07:00
Daniel Scherzer 44608b00ea Reflection: layout and indentation cleanup
Consistently indent with tabs, split up some long lines, combine some nested
conditions, and overall try to improve readability.
2026-07-17 11:40:43 -07:00