blob: 6eb851032504c2de54cbf344e242597f4d1d71bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
--TEST--
SPL: spl_autoload() with methods
--INI--
include_path=.
--FILE--
<?php
class MyAutoLoader {
function autoLoad($className)
{
echo __METHOD__ . "($className)\n";
}
function autoThrow($className)
{
echo __METHOD__ . "($className)\n";
throw new Exception("Unavailable");
}
}
try {
spl_autoload_register(array('MyAutoLoader', 'autoLoad'), true);
} catch(\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
}
// and
$myAutoLoader = new MyAutoLoader();
spl_autoload_register(array($myAutoLoader, 'autoLoad'));
spl_autoload_register(array($myAutoLoader, 'autoThrow'));
try
{
var_dump(class_exists("TestClass", true));
}
catch(Exception $e)
{
echo 'Exception: ' . $e->getMessage() . "\n";
}
?>
--EXPECT--
spl_autoload_register(): Argument #1 ($callback) must be a valid callback, non-static method MyAutoLoader::autoLoad() cannot be called statically
MyAutoLoader::autoLoad(TestClass)
MyAutoLoader::autoThrow(TestClass)
Exception: Unavailable
|