Refactor and improve Loader documentation and properties - #723
Open
fadrian06 wants to merge 18 commits into
Open
Refactor and improve Loader documentation and properties#723fadrian06 wants to merge 18 commits into
fadrian06 wants to merge 18 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors flight/core/Loader.php to improve type annotations and readability around class registration/instantiation and autoload directory handling, aiming for better static analysis and clearer intent in the core dependency loader.
Changes:
- Refined PHPDoc types for registered factories/callbacks and clarified method documentation.
- Refactored
load()/newInstance()for clearer shared vs. new instance logic and simpler callable invocation. - Hardened
addDirectory()input handling (iterables vs. non-strings) and duplicate prevention.
Suppressed comments (1)
flight/core/Loader.php:197
- The PHPDoc for addDirectory() says $dir is string|string[], but the method accepts any iterable (arrays or Traversable) via is_iterable(). Align the annotation with the actual accepted input type.
* @param string|string[] $dir Directory path.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: fadrian06 <109766973+fadrian06@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors and improves the
Loaderclass inflight/core/Loader.phpfor better type safety, clarity, and maintainability. The main changes include updating type annotations, improving method signatures, and enhancing the documentation for better understanding and IDE support.Type and Documentation Improvements:
Loaderclass for more precise types, especially for callable factories, constructor arguments, and callbacks. [1] [2]Exceptionusage withThrowableto allow for broader error handling.register,unregister,load, andnewInstanceto clarify parameter and return types. [1] [2]Code Quality and Logic Enhancements:
loadmethod for better readability and to use more descriptive variable names, as well as clarifying the logic for shared vs. new instances and after-instantiation callbacks.newInstancemethod to use variadic arguments and direct callable invocation with spread operator.addDirectoryto handle non-string and iterable inputs more robustly, and prevent duplicate directory entries.Minor Cleanups: