xref: /PHP-8.2/Zend/tests/bug48533.phpt (revision f8d79582)
1--TEST--
2Bug #48533 (__callStatic is not invoked for private/protected methods)
3--FILE--
4<?php
5
6class foo {
7    private function a() {
8        var_dump(1);
9    }
10    public function b() {
11        var_dump(2);
12    }
13    protected function c() {
14        var_dump(3);
15    }
16    static function __callstatic($a, $b) {
17        var_dump('__callStatic::'. $a);
18    }
19    public function __call($a, $b) {
20        var_dump('__call::'. $a);
21    }
22}
23
24$x = new foo;
25$x->a();
26$x->b();
27$x->c();
28$x::a();
29$x::c();
30$x::b();
31
32?>
33--EXPECTF--
34string(9) "__call::a"
35int(2)
36string(9) "__call::c"
37string(15) "__callStatic::a"
38string(15) "__callStatic::c"
39
40Fatal error: Uncaught Error: Non-static method foo::b() cannot be called statically in %s:%d
41Stack trace:
42#0 {main}
43  thrown in %s on line %d
44