Problem
I recently started using PHPStan to analyse my code for my Laravel projects but I keep getting the following error for all my models:
------ --------------------------------------------------------------------
Line Models/Fund.php
------ --------------------------------------------------------------------
14 PHPDoc tag @mixin contains unknown class App\Models\IdeHelperFund.
💡 Learn more at https://phpstan.org/user-guide/discovering-symbols
------ --------------------------------------------------------------------
Code
Here's the code that triggers the errors:
<?php
namespace App\Models;
/**
* Class Fund
*
* @package App\Models
* @mixin IdeHelperFund
*/
class Fund extends Model
{
//...
}
This mixin is added through running the command php artisan ide-helper:models -M
which is needed for the Laravel IDE-helper package which as the name suggests adds docblocks for the IDE to typehint magic methods of Laravel.
So I tried to solve this with Ignore errors with the following piece of code:
includes:
- ./vendor/nunomaduro/larastan/extension.neon
parameters:
paths:
- app
# The level 8 is the highest level
level: 5
ignoreErrors:
-
message: '#PHPDoc tag @mixin contains unknown class App\\Models\\IdeHelper(.*)+\.#'
path: Models/*
excludePaths:
checkMissingIterableValueType: false
But somehow the errors are not matched while testing the regex at Regexr work fine.
Any suggestions what I'm doing wrong? I've noticed in the ignore errors docs that they add # at the beginning and the end of the regex so I've added that to my phpstan configuration but I'm not sure if this is required, but without them I get the following error (so I left them in):
-- ------------------------------------------------------------------------------------------------------------------------------------
Error
-- ------------------------------------------------------------------------------------------------------------------------------------
Delimiter must not be alphanumeric or backslash in pattern: PHPDoc tag @mixin contains unknown class App\\Models\\IdeHelper(.*)+\.
-- ------------------------------------------------------------------------------------------------------------------------------------
Additional information
I'm using the default larastan version 0.7.12 extension.