GrahamCampbell / Laravel-GitHub

A GitHub API bridge for Laravel
https://gjcampbell.co.uk
MIT License
622 stars 120 forks source link

Method 'repo' not found in \GrahamCampbell\GitHub\Facades\GitHub #150

Closed apasov closed 11 months ago

apasov commented 1 year ago

I use this code and it works:

use GrahamCampbell\GitHub\Facades\GitHub;

GitHub::repo()->show('GrahamCampbell', 'Laravel-GitHub');

But PHPStorm inspections give me warning: Method 'repo' not found in \GrahamCampbell\GitHub\Facades\GitHub

And phpstan throws error: Call to an undefined static method GrahamCampbell\GitHub\Facades\GitHub::repo().

What should I do to avoid these errors?

DevinWalker commented 1 year ago

Same issue here, I've also tried to use https://github.com/barryvdh/laravel-ide-helper to make it work in PHPStorm.

No luck so far. I found this PR: https://github.com/GrahamCampbell/Laravel-GitHub/pull/106 which is referenced by this issue: https://github.com/GrahamCampbell/Laravel-GitHub/issues/144

Basically, I hard implemented the changes in the PR and that resolved the issue of the undefined static method error. However, the code autocompletion is not working and now I see the following error: nonstatic method shouldn't be call statically.

2023-03-29_22-55-39

GrahamCampbell commented 11 months ago

This is just a limitation of the IDE, and I feel is out of scope to fix here. Thanks anyway.

apasov commented 11 months ago

No, it's not just an IDE specific thing. First of all, it's a phpstan error.

As I already mentioned, phpstan says Call to an undefined static method GrahamCampbell\GitHub\Facades\GitHub::repo().

Currently I suppress it in phpstan.neon:

parameters:
    ignoreErrors:
        - '#Call to an undefined static method GrahamCampbell\\GitHub\\Facades\\GitHub::[a-zA-Z0-9\\_]()#'

So I believe here is the exact place where it should be fixed.