Larastan: TelescopeServiceProvider.php: Call to an undefined method Illuminate\Contracts\Foundation\Application::isLocal().

Created on 8 May 2020  路  5Comments  路  Source: nunomaduro/larastan

  • Larastan Version: 0.5.8
  • --level used: 5
  • Laravel framework: 7.10.3
  • Telescope version: 3.3.1

Description

After bumping my composer dependencies, phpstan analyse will throw errors with regards to app/Providers/TelescopeServiceProvider.php lines 24 and 42.

------ -------------------------------------------------------------------------------------
  Line   app/Providers/TelescopeServiceProvider.php
 ------ -------------------------------------------------------------------------------------
  24     Call to an undefined method Illuminate\Contracts\Foundation\Application::isLocal().
  42     Call to an undefined method Illuminate\Contracts\Foundation\Application::isLocal().
 ------ -------------------------------------------------------------------------------------

Laravel code where the issue was found

// inside TelescopeServiceProvider::register()
        Telescope::filter(function (IncomingEntry $entry) {
            if ($this->app->isLocal()) {
                return true;
            }
// ...

Line 48 is a same call to $this->app->isLocal().

Clicking through on isLocal() in PhpStorm finds the appropriate method, so I am not sure what is going on and why phpstan/larastan is complaining?

bug false positive

All 5 comments

I've pinpointed it to version 0.5.6 introducing the above false positive.

Before bumping the deps, I was on 0.5.5 which did not present the issue.

The bug introduced in this commit https://github.com/nunomaduro/larastan/commit/38058ec4722ee435242ad1be8d5f215cda6fe711

Arguments passed to Str::startsWith are in the wrong order :smile: I'll accept a PR where the order of the arguments is changed in all occurrences of Str::startsWith :+1:

All???

I think @canvural means all occurrences in https://github.com/nunomaduro/larastan/commit/38058ec4722ee435242ad1be8d5f215cda6fe711

There are 3 places where the order of the arguments is incorrect in that commit.

Was this page helpful?
0 / 5 - 0 ratings