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

ServiceProvider autocomplete on $this->app no longer working in a package. #26060

Closed
Voziv opened this issue Oct 10, 2018 · 6 comments
Closed

Comments

@Voziv
Copy link

Voziv commented Oct 10, 2018

  • Laravel Version: 5.7.9
  • PHP Version: 7.2.10-0ubuntu0.18.04.1
  • Database Driver & Version: N/A

Description:

In the PR #25830 the phpdoc was changed from the contract to the concrete implemention.

In my laravel package I'm requiring "illuminate/support": "^5.7" in my composer.json. With this update I no longer have any code completion on $this->app in my service providers.

Should I be depending on a different package? Is my laravel package supposed to depend on the whole framework instead?

For now I've worked around by overriding protected $app to add the old phpdoc back in.

From what I understand the reason this change was made is because the concrete implementation has methods that are not in the interface. Should the interface not be updated with the methods that are missing?

Here's my service provider for reference: https://github.com/ratehub/laravel-newrelic/blob/dev/src/RateHub/NewRelic/Providers/NewRelicServiceProvider.php#L27

Steps To Reproduce:

  1. Install "illuminate/support": "5.7.9"
  2. In PHPStorm create a class that extends from Illuminate/Support/ServiceProvider
    3.. Attempt to autocomplete $this->app
@staudenmeir
Copy link
Contributor

Can we solve this by specifying both the class and the interface?

@var \Illuminate\Contracts\Foundation\Application|\Illuminate\Foundation\Application

@Voziv
Copy link
Author

Voziv commented Oct 10, 2018

Hmm, yeah that would solve it as well.

@staudenmeir
Copy link
Contributor

That would be a temporary fix until the missing methods get added to the interface.

/cc @TBlindaruk

TBlindaruk added a commit to TBlindaruk/laravel-framework that referenced this issue Oct 10, 2018
Fixed autocomplete for cases when someone developed a packages

Fixed ticket: laravel#26060
@TBlindaruk
Copy link
Contributor

TBlindaruk commented Oct 10, 2018

@Voziv ,I have created a PR for this

taylorotwell pushed a commit that referenced this issue Oct 10, 2018
Fixed autocomplete for cases when someone developed a packages

Fixed ticket: #26060
taylorotwell pushed a commit to illuminate/support that referenced this issue Oct 10, 2018
Fixed autocomplete for cases when someone developed a packages

Fixed ticket: laravel/framework#26060
@TBlindaruk
Copy link
Contributor

TBlindaruk commented Oct 10, 2018

@Voziv , Changes are merged to 5.7. The issue will be fixed with a next release;

@Voziv
Copy link
Author

Voziv commented Oct 11, 2018

Thanks!

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

No branches or pull requests

3 participants