--level used: 0The magic side of larastan is not working with database factories and the error below is shown when analysing this kind of file:
------ --------------------------------------------------
Line database/factories/MyModel.php
------ --------------------------------------------------
6 Undefined variable: $factory
------ --------------------------------------------------
use Faker\Generator as Faker;
use App\MyModel;
$factory->define(MyModel::class, function (Faker $faker) {
return [
'id' => $faker->randomDigit(),
'description' => $faker->sentence(6, true),
];
});
Is there any way to analyse or simply ignore these files temporarily?
parameters:
excludes_analyse:
- %rootDir%/../../../database/factories/MyModel.php
You may exclude files and suppress errors too. Please see the readme: https://github.com/phpstan/phpstan
Don't forget to to use includes: to keep Larastan's configuration.
But the ideal would be to teach Larastan how to read this code.
See #140
Great! While this analysis is not provided by larastan itself, it's working with this snippet of configuration:
includes:
- vendor/nunomaduro/larastan/extension.neon
parameters:
excludes_analyse:
- %rootDir%/../../../*/factories/*.php
And the command to use the custom conf file is:
$ ./artisan code:analyse --paths='app,modules' --level=0 --configuration=/path/to/app/phpstan.neon
Thank you very much!
You're welcome.
Most helpful comment
Don't forget to to use
includes:to keep Larastan's configuration.But the ideal would be to teach Larastan how to read this code.
See #140