Prevent generation of incorrect property annotation #1665
Merged
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.
Summary
When generating Eloquent annotations on a model that uses a factory, the tool generates an incorrect
$use_factory
property with the following annotation:@property-read \App\Models\TFactory|null $use_factory
Then, when running a static analysis tool (like Larastan), it fails:
PHPDoc tag
@property-read for property App\Models\User::$use_factory contains unknown class App\Models\User\TFactory
.This pull request introduces a workaround for that problem by filtering out the
getUseFactoryAttribute
method from the reflected methods insrc/Console/ModelsCommand::getPropertiesFromMethods()
.With the changes from this PR, running
artisan ide-helper:models -n -W -R
in our project root removes the faulty@property-read
annotations.Credit for this idea goes to LauJosefsen.
See issue 1664 for more details.
Type of change
Checklist
composer fix-style