mirror of
https://github.com/danog/psalm-plugin-laravel.git
synced 2024-11-30 04:39:01 +01:00
fix: suppress PropertyNotSetInConstructor in Command/FormRequest
This commit is contained in:
parent
c8e0c5161e
commit
273411ad94
27
src/Handlers/SuppressHandler.php
Normal file
27
src/Handlers/SuppressHandler.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Psalm\LaravelPlugin\Handlers;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Psalm\Plugin\EventHandler\AfterClassLikeVisitInterface;
|
||||
use Psalm\Plugin\EventHandler\Event\AfterClassLikeVisitEvent;
|
||||
use function in_array;
|
||||
|
||||
class SuppressHandler implements AfterClassLikeVisitInterface
|
||||
{
|
||||
public static function afterClassLikeVisit(AfterClassLikeVisitEvent $event)
|
||||
{
|
||||
$storage = $event->getStorage();
|
||||
|
||||
// Commands: suppress PropertyNotSetInConstructor.
|
||||
if (in_array(Command::class, $storage->parent_classes) && !in_array('PropertyNotSetInConstructor', $storage->suppressed_issues)) {
|
||||
$storage->suppressed_issues[] = 'PropertyNotSetInConstructor';
|
||||
}
|
||||
|
||||
// FormRequest: suppress PropertyNotSetInConstructor.
|
||||
if (in_array(FormRequest::class, $storage->parent_classes) && !in_array('PropertyNotSetInConstructor', $storage->suppressed_issues)) {
|
||||
$storage->suppressed_issues[] = 'PropertyNotSetInConstructor';
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ use Psalm\LaravelPlugin\Handlers\Helpers\RedirectHandler;
|
||||
use Psalm\LaravelPlugin\Handlers\Helpers\TransHandler;
|
||||
use Psalm\LaravelPlugin\Handlers\Helpers\UrlHandler;
|
||||
use Psalm\LaravelPlugin\Handlers\Helpers\ViewHandler;
|
||||
use Psalm\LaravelPlugin\Handlers\SuppressHandler;
|
||||
use Psalm\LaravelPlugin\Providers\ApplicationProvider;
|
||||
use Psalm\LaravelPlugin\Providers\FacadeStubProvider;
|
||||
use Psalm\LaravelPlugin\Providers\ModelStubProvider;
|
||||
@ -75,6 +76,8 @@ class Plugin implements PluginEntryPointInterface
|
||||
$registration->registerHooksFromClass(TransHandler::class);
|
||||
require_once 'Handlers/Helpers/RedirectHandler.php';
|
||||
$registration->registerHooksFromClass(RedirectHandler::class);
|
||||
require_once 'Handlers/SuppressHandler.php';
|
||||
$registration->registerHooksFromClass(SuppressHandler::class);
|
||||
}
|
||||
|
||||
private function generateStubFiles(): void
|
||||
|
Loading…
Reference in New Issue
Block a user