-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor resolving of null information for custom casted attribute types #1330
Refactor resolving of null information for custom casted attribute types #1330
Conversation
* @property array|null $casted_property_with_return_primitive_docblock | ||
* @property array|null $casted_property_with_return_nullable_primitive | ||
* @property array $casted_property_with_return_primitive_docblock | ||
* @property array $casted_property_with_return_nullable_primitive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this changed? Is it intentional based on the fix? Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is intentional. I didn't change the migration for these properties and they weren't marked as nullable()
, so the |null
gets removed by the fix in this PR.
@mfn Can you please take another look at this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applyNullability
make my head hurt but me feel is this is a "LGTM"!
@wimski can you please update the changelog too? |
Added to changelog in aa1aa66 |
…pes (barryvdh#1330) * Refactor resolving of null information for custom casted attribute types * composer fix-style --------- Co-authored-by: laravel-ide-helper <[email protected]>
Summary
Let's say we have the following custom cast:
Now suppose we have two pretty much identical models which use this cast:
These models have tables created with the following migrations:
The only difference between A and B is the
nullable()
setting on the column. Based on that difference I would expect the following properties to be written by the IDE helper:However, both models will receive
SomeObject|null
as the property type, because currently the IDE helper only check the cast class without taking the migration into account. In my opinion the migration should inform the possibility of anull
value and not the cast, because the cast doesn't know anything about the column it's going to be used for and should always implementX|null
.Type of change
In my opnion this is a fix for behaviour that was always incorrect, but because it changes behaviour (and outcome), I do consider it a breaking change. I'll let it up to the maintainers how they want to deal with this.
Checklist
composer fix-style