Skip to content

Language: parent::class outside class scope — wrong compile fatal message (zend_compile.c) #5024

Description

@PurHur

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions