Larastan: phpstan.neon paths not working

Created on 11 Nov 2018  路  7Comments  路  Source: nunomaduro/larastan

  • Larastan Version: 0.3.8
  • --level used: max

Description:

Modifying paths in phpstan.neon changes nothing, it always use my app directory and only.

Laravel code where the issue was found:

Bellow my phpstan.neon

includes:
    - ./vendor/nunomaduro/larastan/extension.neon
parameters:
    excludes_analyse:
        - /*/Definitions/*
    level: max
    ignoreErrors:
        - '#Laravel\\Passport\\ClientRepository::createPasswordGrantClient()#'
        - '#Illuminate\\Database\\Query\\Builder::dynamicWhere()#'
    paths:
        - %rootDir%/../../../app
        - %rootDir%/../../../routes
        - %rootDir%/../../../tests
        - %rootDir%/../../../database

bug

Most helpful comment

AFAICS, you can't specify paths in phpstan.neon when you run Larastan using php artisan code:analyse.

When you don't specify the --paths= option, Larastan will pass the app directory to PHPStan by default. PHPStan will only use the paths parameter from phpstan.neon when Larastan doesn't provide a path (so in this case: never).

The example from the documentation only works in combination with ./vendor/bin/phpstan analyse.

All 7 comments

Thanks for reporting this. Are you able to debug this and propose a pull request?

Thanks for reply, unfortunately I would not have time to propose a pull request.

@loic-lopez

I had the same issue, but with the excludes_analyse option. What I ended up doing was using wildcard characters. Like so:

    excludes_analyse:
        - /*/*/NovaServiceProvider.php

Maybe this would work for you. Not ideal, and diffidently an issue tho. But it works for now.

AFAICS, you can't specify paths in phpstan.neon when you run Larastan using php artisan code:analyse.

When you don't specify the --paths= option, Larastan will pass the app directory to PHPStan by default. PHPStan will only use the paths parameter from phpstan.neon when Larastan doesn't provide a path (so in this case: never).

The example from the documentation only works in combination with ./vendor/bin/phpstan analyse.

@staudenmeir Can confirm this behavior!

@staudenmeir @blackfyre Thanks for the input on this folks, fell free to improve this feature adding proposing a Pull Request.

The code:analyse artisan command is no longer available. Therefore, this should be no longer an issue.

Was this page helpful?
0 / 5 - 0 ratings