View type hinting
#45763
Replies: 1 comment 4 replies
-
Use docblocks |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Our app has an action class that creates a pdf with Browsershot. Instead of testing the final PDF, we want to verify that the view we pass to Browsershot contains the data we expect. A simplified version of our class will look like this:
As we return an object, we can't test it with
$this->view('some-pdf-view')
. As the helper expects a Blade-file as a sring, and not an object. Not a big deal as we can useTestView
directly instead.Our test passes, but PHPStorm warns that we're passing the wrong type to
TestView
.TestView
expects aView
and we're passing a contract. You would think this is an easy fix. Change the return type ofgetView
in the action class to aView
and you're done. Sadly, PHPStorm then warns you about returning the wrong type ingetView
, as theview()
helper returns something different.Is there a reason why there are differences here?
Beta Was this translation helpful? Give feedback.
All reactions