[11.x] Deprecate Factory::$modelNameResolver
#54736
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.
Renaming the
$modelNameResolver
property entirely in #54644 was a backwards compatibility break for any user-land and 3rd-party code that happened to touch the original property (see #54665, #54698). While it was a protected, static property inside a framework class, it's a relatively high-touch interface as most developers will extend theFactory
class, and it's reasonable to assume that there is going to be code out there which touches the model resolver directly.This PR re-introduces the original property as a fallback without affecting the new methods, but marks it the property as deprecated so that developers and third parties have a chance to migrate correctly without having to avoid other Laravel updates >=v11.42.0.
The doesn't need to be migrated to 12.x - it's a deprecation, and any external libraries that touch the property can handle the change in their migration to supporting 12.x. For the vast majority of users the property change would appear to be a be a low-no impact change, but for anyone that's using any code or libraries that happen to touch the
$modelNameResolver
property on factories, this was a BC break that blows up primarily testing environments.