Category
language · compiler
Problem
Using parent::class at file scope must be rejected at compile time. Zend reports:
Cannot use "parent" in the global scope
This compiler emits a misleading fatal:
self:: used outside of class scope
php-src reference
Repro
test/repro-maintainer/parity_parent_class_global.php:
<?php
class C extends stdClass {}
echo parent::class;
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro-maintainer/parity_parent_class_global.php 2>&1 | head -5'
Expected: compile/runtime fatal mentioning parent / global scope (Zend wording).
Actual: self:: used outside of class scope.
Acceptance
- Fatal text matches Zend for
parent:: / self:: / static:: pseudo-constants used outside allowed scope.
- Compliance
.phpt comparing message substring.
Category
language·compilerProblem
Using
parent::classat file scope must be rejected at compile time. Zend reports:Cannot use "parent" in the global scopeThis compiler emits a misleading fatal:
self:: used outside of class scopephp-src reference
Zend/zend_compile.c—parent/self/staticscope checks for::classRepro
test/repro-maintainer/parity_parent_class_global.php:./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro-maintainer/parity_parent_class_global.php 2>&1 | head -5'Expected: compile/runtime fatal mentioning
parent/ global scope (Zend wording).Actual:
self:: used outside of class scope.Acceptance
parent::/self::/static::pseudo-constants used outside allowed scope..phptcomparing message substring.