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
{{ message }}
This repository has been archived by the owner on Dec 17, 2021. It is now read-only.
getinstance currently uses self::$instances[ get_called_class() ] = new static. However, since the plugin assumes PHP 5.3+ (with use of both get_called_class() and static), this could be set as static:: instead.
(Also, contrary to the comment 'self' in this context refers to the current class in use, it actually refers to the class where the method is defined.)
The text was updated successfully, but these errors were encountered:
I'm fixing the PHP 5.3+ issue today. I'll leave this open as part of that.
For PHP 5.2, singletons with extended classes are actually much harder. You'll need to use debug_backtrace to find which class was actually called, or override the method in each subclass.
If you're going with 5.2 compatibility, I'd actually get rid of the forced singleton (with getinstance) and just store the instance in a global variable. It's much nicer to extend.
For PHP 5.2, singletons with extended classes are actually much harder.
I'm frustrated that I didn't catch this before shipping v1.0.0.
If you're going with 5.2 compatibility, I'd actually get rid of the forced singleton (with getinstance) and just store the instance in a global variable. It's much nicer to extend.
getinstance
currently usesself::$instances[ get_called_class() ] = new static
. However, since the plugin assumes PHP 5.3+ (with use of bothget_called_class()
andstatic
), this could be set asstatic::
instead.(Also, contrary to the comment
'self' in this context refers to the current class in use
, it actually refers to the class where the method is defined.)The text was updated successfully, but these errors were encountered: