Skip to content

Conversation

@darylldoyle
Copy link
Collaborator

@darylldoyle darylldoyle commented May 6, 2025

Description of the Change

This PR fixes an issue where classes are loaded, even if their parent classes are non-existent. For example, a missing plugin or something that extends \WP_CLI.

How to test the Change

Unit tests are included.

Changelog Entry

Fixed - Issue where the autoloader loads classes with non-existent parents.

Credits

Props @darylldoyle

Checklist:

Move class reflection logic to a new `get_fully_loadable_class` method to improve clarity and reusability. Added error handling to safely handle non-loadable classes, ensuring smoother execution and fewer runtime errors.
Introduce `BaseClass`, `ChildClass`, and `InvalidChildClass` to the fixtures. Added a test method to validate if these classes are fully loadable, ensuring the module handles valid and invalid class definitions appropriately.
Excluded `InvalidChildClass.php` from analysis to avoid unnecessary errors in test fixtures. This ensures PHPStan runs more cleanly and focuses on relevant code paths.
@darylldoyle darylldoyle self-assigned this May 6, 2025
@darylldoyle darylldoyle merged commit 4512e0b into develop May 6, 2025
3 checks passed
@darylldoyle darylldoyle deleted the feature/fix-loading-of-broken-classes branch May 6, 2025 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants