Repository navigation
chore(phpstan): correct CustomAttribute parameter types - #1895
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
An active moderate issue remains because WithSecondaryEntities() returns secondary entity IDs as strings despite the documented int[] API.
1 open issue
What changed in this PR
This PR corrects the PHPDoc types for CustomAttribute so they match how the class is really used. That clears about 100 PHPStan level-5 argument.type errors. The main changes are nullable regex and possibleValues, integer entity IDs from FromRow(), a boolean required flag in the API save controller, and test fixtures updated to pass the right types.
Changes:
- Marks
regex,possibleValues, andidas nullable inCustomAttributedocblocks, and documents thatWithSecondaryEntities()acceptsnullto clear the secondary scope. - Converts primary entity IDs from
FromRow()to integers, and castsrequiredto a boolean inAttributeSaveController. - Updates test fixtures to pass valid types, such as
falsefor required, integer sort orders, and arrays of entity IDs.
Open issue: FromRow() still returns secondary entity IDs as strings. Converting them is needed to match the documented int[] type.
| File | Description |
|---|---|
| WebServices/Controllers/AttributeSaveController.php | Casts required to bool instead of int, matching the bool parameter. |
| tests/Presenters/Reservation/ReservationAttributesPresenterTest.php | Passes secondary entity IDs as arrays. |
| tests/Presenters/Admin/ManageAttributesPresenterTest.php | Replaces null sort order and entity IDs with valid values. |
| tests/Domain/Attribute/CustomAttributeTest.php | Replaces null labels and sort orders with valid values. |
| tests/Domain/Attribute/AttributeRepositoryTest.php | Uses integer sort orders and wraps entity IDs in arrays. |
| tests/Application/Schedule/ScheduleResourceFilterTest.php | Wraps entity IDs in arrays to match the new constructor type. |
| tests/Application/Reservation/CustomAttributeValidationRuleTest.php | Passes secondary entity IDs as arrays. |
| tests/Application/Attributes/AttributeServiceTest.php | Replaces null required flags and sort orders, and wraps IDs in arrays. |
| Domain/CustomAttribute.php | Updates docblocks to nullable types and converts FromRow() primary IDs to integers. |
Review effort: Lite
JohnVillalovos
force-pushed
the
jlvillal/phpstan
branch
from
November 10, 2026 05:19
4451b60 to
41de541
Compare
The CustomAttribute PHPDoc did not match how the class is used, which produced about 100 level-5 argument.type errors: - regex and possible_values are nullable columns, Create() passes a null id, and WithSecondaryEntities(null, null) clears the secondary scope. Document those as nullable. - FromRow() and WithSecondaryEntities() kept entity IDs split from database strings as strings. Convert them to int, as documented. The API's appliesToIds and secondaryEntityIds now return integers, matching CustomAttributeDefinitionResponse's int[] types and examples. - AttributeSaveController passed (int) for the bool $required. Fix tests that passed null labels, sort orders and required flags, or a bare int where an array of entity IDs is expected. Assisted-by: Claude:claude-opus-5-5
JohnVillalovos
force-pushed
the
jlvillal/phpstan
branch
from
November 10, 2026 05:30
41de541 to
7fe6e10
Compare
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.


The CustomAttribute PHPDoc did not match how the class is used, which produced about 100 level-5 argument.type errors:
Document the response's regex and secondaryCategoryId as nullable.
Fix tests that passed null labels, sort orders and required flags, or a bare int where an array of entity IDs is expected.
Assisted-by: Claude:claude-opus-5-5