Closed johnwatkins0 closed 1 year ago
This all looks good to me @claytoncollie @johnwatkins0 . My only question is what is the minimum version of PHP this will support?
@tlovett1 Traits were introduced in PHP 5.4, so this might be problematic since this plugin's README says it supports 5.3. I'll revisit and see what can be done while still working with 5.3.
@johnwatkins0 5.4 is fine. I'll update the readme. Thank you!
Description of the Change
Because of this change, the
static $instance
in the Singleton abstract class'sinstance
method was going to be shared between all classes that inherit from Singleton. As a result, the instance would be set to the first class whoseinstance
method is called, and none of the other classes would be created.This converts the class to a trait, which essentially gives each Singleton class its own instances of the
instance
static property and method.Also included: If you review the
instance
method previously in the abstract class and now in the trait, it runs its class'ssetup
method if that method exists. That method was also being run in the plugin entry file as classes were instantiated, so it was being run twice.Closes #117
How to test the Change
Check out this branch. Confirm all functionality works as expected.
Changelog Entry
Changed - Converted the Singleton abstract class into a trait for PHP 8.1. compatability.
Credits
Props @username, @username2, ...
Checklist: