You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Weaving a namespaced class whose attribute references a global constant (PHP_INT_MAX, PHP_EOL, …) aborts the whole transform:
Go\ParserReflection\ReflectionException: Namespace was not found in the file .../Php80GlobalConstAttrArg.php
The root cause is upstream in goaop/parser-reflection 4.0.0, but it takes down the framework's weaving pass, so tracking it here from the PHP 8.5 support audit (PR #597). Reproduces on PHP 8.4 / 8.5.10 / 8.6.0beta2.
Reproduction
namespaceSome\Ns;
class Php80GlobalConstAttrArg
{
#[ExprAttr(PHP_INT_MAX)]
publicfunctionlimited(): int { returnPHP_INT_MAX; }
}
NodeExpressionResolver::resolveExprConstFetch() falls back to looking the constant up in the file's global namespace (ReflectionFileNamespace($file, '')), and since the file only declares Some\Ns, the lookup itself throws.
Fixture: tests/Fixtures/audit/src/Php80GlobalConstAttrArg.php (audit branch). This is also why the audit fixtures initially broke DebugAdvisorCommandTest — one poisoned file aborts debug:advisor for the whole project.
Upstream (goaop/parser-reflection): resolveExprConstFetch() should resolve known built-in/defined constants via defined()/constant() before attempting a ReflectionFileNamespace lookup, and treat a missing global namespace in the file as "not resolvable here" rather than throwing. Filing/fixing that belongs in the parser-reflection repo; this issue tracks the framework-side impact.
Summary
Weaving a namespaced class whose attribute references a global constant (
PHP_INT_MAX,PHP_EOL, …) aborts the whole transform:The root cause is upstream in goaop/parser-reflection 4.0.0, but it takes down the framework's weaving pass, so tracking it here from the PHP 8.5 support audit (PR #597). Reproduces on PHP 8.4 / 8.5.10 / 8.6.0beta2.
Reproduction
NodeExpressionResolver::resolveExprConstFetch()falls back to looking the constant up in the file's global namespace (ReflectionFileNamespace($file, '')), and since the file only declaresSome\Ns, the lookup itself throws.Fixture:
tests/Fixtures/audit/src/Php80GlobalConstAttrArg.php(audit branch). This is also why the audit fixtures initially brokeDebugAdvisorCommandTest— one poisoned file abortsdebug:advisorfor the whole project.Proposed fix
Two layers:
resolveExprConstFetch()should resolve known built-in/defined constants viadefined()/constant()before attempting aReflectionFileNamespacelookup, and treat a missing global namespace in the file as "not resolvable here" rather than throwing. Filing/fixing that belongs in the parser-reflection repo; this issue tracks the framework-side impact.Environment