Providing intellisense when resolving via the container #51829
-
Often I find myself writing the following in order to get type information in my editor:
Obviously, ideally I use Laravel's normal convention of dependency inject using PHP argument types to make this easier, like the container resolving during method calls (e.g. a handle() method a job, or a controller action etc.) but sometimes, I just call
What's stopped us changing My guess might be conformance with the Psr contract? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
The Spoilerframework/src/Illuminate/Foundation/helpers.php Lines 108 to 124 in 07e12d3 In PHPStan, you can have conditional return types that infer the correct type based on input types. You can also pass the registered alias as a parameter for the abstract. For example, check the code for the Spoilerframework/src/Illuminate/Foundation/helpers.php Lines 266 to 277 in 07e12d3 I don't think there is a way to type the If you're just looking to enhance intellisense for your IDE, you can check existing community solutions. Regarding the |
Beta Was this translation helpful? Give feedback.
-
There is the 'resolve' helper function ... |
Beta Was this translation helpful? Give feedback.
The
app()
helper provides more than just class name binding.Spoiler
framework/src/Illuminate/Foundation/helpers.php
Lines 108 to 124 in 07e12d3
In PHPStan, you can have c…