]> granicus.if.org Git - php/commitdiff
Add tests for dynamic static call to instance method
authorAaron Piotrowski <aaron@trowski.com>
Tue, 30 Jun 2015 03:07:29 +0000 (22:07 -0500)
committerBob Weinand <bobwei9@hotmail.com>
Tue, 30 Jun 2015 05:07:17 +0000 (07:07 +0200)
Zend/tests/indirect_call_array_005.phpt [new file with mode: 0644]
Zend/tests/indirect_call_string_003.phpt [new file with mode: 0644]

diff --git a/Zend/tests/indirect_call_array_005.phpt b/Zend/tests/indirect_call_array_005.phpt
new file mode 100644 (file)
index 0000000..4938856
--- /dev/null
@@ -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
diff --git a/Zend/tests/indirect_call_string_003.phpt b/Zend/tests/indirect_call_string_003.phpt
new file mode 100644 (file)
index 0000000..a6839df
--- /dev/null
@@ -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