You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This makes it always throw a TypeError, moreover this makes the
error message consistent.
Added a warning mentioning that the second parameter is now ignored
when passed false.
ClosesphpGH-5301
Exception: Function 'unavailable_autoload_function' not found (function 'unavailable_autoload_function' not found or invalid function name)
103
+
spl_autoload_register(): Argument #1 ($autoload_function) must be a valid callback, function 'unavailable_autoload_function' not found or invalid function name
Exception: Passed array specifies a non static method but no object (non-static method MyAutoLoader::autoLoad() cannot be called statically)
46
+
spl_autoload_register(): Argument #1 ($autoload_function) must be a valid callback, non-static method MyAutoLoader::autoLoad() cannot be called statically
Copy file name to clipboardExpand all lines: ext/spl/tests/spl_autoload_007.phpt
+11-14
Original file line number
Diff line number
Diff line change
@@ -40,47 +40,44 @@ $funcs = array(
40
40
foreach($funcsas$idx => $func)
41
41
{
42
42
if ($idx) echo"\n";
43
-
try
44
-
{
43
+
try {
45
44
var_dump($func);
46
45
spl_autoload_register($func);
47
46
echo"ok\n";
48
-
}
49
-
catch (Exception$e)
50
-
{
51
-
echo$e->getMessage() . "\n";
47
+
} catch(\TypeError$e) {
48
+
echo$e->getMessage() . \PHP_EOL;
52
49
}
53
50
}
54
51
55
52
?>
56
53
--EXPECTF--
57
54
string(22) "MyAutoLoader::notExist"
58
-
Function 'MyAutoLoader::notExist' not found (class 'MyAutoLoader' does not have a method 'notExist')
55
+
spl_autoload_register(): Argument #1 ($autoload_function) must be a valid callback, class 'MyAutoLoader' does not have a method 'notExist'
59
56
60
57
string(22) "MyAutoLoader::noAccess"
61
-
Function 'MyAutoLoader::noAccess' not callable (cannot access protected method MyAutoLoader::noAccess())
58
+
spl_autoload_register(): Argument #1 ($autoload_function) must be a valid callback, cannot access protected method MyAutoLoader::noAccess()
62
59
63
60
string(22) "MyAutoLoader::autoLoad"
64
61
ok
65
62
66
63
string(22) "MyAutoLoader::dynaLoad"
67
-
Function 'MyAutoLoader::dynaLoad' not callable (non-static method MyAutoLoader::dynaLoad() cannot be called statically)
64
+
spl_autoload_register(): Argument #1 ($autoload_function) must be a valid callback, non-static method MyAutoLoader::dynaLoad() cannot be called statically
68
65
69
66
array(2) {
70
67
[0]=>
71
68
string(12) "MyAutoLoader"
72
69
[1]=>
73
70
string(8) "notExist"
74
71
}
75
-
Passed array does not specify an existing static method (class 'MyAutoLoader' does not have a method 'notExist')
72
+
spl_autoload_register(): Argument #1 ($autoload_function) must be a valid callback, class 'MyAutoLoader' does not have a method 'notExist'
76
73
77
74
array(2) {
78
75
[0]=>
79
76
string(12) "MyAutoLoader"
80
77
[1]=>
81
78
string(8) "noAccess"
82
79
}
83
-
Passed array does not specify a callable static method (cannot access protected method MyAutoLoader::noAccess())
80
+
spl_autoload_register(): Argument #1 ($autoload_function) must be a valid callback, cannot access protected method MyAutoLoader::noAccess()
84
81
85
82
array(2) {
86
83
[0]=>
@@ -96,7 +93,7 @@ array(2) {
96
93
[1]=>
97
94
string(8) "dynaLoad"
98
95
}
99
-
Passed array specifies a non static method but no object (non-static method MyAutoLoader::dynaLoad() cannot be called statically)
96
+
spl_autoload_register(): Argument #1 ($autoload_function) must be a valid callback, non-static method MyAutoLoader::dynaLoad() cannot be called statically
100
97
101
98
array(2) {
102
99
[0]=>
@@ -105,7 +102,7 @@ array(2) {
105
102
[1]=>
106
103
string(8) "notExist"
107
104
}
108
-
Passed array does not specify an existing method (class 'MyAutoLoader' does not have a method 'notExist')
105
+
spl_autoload_register(): Argument #1 ($autoload_function) must be a valid callback, class 'MyAutoLoader' does not have a method 'notExist'
109
106
110
107
array(2) {
111
108
[0]=>
@@ -114,7 +111,7 @@ array(2) {
114
111
[1]=>
115
112
string(8) "noAccess"
116
113
}
117
-
Passed array does not specify a callable static method (cannot access protected method MyAutoLoader::noAccess())
114
+
spl_autoload_register(): Argument #1 ($autoload_function) must be a valid callback, cannot access protected method MyAutoLoader::noAccess()
LogicException: Function 'MyAutoLoader::dynaLoad' not callable (non-static method MyAutoLoader::dynaLoad() cannot be called statically)
79
+
TypeError: spl_autoload_register(): Argument #1 ($autoload_function) must be a valid callback, non-static method MyAutoLoader::dynaLoad() cannot be called statically
82
80
int(0)
83
81
====3====
84
82
array(2) {
@@ -98,7 +96,7 @@ array(2) {
98
96
[1]=>
99
97
string(8) "dynaLoad"
100
98
}
101
-
LogicException: Passed array specifies a non static method but no object (non-static method MyAutoLoader::dynaLoad() cannot be called statically)
99
+
TypeError: spl_autoload_register(): Argument #1 ($autoload_function) must be a valid callback, non-static method MyAutoLoader::dynaLoad() cannot be called statically
0 commit comments