Category
Language · php-src-strict · scope resolution Error message
Problem
self:: / parent:: evaluated with no active class scope (e.g. eval('self::foo();') at top level) must Error with Zend’s wording. VM already matches for static::, but self/parent use a different string.
Verified 2026-08-08 @ 4bbede110e vs php:8.4-cli 8.4.24.
| Repro |
Zend 8.4.24 |
VM PROFILE=8.4 |
eval('self::foo();') |
Cannot access "self" when no class scope is active |
Cannot use "self" in the global scope ❌ |
eval('parent::foo();') |
Cannot access "parent" when no class scope is active |
Cannot use "parent" in the global scope ❌ |
eval('static::foo();') (control) |
Cannot access "static" when no class scope is active |
same ✅ |
php-src reference
PHP implementation target
- Scope-resolution Error construction in
lib/ / VM — align self/parent messages with the existing static path (Zend “Cannot access … when no class scope is active”)
- PHP-in-PHP only
Repro
./script/docker-exec.sh -- bash -lc 'cat > /tmp/self_parent_scope.php <<'"'"'PHP'"'"'
<?php
try { eval("self::foo();"); } catch (Throwable $e) { echo "self:", $e->getMessage(), "\n"; }
try { eval("parent::foo();"); } catch (Throwable $e) { echo "parent:", $e->getMessage(), "\n"; }
try { eval("static::foo();"); } catch (Throwable $e) { echo "static:", $e->getMessage(), "\n"; }
PHP
PHP_COMPILER_PROFILE=8.4 php bin/vm.php /tmp/self_parent_scope.php'
Done when
Trust snapshot (this maintainer run)
user_release_ready: yes · inventory OK 7252/7252 · no open worker PRs
Category
Language· php-src-strict · scope resolution Error messageProblem
self::/parent::evaluated with no active class scope (e.g.eval('self::foo();')at top level) must Error with Zend’s wording. VM already matches forstatic::, butself/parentuse a different string.Verified 2026-08-08 @
4bbede110evsphp:8.4-cli8.4.24.eval('self::foo();')Cannot access "self" when no class scope is activeCannot use "self" in the global scope❌eval('parent::foo();')Cannot access "parent" when no class scope is activeCannot use "parent" in the global scope❌eval('static::foo();')(control)Cannot access "static" when no class scope is activephp-src reference
Zend/zend_execute.c—ZEND_FETCH_CLASS_*/ scope errors for self/parent/staticparent::classcompile fatal message — different surface)PHP implementation target
lib// VM — alignself/parentmessages with the existingstaticpath (Zend “Cannot access … when no class scope is active”)Repro
Done when
self/parent/staticoutside class scope match Zend Error messages on VM/JITtest/repro/guardTrust snapshot (this maintainer run)
user_release_ready: yes· inventory OK 7252/7252 · no open worker PRs