Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application meta broken in laravel 11 #1633

Open
chack1172 opened this issue Dec 20, 2024 · 4 comments
Open

Application meta broken in laravel 11 #1633

chack1172 opened this issue Dec 20, 2024 · 4 comments
Labels

Comments

@chack1172
Copy link
Contributor

chack1172 commented Dec 20, 2024

Versions:

  • ide-helper Version: 3.3.0
  • Laravel Version: 11.0
  • PHP Version: 8.2

Description:

In laravel 11 the docblock return type of app() function has changed using generics. Now when called without arguments his return type is \Illuminate\Foundation\Application.
Before it was \Illuminate\Contracts\Foundation\Application|\Illuminate\Foundation\Application

With this change overrides in .phpstorm.meta.php are not working when calling app()->make(...).
image

Manually adding the Contract type to the return variable makes it work again:
image

@chack1172 chack1172 added the bug label Dec 20, 2024
@chack1172
Copy link
Contributor Author

This change also breaks the return type of the app() helper when parameters are provided.
In vscode intelephense ignores metadata if templates are used: bmewburn/vscode-intelephense#3142

@chack1172
Copy link
Contributor Author

An easy fix for this would be to add the definition of the function with the old docblock when generating .phpstorm.meta.php file:

/**
 * Get the available container instance.
 *
 * @param  string|null  $abstract
 * @param  array  $parameters
 * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Foundation\Application|mixed
 */
function app($abstract = null, array $parameters = []) {}

@barryvdh
Copy link
Owner

I think it's a PHPstorm bug; https://youtrack.jetbrains.com/issue/WI-78351

@chack1172
Copy link
Contributor Author

I'm not sure about PHPstom, but in vscode with intelephense extension meta overrides are not used if method has a phpdoc with templates used. So calling app() with a string parameter will always return mixed because overrides are not used in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants