xref: /PHP-7.4/Zend/tests/009.phpt (revision 782352c5)
1--TEST--
2get_class() tests
3--FILE--
4<?php
5
6class foo {
7	function bar () {
8		var_dump(get_class());
9	}
10    function testNull ()
11    {
12        var_dump(get_class(null));
13    }
14}
15
16class foo2 extends foo {
17}
18
19foo::bar();
20foo2::bar();
21
22$f1 = new foo;
23$f2 = new foo2;
24
25$f1->bar();
26$f2->bar();
27
28var_dump(get_class());
29var_dump(get_class("qwerty"));
30
31var_dump(get_class($f1));
32var_dump(get_class($f2));
33
34$f1->testNull();
35
36echo "Done\n";
37?>
38--EXPECTF--
39Deprecated: Non-static method foo::bar() should not be called statically in %s on line %d
40string(3) "foo"
41
42Deprecated: Non-static method foo::bar() should not be called statically in %s on line %d
43string(3) "foo"
44string(3) "foo"
45string(3) "foo"
46
47Warning: get_class() called without object from outside a class in %s on line %d
48bool(false)
49
50Warning: get_class() expects parameter 1 to be object, string given in %s on line %d
51bool(false)
52string(3) "foo"
53string(4) "foo2"
54
55Warning: get_class() expects parameter 1 to be object, null given in %s on line %d
56bool(false)
57Done
58