Hi internals,

I am using the register_shutdown_function() inside a class, and then I have
created a private method to be called during shutdown. I have noted that if
the method is public it works, but private does not.

register_shutdown_function([ self::class, 'privateMethod' ]); // FAIL

Warning: (Registered shutdown functions) Unable to call
MyClass::privateMethod() - function does not exist in Unknown on line 0


In contrast, spl_autoload_register() will works independent if it is
private or public.

spl_autoload_register([ self::class, 'privateMethod' ]); // OK


Example code:

https://3v4l.org/lClJQ

This case is applicable independent if method is static or not.

My real case is that I am initializing a static method that will register
some shutdowns events (that are static methods too). This shutdown function
should be private, to avoid execution at a public scope. As workaround I am
keeping it as public.

So, there are some reason to it do not works like spl does?

-- 
David Rodrigues

Reply via email to