Add tests for dynamic static call to instance method

This commit is contained in:
Aaron Piotrowski 2015-06-29 22:07:29 -05:00 committed by Bob Weinand
parent ffd36e0fc8
commit f7565a93d8
2 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,28 @@
--TEST--
Dynamic static call to instance method should throw.
--CREDITS--
Aaron Piotrowski <aaron@icicle.io>
--FILE--
<?php
class TestClass
{
private $test;
public function method()
{
$this->test = 'test';
return "Hello, world!\n";
}
}
$callback = ['TestClass', 'method'];
echo $callback();
?>
--EXPECTF--
Deprecated: Non-static method TestClass::method() should not be called statically in %s on line %d
Fatal error: Uncaught Error: Using $this when not in object context in %s:%d
Stack trace:
#0 %s(%d): TestClass::method()
#1 {main}
thrown in %s on line %d

View File

@ -0,0 +1,28 @@
--TEST--
Dynamic static call to instance method should throw.
--CREDITS--
Aaron Piotrowski <aaron@icicle.io>
--FILE--
<?php
class TestClass
{
private $test;
public function method()
{
$this->test = 'test';
return "Hello, world!\n";
}
}
$callback = 'TestClass::method';
echo $callback();
?>
--EXPECTF--
Deprecated: Non-static method TestClass::method() should not be called statically in %s on line %d
Fatal error: Uncaught Error: Using $this when not in object context in %s:%d
Stack trace:
#0 %s(%d): TestClass::method()
#1 {main}
thrown in %s on line %d