php-src/ext/reflection
Ilija Tovilo f8d1864bbb
Delay #[Attribute] arg validation until runtime
Fixes GH-13970
Closes GH-14105

We cannot validate at compile-time for multiple reasons:

* Evaluating the argument naively with zend_get_attribute_value can lead to code
  execution at compile time through the new expression, leading to possible
  reentrance of the compiler.
* Even if the evaluation was possible, it would need to be restricted to the
  current file, because constant values coming from other files can change
  without affecting the current compilation unit. For this reason, validation
  would need to be repeated at runtime anyway.
* Enums cannot be instantiated at compile-time (the actual bug report). This
  could be allowed here, because the value is immediately destroyed. But given
  the other issues, this won't be needed.

Instead, we just move it to runtime entirely. It's only needed for
ReflectionAttribute::newInstance(), which is not particularly a hot path. The
checks are also simple.
2024-05-06 12:38:56 +02:00
..
tests Fix GH-13517: Multiple test failures when building with --with-expat 2024-02-27 21:49:01 +01:00
config.m4 Normalize comments in *nix build system m4 files 2019-05-12 18:43:03 +02:00
config.w32 Remove HAVE_* for always available extensions 2019-04-14 11:44:12 -03:00
CREDITS Change some permissions from 755 to 644 2018-08-28 23:26:49 +02:00
php_reflection_arginfo.h Merge branch 'PHP-8.1' into PHP-8.2 2023-02-23 23:27:55 +01:00
php_reflection.c Delay #[Attribute] arg validation until runtime 2024-05-06 12:38:56 +02:00
php_reflection.h Update http->https in license (#6945) 2021-05-06 12:16:35 +02:00
php_reflection.stub.php Merge branch 'PHP-8.1' into PHP-8.2 2023-02-23 23:27:55 +01:00