Fix documentation generation when using binded interfaces instead of model classes as typed arguments #494
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.
Hi,
The version
3.33.1
introduces a breaking change when you are using a type hinted argument that is an interface binded to a model via the service container.Since an interface is not instantiable, you get this error when generating the documention:
To resolve this issue, we need to use the service container to resolve the instance instead of just
new
.However, there is a caveat, because when you resolve a form request class using the service container, it also execute the
authorize
method of theValidatesWhenResolvedTrait
trait.That was the first error I found but alongs the way of fixing it, I found that type hinted arguments with builtin types (e.g.
string
) also returns a similar error:This PR fixes these problems by using the
app()
helper to resolve any interfaces that can be used as controller method arguments,new
for classes (to avoid any side effects ofValidatesWhenResolvedTrait
).Althrough this PR also fixes the error for builtin types, it was not its first goal. For now, theses arguments are treated as "not type hinted".
Of course, any improvements are welcome :)
Have a nice day.