[10.x] Fix Factory::configure()
return type
#47920
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.
TL;DR: Small doc block fix
The
Factory::configure()
method currently indicates that it returns$this
(the exact instance the method was called on), but this is not always true. For example, when calling theafterCreating()
method a new factory instance is created, e.g.:For most IDEs this isn't an issue because they will handle
$this
andstatic
the same way, but tools like PHPStan do differentiate between them. When using PHPStan strict rules, you would get an error here because the@return static
in the example doesn't comply with the@return $this
on the base factory, and if you changed it to@return $this
it will also fail because you are in fact returning a new instance (the return type forafterCreating()
is documented asstatic
).This PR solves this by fixing the return type on the configure method, this is not a breaking change as its only a docblock type and
static
encompasses$this
so anyone using@return $this
is still fine.