6 changed files with 234 additions and 0 deletions
-
1NEWS
-
76ext/standard/basic_functions.c
-
2ext/standard/basic_functions.h
-
83ext/standard/tests/class_object/forward_static_call_001.phpt
-
21ext/standard/tests/class_object/forward_static_call_002.phpt
-
51ext/standard/tests/class_object/forward_static_call_003.phpt
@ -0,0 +1,83 @@ |
|||
--TEST-- |
|||
forward_static_call() called from outside of a method. |
|||
--FILE-- |
|||
<?php |
|||
|
|||
class A |
|||
{ |
|||
const NAME = 'A'; |
|||
public static function test() { |
|||
echo static::NAME, "\n"; |
|||
} |
|||
} |
|||
|
|||
class B extends A |
|||
{ |
|||
const NAME = 'B'; |
|||
|
|||
public static function test() { |
|||
echo self::NAME, "\n"; |
|||
forward_static_call(array('parent', 'test')); |
|||
} |
|||
|
|||
public static function test2() { |
|||
echo self::NAME, "\n"; |
|||
forward_static_call(array('self', 'test')); |
|||
} |
|||
|
|||
public static function test3() { |
|||
echo self::NAME, "\n"; |
|||
forward_static_call(array('A', 'test')); |
|||
} |
|||
} |
|||
|
|||
class C extends B |
|||
{ |
|||
const NAME = 'C'; |
|||
|
|||
public static function test() |
|||
{ |
|||
echo self::NAME, "\n"; |
|||
forward_static_call(array('A', 'test')); |
|||
} |
|||
} |
|||
|
|||
A::test(); |
|||
echo "-\n"; |
|||
B::test(); |
|||
echo "-\n"; |
|||
B::test2(); |
|||
echo "-\n"; |
|||
B::test3(); |
|||
echo "-\n"; |
|||
C::test(); |
|||
echo "-\n"; |
|||
C::test2(); |
|||
echo "-\n"; |
|||
C::test3(); |
|||
|
|||
?> |
|||
===DONE=== |
|||
--EXPECTF-- |
|||
A |
|||
- |
|||
B |
|||
B |
|||
- |
|||
B |
|||
B |
|||
B |
|||
- |
|||
B |
|||
B |
|||
- |
|||
C |
|||
C |
|||
- |
|||
B |
|||
B |
|||
C |
|||
- |
|||
B |
|||
C |
|||
===DONE=== |
|||
@ -0,0 +1,21 @@ |
|||
--TEST-- |
|||
forward_static_call() from outside of a class method. |
|||
--FILE-- |
|||
<?php |
|||
|
|||
class A |
|||
{ |
|||
public static function test() { |
|||
echo "A\n"; |
|||
} |
|||
} |
|||
|
|||
function test() { |
|||
forward_static_call(array('A', 'test')); |
|||
} |
|||
|
|||
test(); |
|||
|
|||
?> |
|||
--EXPECTF-- |
|||
Fatal error: Cannot call forward_static_call() when no class scope is active in %s on line %d |
|||
@ -0,0 +1,51 @@ |
|||
--TEST-- |
|||
forward_static_call() calling outside of the inheritance chain. |
|||
--FILE-- |
|||
<?php |
|||
|
|||
class A |
|||
{ |
|||
const NAME = 'A'; |
|||
public static function test() { |
|||
echo static::NAME, "\n"; |
|||
} |
|||
} |
|||
|
|||
class B extends A |
|||
{ |
|||
const NAME = 'B'; |
|||
|
|||
public static function test() { |
|||
echo self::NAME, "\n"; |
|||
forward_static_call(array('parent', 'test')); |
|||
} |
|||
} |
|||
|
|||
class C |
|||
{ |
|||
const NAME = 'C'; |
|||
|
|||
public static function test() { |
|||
echo self::NAME, "\n"; |
|||
forward_static_call(array('B', 'test')); |
|||
} |
|||
} |
|||
|
|||
A::test(); |
|||
echo "-\n"; |
|||
B::test(); |
|||
echo "-\n"; |
|||
C::test(); |
|||
|
|||
?> |
|||
===DONE=== |
|||
--EXPECTF-- |
|||
A |
|||
- |
|||
B |
|||
B |
|||
- |
|||
C |
|||
B |
|||
B |
|||
===DONE=== |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue