Skip to content

Language: outside call to private static skips __callStatic (re-#3273, zend_object_handlers.c) #25670

Description

@PurHur

Category

Language · php-src-strict · magic static call visibility (regression vs #3273)

Problem

Same visibility rule as instance __call, for statics: an inaccessible private static method from outside scope must dispatch __callStatic. VM throws private-method Error instead.

Repro (2026-07-31) Zend 8.2 VM
A::hid() with private static function hid() + __callStatic CS_hid / m Error: Call to private method A::hid() from global scope

php-src reference

PHP implementation target

  • lib/VM.php — static method resolution / __callStatic walk (~18282+): visibility failure for caller scope → __callStatic, not private Error
  • PHP-in-PHP only
  • Compliance: test/compliance/cases/language/magic_callstatic_private.phpt

Repro

./script/docker-exec.sh -- bash -lc 'cat > /tmp/cs_priv.php <<'"'"'PHP'"'"'
<?php
class A {
  private static function hid() { return "p"; }
  public static function __callStatic($n, $a) { echo "CS_$n\n"; return "m"; }
}
echo A::hid(), "\n";
PHP
php bin/vm.php /tmp/cs_priv.php'

Done when

  • Outside-scope static call to private/protected static method invokes __callStatic
  • In-scope static calls use the real method
  • Compliance PHPT; php-src-strict

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:vmVirtual machinebugSomething isn't workingimplementation-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