Skip to content

Commit bc0df38

Browse files
committed
Added more indirect call tests, remove invalid test
1 parent ba67fc2 commit bc0df38

File tree

3 files changed

+101
-21
lines changed

3 files changed

+101
-21
lines changed

Zend/tests/call_static_005.phpt

-21
This file was deleted.
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
--TEST--
2+
Indirect call with 'Class::method' syntax with class in namespace
3+
--FILE--
4+
<?php
5+
namespace TestNamespace
6+
{
7+
class TestClass
8+
{
9+
public static function staticMethod()
10+
{
11+
echo "Static method called!\n";
12+
}
13+
14+
public static function staticMethodWithArgs($arg1, $arg2, $arg3)
15+
{
16+
printf("Static method called with args: %s, %s, %s\n", $arg1, $arg2, $arg3);
17+
}
18+
}
19+
20+
// Test basic call using Class::method syntax.
21+
$callback = 'TestNamespace\TestClass::staticMethod';
22+
$callback();
23+
24+
// Case should not matter.
25+
$callback = 'testnamespace\testclass::staticmethod';
26+
$callback();
27+
28+
$args = ['arg1', 'arg2', 'arg3'];
29+
$callback = 'TestNamespace\TestClass::staticMethodWithArgs';
30+
31+
// Test call with args.
32+
$callback($args[0], $args[1], $args[2]);
33+
34+
// Test call with splat operator.
35+
$callback(...$args);
36+
}
37+
?>
38+
--EXPECT--
39+
Static method called!
40+
Static method called!
41+
Static method called with args: arg1, arg2, arg3
42+
Static method called with args: arg1, arg2, arg3
+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
--TEST--
2+
Indirect call with empty class and/or method name.
3+
--FILE--
4+
<?php
5+
class TestClass
6+
{
7+
public static function __callStatic($method, array $args)
8+
{
9+
var_dump($method);
10+
}
11+
}
12+
13+
// Test call using array syntax
14+
$callback = ['TestClass', ''];
15+
$callback();
16+
17+
// Test call using Class::method syntax.
18+
$callback = 'TestClass::';
19+
$callback();
20+
21+
// Test array syntax with empty class name
22+
$callback = '::method';
23+
try {
24+
$callback();
25+
} catch (Error $e) {
26+
echo $e->getMessage() . "\n";
27+
}
28+
29+
// Test Class::method syntax with empty class name
30+
$callback = '::method';
31+
try {
32+
$callback();
33+
} catch (Error $e) {
34+
echo $e->getMessage() . "\n";
35+
}
36+
37+
// Test array syntax with empty class and method name
38+
$callback = ['', ''];
39+
try {
40+
$callback();
41+
} catch (Error $e) {
42+
echo $e->getMessage() . "\n";
43+
}
44+
45+
// Test Class::method syntax with empty class and method name
46+
$callback = '::';
47+
try {
48+
$callback();
49+
} catch (Error $e) {
50+
echo $e->getMessage() . "\n";
51+
}
52+
?>
53+
--EXPECT--
54+
string(0) ""
55+
string(0) ""
56+
Class '' not found
57+
Class '' not found
58+
Class '' not found
59+
Class '' not found

0 commit comments

Comments
 (0)