Repository navigation
Clear the non-BC Mago findings in Container, Adapter and ResultSet - #253
Open
simon-mundy wants to merge 2 commits into
Open
simon-mundy wants to merge 2 commits into
simon-mundy wants to merge 2 commits into
Conversation
Give the config arrays and factory options precise docblock types, document the container exceptions each factory can raise, drop the redundant @var casts on built services, replace isset/empty in canCreate() with an equivalent is_array check, and mark the unused delegator $options parameter as expected. AdapterInterfaceFactory now throws ContainerException::forMissingDriver() when the adapter configuration has no driver, matching the abstract factory, instead of passing null to ServiceManager::build() and failing with a TypeError. Remove the baseline entries these changes clear.
Mark the rows read for field counting as mixed, drop the @var object casts the analyzer already infers in toArray(), and have RowPrototypeResultSet::toArray() iterate through current(), whose nullable return type makes the null-row passthrough explicit rather than a redundant instanceof check. Document the exceptions that iteration can raise. Remove the baseline entries these changes clear.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🟢 Approval recommended
No active review findings block the adapter configuration and result-set updates.
No open issues 🎉
What changed in this PR
This PR reduces Mago findings in adapter container wiring and result sets without changing public or protected signatures. It improves type annotations and exception documentation, while introducing a specific exception for missing driver configuration.
Changes:
- Refines configuration types and exception declarations, and removes redundant docblocks.
- Simplifies adapter configuration checks and preserves null rows during result-set conversion.
- Adds regression tests and removes resolved analyzer and lint baseline entries.
| File | Description |
|---|---|
test/unit/ResultSet/RowPrototypeResultSetTest.php |
Tests null-row preservation in toArray(). |
test/unit/Container/AdapterInterfaceFactoryTest.php |
Tests configuration-key precedence and missing drivers. |
test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php |
Tests accepted and rejected named-adapter configurations. |
src/ResultSet/RowPrototypeResultSet.php |
Uses nullable current() for row conversion and documents exceptions. |
src/ResultSet/ObjectResultSet.php |
Removes a redundant row annotation. |
src/ResultSet/HydratingResultSet.php |
Removes a redundant row annotation. |
src/ResultSet/AbstractResultSet.php |
Explicitly annotates mixed source values. |
src/Container/AdapterInterfaceFactory.php |
Refines annotations and throws a specific missing-driver exception. |
src/Container/AdapterInterfaceDelegator.php |
Documents option and state types and annotates mixed values. |
src/Container/AbstractAdapterInterfaceFactory.php |
Simplifies configuration access and improves type and exception documentation. |
src/ConfigProvider.php |
Documents dependency-array shapes. |
lint-baseline.toml |
Removes resolved isset() and empty() findings. |
analyzer-baseline.toml |
Removes resolved analysis findings. |
Review effort: Balanced
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.
Problem
About 55 Mago findings in
src/Container,src/ConfigProvider.php,src/Adapterandsrc/ResultSetsit in the baselines. They cover:@throws;isset()/empty()use.Fix
__set_state()'s state and theConfigProviderarrays.@throwsfor the container exceptions each factory andcanCreate()can raise.@vardocblocks are removed from built services and result-set rows. One of them was wrong (ResultSetInterface|null).canCreate()uses an equivalentis_array()/[] !==check instead ofisset()/empty().RowPrototypeResultSet::toArray()iterates through its nullablecurrent(). The analyzer flagged the oldinstanceofcheck as redundant, but null rows really do occur, so the null-row passthrough is now typed instead.AdapterInterfaceFactoryreports a missingdriverwithContainerException::forMissingDriver(), as the abstract factory already does, instead of aTypeErrorfromServiceManager::build().What stays the same
@apiclasses and interfaces;AbstractPdo::getResultPrototype()'s nullability.Verification
mago format --check,lint,analyzeandguardexit 0 on PHP 8.3, 8.4 and 8.5.srcline is covered.canCreate()rejects;toArray().