10up / wp-scaffold

10up WordPress project scaffold.
MIT License
194 stars 46 forks source link

Feature/updated autoloading #236

Open darylldoyle opened 1 month ago

darylldoyle commented 1 month ago

Description of the Change

This PR updates the class autoloader from using https://gitlab.com/hpierce1102/ClassFinder/ to using https://github.com/spatie/php-structure-discoverer and adds unit tests to ensure it's working as expected.

Spatie are a well known company, who specialise in Open Source packages. This means the package is updated more often and bugs will be fixed more quickly. For example, the last commit in hpierce1102/classfinder was June 18, 2023, whereas the last commit in spatie/php-structure-discoverer was today.

There are a few other benefits of the Spatie package:

Old Class Loader Screenshot 2024-08-13 at 23 22 45

New Class Loader Screenshot 2024-08-13 at 23 21 50

Additionally, during the refactor, I eliminated all the hardcoded strings and awkward configurations needed to get the classloader working. It should now be plug-and-play.

One downside of this change is that it only supports PHP 8.1 upwards, though since every version pre-8.1 is End of Life, I think that's a fair tradeoff, https://www.php.net/supported-versions.php.

How to test the Change

Ensure all classes are still loading and test suite is passing.

Changelog Entry

Credits

Props @darylldoyle

Checklist: