Prevent Container::make() from type-hinting the parameters #509
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.
I was having a hell of a time getting
jsonitems
to return any legitimate output. I am using Laravel 5.4.The issue happens in
LfmPath::pretty()
when it attempts to resolve a newLfmItem
instance.The problem is that in Laravel 5.4 the
Container::make()
method does not accept the parameters as an argument. You instead have to useContainer::makeWith()
.Container::make()
was changed in Laravel 5.5 to behave exactly the same asContainer::makeWith()
, so changing the method tomakeWith()
ensures backwards compatibility.The second problem is that the
Container::makeWith()
method does not accept a non-associate array for the parameters. You instead have to pass an associative array with keys as the dependency name. See laravel/framework#18474.We end up with this:
The code still actually ran before, because laravel simply type-hinted the
LfmPath
object instead of creating it from the parameters. This however, meant that the data was getting wiped as it was getting passed through this function.