<?php
namespace Foo;
class Loader {
public function __construct() {
spl_autoload_register([self, 'load']);
}
public function load() {}
}
spl_autoload_register(['Foo\Loader', 'load']);
new Loader();
var_dump(spl_autoload_functions());
Fatal error: Uncaught TypeError: spl_autoload_register(): Argument #1 ($callback) must be a valid callback or null, non-static method Foo\Loader::load() cannot be called statically in /in/A4UlM:9
Stack trace:
#0 /in/A4UlM(9): spl_autoload_register(Array)
#1 {main}
thrown in /in/A4UlM on line 9
Process exited with code 255.
Output for 8.0.0 - 8.0.30
Fatal error: Uncaught TypeError: spl_autoload_register(): Argument #1 ($callback) must be a valid callback, non-static method Foo\Loader::load() cannot be called statically in /in/A4UlM:9
Stack trace:
#0 /in/A4UlM(9): spl_autoload_register(Array)
#1 {main}
thrown in /in/A4UlM on line 9
Process exited with code 255.
Fatal error: Uncaught LogicException: Passed array specifies a non static method but no object (non-static method Foo\Loader::load() should not be called statically) in /in/A4UlM:9
Stack trace:
#0 /in/A4UlM(9): spl_autoload_register(Array)
#1 {main}
thrown in /in/A4UlM on line 9
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Fatal error: Uncaught exception 'LogicException' with message 'Passed array specifies a non static method but no object (non-static method Foo\Loader::load() should not be called statically)' in /in/A4UlM:9
Stack trace:
#0 /in/A4UlM(9): spl_autoload_register(Array)
#1 {main}
thrown in /in/A4UlM on line 9
Process exited with code 255.