summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rwxr-xr-xext/spl/tests/spl_autoload_007.phpt138
-rw-r--r--ext/standard/tests/general_functions/bug32647.phpt20
2 files changed, 149 insertions, 9 deletions
diff --git a/ext/spl/tests/spl_autoload_007.phpt b/ext/spl/tests/spl_autoload_007.phpt
new file mode 100755
index 0000000000..40b4b61cbd
--- /dev/null
+++ b/ext/spl/tests/spl_autoload_007.phpt
@@ -0,0 +1,138 @@
+--TEST--
+SPL: spl_autoload() with inaccessible methods
+--INI--
+include_path=.
+--FILE--
+<?php
+
+class MyAutoLoader {
+
+ static protected function noAccess($className) {
+ echo __METHOD__ . "($className)\n";
+ }
+
+ static function autoLoad($className) {
+ echo __METHOD__ . "($className)\n";
+ }
+
+ function dynaLoad($className) {
+ echo __METHOD__ . "($className)\n";
+ }
+}
+
+$obj = new MyAutoLoader;
+
+$funcs = array(
+ 'MyAutoLoader::notExist',
+ 'MyAutoLoader::noAccess',
+ 'MyAutoLoader::autoLoad',
+ 'MyAutoLoader::dynaLoad',
+ array('MyAutoLoader', 'notExist'),
+ array('MyAutoLoader', 'noAccess'),
+ array('MyAutoLoader', 'autoLoad'),
+ array('MyAutoLoader', 'dynaLoad'),
+ array($obj, 'notExist'),
+ array($obj, 'noAccess'),
+ array($obj, 'autoLoad'),
+ array($obj, 'dynaLoad'),
+);
+
+foreach($funcs as $idx => $func)
+{
+ if ($idx) echo "\n";
+ try
+ {
+ var_dump($func);
+ spl_autoload_register($func);
+ echo "ok\n";
+ }
+ catch (Exception $e)
+ {
+ echo $e->getMessage() . "\n";
+ }
+}
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+string(22) "MyAutoLoader::notExist"
+Function 'MyAutoLoader::notExist' not found
+
+string(22) "MyAutoLoader::noAccess"
+Function 'MyAutoLoader::noAccess' not callable
+
+string(22) "MyAutoLoader::autoLoad"
+ok
+
+string(22) "MyAutoLoader::dynaLoad"
+Function 'MyAutoLoader::dynaLoad' not callable
+
+array(2) {
+ [0]=>
+ string(12) "MyAutoLoader"
+ [1]=>
+ string(8) "notExist"
+}
+Passed array does not specify an existing static method
+
+array(2) {
+ [0]=>
+ string(12) "MyAutoLoader"
+ [1]=>
+ string(8) "noAccess"
+}
+Passed array does not specify a callable static method
+
+array(2) {
+ [0]=>
+ string(12) "MyAutoLoader"
+ [1]=>
+ string(8) "autoLoad"
+}
+ok
+
+array(2) {
+ [0]=>
+ string(12) "MyAutoLoader"
+ [1]=>
+ string(8) "dynaLoad"
+}
+Passed array specifies a non static method but no object
+
+array(2) {
+ [0]=>
+ object(MyAutoLoader)#%d (0) {
+ }
+ [1]=>
+ string(8) "notExist"
+}
+Passed array does not specify an existing method
+
+array(2) {
+ [0]=>
+ object(MyAutoLoader)#%d (0) {
+ }
+ [1]=>
+ string(8) "noAccess"
+}
+Passed array does not specify a callable method
+
+array(2) {
+ [0]=>
+ object(MyAutoLoader)#%d (0) {
+ }
+ [1]=>
+ string(8) "autoLoad"
+}
+ok
+
+array(2) {
+ [0]=>
+ object(MyAutoLoader)#%d (0) {
+ }
+ [1]=>
+ string(8) "dynaLoad"
+}
+ok
+===DONE===
diff --git a/ext/standard/tests/general_functions/bug32647.phpt b/ext/standard/tests/general_functions/bug32647.phpt
index ca98f429a7..2e82012077 100644
--- a/ext/standard/tests/general_functions/bug32647.phpt
+++ b/ext/standard/tests/general_functions/bug32647.phpt
@@ -1,14 +1,14 @@
--TEST--
Bug #32647 (Using register_shutdown_function() with invalid callback can crash PHP)
--INI--
-error_reporting=2047
+error_reporting=4095
display_errors=1
--FILE--
<?php
function foo()
{
- echo "joo!\n";
+ echo "foo!\n";
}
class bar
@@ -23,9 +23,9 @@ register_shutdown_function(array($obj,"some string")); // Invalid
register_shutdown_function(array(0,"")); // Invalid
register_shutdown_function(array('bar','foo')); // Invalid
register_shutdown_function(array(0,"some string")); // Invalid
-register_shutdown_function('bar'); // Valid
+register_shutdown_function('bar'); // Invalid
register_shutdown_function('foo'); // Valid
-register_shutdown_function(array('bar','barfoo')); // Valid
+register_shutdown_function(array('bar','barfoo')); // Invalid
$obj = new bar;
register_shutdown_function(array($obj,'foobar')); // Invalid
@@ -45,11 +45,13 @@ Warning: register_shutdown_function(): Invalid shutdown callback 'Array' passed
Warning: register_shutdown_function(): Invalid shutdown callback 'Array' passed in %s on line %d
-Warning: (Registered shutdown functions) Unable to call bar::foo() - function does not exist in Unknown on line 0
+Strict Standards: Non-static method bar::barfoo() cannot be called statically in %sbug32647.php on line %d
-Warning: (Registered shutdown functions) Unable to call bar() - function does not exist in Unknown on line 0
-joo!
-bar!
+Warning: register_shutdown_function(): Invalid shutdown callback 'bar::foobar' passed in %sbug32647.php on line %d
+foo!
+
+Strict Standards: Non-static method bar::barfoo() cannot be called statically in Unknown on line 0
-Warning: (Registered shutdown functions) Unable to call bar::foobar() - function does not exist in Unknown on line 0
+Strict Standards: Non-static method bar::barfoo() cannot be called statically in Unknown on line 0
+bar!
bar!