Skip to content

Commit f7565a9

Browse files
trowskibwoebi
authored andcommitted
Add tests for dynamic static call to instance method
1 parent ffd36e0 commit f7565a9

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Dynamic static call to instance method should throw.
3+
--CREDITS--
4+
Aaron Piotrowski <aaron@icicle.io>
5+
--FILE--
6+
<?php
7+
class TestClass
8+
{
9+
private $test;
10+
11+
public function method()
12+
{
13+
$this->test = 'test';
14+
return "Hello, world!\n";
15+
}
16+
}
17+
18+
$callback = ['TestClass', 'method'];
19+
echo $callback();
20+
?>
21+
--EXPECTF--
22+
Deprecated: Non-static method TestClass::method() should not be called statically in %s on line %d
23+
24+
Fatal error: Uncaught Error: Using $this when not in object context in %s:%d
25+
Stack trace:
26+
#0 %s(%d): TestClass::method()
27+
#1 {main}
28+
thrown in %s on line %d
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
Dynamic static call to instance method should throw.
3+
--CREDITS--
4+
Aaron Piotrowski <aaron@icicle.io>
5+
--FILE--
6+
<?php
7+
class TestClass
8+
{
9+
private $test;
10+
11+
public function method()
12+
{
13+
$this->test = 'test';
14+
return "Hello, world!\n";
15+
}
16+
}
17+
18+
$callback = 'TestClass::method';
19+
echo $callback();
20+
?>
21+
--EXPECTF--
22+
Deprecated: Non-static method TestClass::method() should not be called statically in %s on line %d
23+
24+
Fatal error: Uncaught Error: Using $this when not in object context in %s:%d
25+
Stack trace:
26+
#0 %s(%d): TestClass::method()
27+
#1 {main}
28+
thrown in %s on line %d

0 commit comments

Comments
 (0)