Category
language | php-src-strict
Problem
#[AllowDynamicProperties] is only valid on classes in PHP 8.2+. Zend rejects it on parameters with a compile-time fatal. This compiler accepts the attribute on a parameter (with spurious CFG deprecation noise) instead of failing like php-src.
Related umbrella: #4392 (attributes), #5124 (#[\DelayedTargetValidation]). This issue is the specific AllowDynamicProperties disallowed target slice — not promoted-parameter delayed validation (valid in PHP 8.4 via #5124).
php-src reference
Repro (failure today — probed 2026-06-07)
<?php
function f(#[AllowDynamicProperties] int $x) {}
echo "compiled\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php -r "function f(#[AllowDynamicProperties] int \$x) {} echo \"compiled\";" 2>&1 | head -1
php bin/vm.php -r "function f(#[AllowDynamicProperties] int \$x) {} echo \"compiled\";" 2>&1
'
| Runtime |
Result |
| Zend PHP 8.2 |
Fatal error: Attribute "AllowDynamicProperties" cannot target parameter (allowed targets: class) |
bin/vm.php |
prints compiled (compile succeeds) |
Additional invalid targets (same fix)
| Snippet |
Zend |
#[AllowDynamicProperties] function g() {} |
cannot target function |
class C { #[AllowDynamicProperties] public int $p; } |
cannot target property |
const X = 1; #[AllowDynamicProperties] /* on const */ |
cannot target class constant |
Add at least parameter + function cases to compliance PHPT.
Scope (this repo)
| Layer |
Path |
| Early guard |
lib/Compiler/AttributeNames.php — assertAllowDynamicPropertiesClassTargetOnly() already called for some decls; extend to parameters and functions |
| Compile hook |
lib/Compiler.php — parameter/method/function attribute validation passes (~lines calling AttributeNames::assertAllowDynamicPropertiesClassTargetOnly) |
| Builtin class |
ext/standard/BuiltinAttributes.php — AllowDynamicProperties registered with TARGET_CLASS only (#7145) |
| JIT/AOT |
Compile-time only — invalid targets must fail before codegen (no runtime fallback) |
| Tests |
test/compliance/cases/language/allow_dynamic_properties_param_target.phpt |
Do not add C runtime checks — reject in PHP compile path.
Done when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter allow_dynamic_properties_param'
Links
Category
language| php-src-strictProblem
#[AllowDynamicProperties]is only valid on classes in PHP 8.2+. Zend rejects it on parameters with a compile-time fatal. This compiler accepts the attribute on a parameter (with spurious CFG deprecation noise) instead of failing like php-src.Related umbrella: #4392 (attributes), #5124 (
#[\DelayedTargetValidation]). This issue is the specific AllowDynamicProperties disallowed target slice — not promoted-parameter delayed validation (valid in PHP 8.4 via #5124).php-src reference
Zend/zend_attributes.c—zend_validate_attribute_target(), allowed target bitmaskZend/zend_compile.c— attribute attachment onzend_argument_infoext/standard/basic_functions.c/zend_attributes.stub.php—AllowDynamicPropertiestargetsTARGET_CLASSonlyRepro (failure today — probed 2026-06-07)
Fatal error: Attribute "AllowDynamicProperties" cannot target parameter (allowed targets: class)bin/vm.phpcompiled(compile succeeds)Additional invalid targets (same fix)
#[AllowDynamicProperties] function g() {}class C { #[AllowDynamicProperties] public int $p; }const X = 1; #[AllowDynamicProperties] /* on const */Add at least parameter + function cases to compliance PHPT.
Scope (this repo)
lib/Compiler/AttributeNames.php—assertAllowDynamicPropertiesClassTargetOnly()already called for some decls; extend to parameters and functionslib/Compiler.php— parameter/method/function attribute validation passes (~lines callingAttributeNames::assertAllowDynamicPropertiesClassTargetOnly)ext/standard/BuiltinAttributes.php—AllowDynamicPropertiesregistered withTARGET_CLASSonly (#7145)test/compliance/cases/language/allow_dynamic_properties_param_target.phptDo not add C runtime checks — reject in PHP compile path.
Done when
cannot target parameter,allowed targets: class)echo "compiled"on VM for parameter repro./script/ci-fast.sh --filter allow_dynamic_properties_paramgreenVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter allow_dynamic_properties_param'Links