xref: /php-src/Zend/tests/bug45186_2.phpt (revision ee510eed)
1--TEST--
2Bug #45186.2 (__call depends on __callstatic in class scope)
3--FILE--
4<?php
5
6class bar  {
7    public function __call($a, $b) {
8        print "__call:\n";
9        var_dump($a);
10    }
11    public function test() {
12        self::ABC();
13        bar::ABC();
14        call_user_func(array('BAR', 'xyz'));
15        call_user_func('BAR::www');
16        call_user_func(array('self', 'y'));
17        call_user_func('self::y');
18    }
19    static function x() {
20        print "ok\n";
21    }
22}
23
24$x = new bar;
25
26$x->test();
27
28call_user_func(array('BAR','x'));
29try {
30    call_user_func('BAR::www');
31} catch (TypeError $e) {
32    echo $e->getMessage(), "\n";
33}
34try {
35    call_user_func('self::y');
36} catch (TypeError $e) {
37    echo $e->getMessage(), "\n";
38}
39
40?>
41--EXPECTF--
42__call:
43string(3) "ABC"
44__call:
45string(3) "ABC"
46__call:
47string(3) "xyz"
48__call:
49string(3) "www"
50
51Deprecated: Use of "self" in callables is deprecated in %s on line %d
52__call:
53string(1) "y"
54
55Deprecated: Use of "self" in callables is deprecated in %s on line %d
56__call:
57string(1) "y"
58ok
59call_user_func(): Argument #1 ($callback) must be a valid callback, class bar does not have a method "www"
60call_user_func(): Argument #1 ($callback) must be a valid callback, cannot access "self" when no class scope is active
61