Skip to content

Stdlib: forward_static_call() outside class scope must Error — succeeds on VM (ext/standard/basic_functions.c) #12164

Closed

Description

@PurHur

Summary

Calling forward_static_call() from global scope (no active class scope) must throw Error: Cannot call forward_static_call() when no class scope is active (Zend/php-src). The VM currently executes successfully and returns the callee result.

Note: forward_static_call_array() from global scope is allowed on Zend — only the non-array form is restricted.

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/issue_forward_static_scope.php'
./script/docker-exec.sh -- bash -lc 'php test/repro/issue_forward_static_scope.php'

Zend (expected):

Error:Cannot call forward_static_call() when no class scope is active

VM (today):

unexpected_ok:3

php-src reference

  • ext/standard/basic_functions.c — zif_forward_static_call() class-scope guard

Implementation (PHP-in-PHP)

  • Enforce active class scope in ext/standard/ builtin (forward_static_call) / shared VM guard before invoking the callback.
  • Mirror guard in JIT lowering if the builtin is JIT-supported.

Done when (php-src-strict)

  • Global-scope repro throws Error with Zend message
  • In-class forward_static_call([C::class, 'm']) still works
  • forward_static_call_array() global behavior unchanged (Zend parity)
  • Targeted test guard

Refs #1492

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 26, 2026
  2. PurHur commented on Jun 26, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #12165, #12164)

  3. PurHur commented on Jun 26, 2026

    @PurHur
    OwnerAuthor

    Already fixed on master (2026-06-26 verify): global-scope forward_static_call([C::class, 'm']) throws Error: Cannot call forward_static_call() when no class scope is active. Repro: test/repro/issue_forward_static_scope.php. Unclaiming — no code change needed.

  4. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #12164)

  5. added a commit that references this issue on Jun 30, 2026
    620f908
  6. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    Merged via #14058. VM repro + compliance green; forward_static_call_array('strlen') still allowed at global scope per Zend.

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:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions