Larastan: The comand it fails from start

Created on 13 Aug 2018  路  13Comments  路  Source: nunomaduro/larastan

  • Larastan Version: last
  • --level used: default

Description:

It fails when I run php artisan code:analyze

Laravel code where the issue was found:

$ php artisan code:analyse --paths="app/" --error-format=table
Note: Using the option --errorFormat is deprecated. Use --error-format instead.
Error formatter "" not found. Available error formatters are: checkstyle, raw, table, json, prettyJson

When downgrading to phpstan 0.10.2: it works

```
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 2 updates, 0 removals

  • Downgrading phpstan/phpstan (0.10.3 => 0.10.2): Downloading (100%)
  • Updating psy/psysh (v0.9.6 => v0.9.7): Downloading (100%)

All 13 comments

This is a weird error because in PHPStan itself, there's backwards compatibility to make the old option work:

phpstan master $ bin/phpstan analyse src --errorFormat json
Note: Using the option --errorFormat is deprecated. Use --error-format instead.
 336/336 [鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔鈻撯枔] 100%

{"totals":{"errors":0,"file_errors":0},"files":[],"errors":[]}

in PHPStan they have a wierd check

        if ($oldErrorFormat !== null) {
            $errOutput->writeln('Note: Using the option --errorFormat is deprecated. Use --error-format instead.');

            $errorFormat = $oldErrorFormat;
        }

The problem is that $oldErrorFormat is empty string.

It's not weird - you either pass --error-format X or --errorFormat X. I don't know why someone would pass -errorFormat ''.

I got it: This line in OptionsResolver is potentially dangerous:

$definition = clone $this->command->getDefinition();

Because it clones deprecated options as well.

I don't.

I pass

$ php artisan code:analyse --paths="app/"
Note: Using the option --errorFormat is deprecated. Use --error-format instead.
Error formatter "" not found. Available error formatters are: checkstyle, raw, table, json, prettyJson

The problem is that the oldErrorFormat gets emptyString and not null

@catalinux Larastan does on your behalf and it shouldn't.

I'm hopefully fixing this in #121.

Facing the same issue :(

Lock PHPStan to 0.10.2 or wait until the PR is merged 馃槉

does anyone have idea about when the PR will be Merged ? @ondrejmirtes

Nuno (the maintainer) is on vacation whole August, so probably after that. Use PHPStan 0.10.2 until then.

@progalaa : the only solutions is to add phpstan/phpstan (0.10.2) dependency in your project till this merge will be made

@progalaa @catalinux @ondrejmirtes @coding-sunshine this issue has been fixed on the version v0.2.5, props to @ondrejmirtes

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Gummibeer picture Gummibeer  路  3Comments

grcasanova picture grcasanova  路  4Comments

tranba picture tranba  路  4Comments

spaceemotion picture spaceemotion  路  4Comments

mariomka picture mariomka  路  4Comments