diff --git a/composer.json b/composer.json index 8728941..86153f3 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "illuminate/view": "^6.0 || ^8.0", "vimeo/psalm": "^4.8.1", "orchestra/testbench": "^3.8 || ^4.0 || ^5.0 || ^6.22 || ^7.0", - "barryvdh/laravel-ide-helper": ">=2.8.0 <2.9.2" + "barryvdh/laravel-ide-helper": ">=2.8.0" }, "require-dev": { "codeception/codeception": "^4.1.6", @@ -64,7 +64,10 @@ } }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } }, "minimum-stability": "dev", "prefer-stable": true diff --git a/psalm.xml b/psalm.xml index 6418bc4..fa7f365 100644 --- a/psalm.xml +++ b/psalm.xml @@ -21,9 +21,15 @@ - + + + + + + + diff --git a/src/Fakes/FakeMetaCommand.php b/src/Fakes/FakeMetaCommand.php index f7520a7..d15e49e 100644 --- a/src/Fakes/FakeMetaCommand.php +++ b/src/Fakes/FakeMetaCommand.php @@ -7,12 +7,15 @@ use Barryvdh\LaravelIdeHelper\Console\MetaCommand; class FakeMetaCommand extends MetaCommand { /** - * @return void + * @return callable */ - protected function registerClassAutoloadExceptions() + protected function registerClassAutoloadExceptions(): callable { // by default, the ide-helper throws exceptions when it cannot find a class. However it does not unregister that // autoloader when it is done, and we certainly do not want to throw exceptions when we are simply checking if // a certain class exists. We are instead changing this to be a noop. + + return function () { + }; } } diff --git a/src/Fakes/FakeModelsCommand210.php b/src/Fakes/FakeModelsCommand210.php new file mode 100644 index 0000000..d49d988 --- /dev/null +++ b/src/Fakes/FakeModelsCommand210.php @@ -0,0 +1,32 @@ +schema = $schema; + } + + /** + * Load the properties from the database table. + * + * @param Model $model + */ + public function getPropertiesFromTable($model): void + { + $this->getProperties($model); + } +} diff --git a/src/Fakes/FakeModelsCommand291.php b/src/Fakes/FakeModelsCommand291.php new file mode 100644 index 0000000..7258c70 --- /dev/null +++ b/src/Fakes/FakeModelsCommand291.php @@ -0,0 +1,35 @@ + */ + private $model_classes = []; + + public function __construct(Filesystem $files, SchemaAggregator $schema) + { + parent::__construct($files); + $this->schema = $schema; + } + + /** + * Load the properties from the database table. + * + * @param Model $model + */ + protected function getPropertiesFromTable($model): void + { + $this->getProperties($model); + } +} diff --git a/src/Fakes/FakeModelsCommand.php b/src/Fakes/FakeModelsCommandLogic.php similarity index 87% rename from src/Fakes/FakeModelsCommand.php rename to src/Fakes/FakeModelsCommandLogic.php index 1350608..6674d79 100644 --- a/src/Fakes/FakeModelsCommand.php +++ b/src/Fakes/FakeModelsCommandLogic.php @@ -2,33 +2,21 @@ namespace Psalm\LaravelPlugin\Fakes; -use Barryvdh\LaravelIdeHelper\Console\ModelsCommand; use Illuminate\Database\Eloquent\Model; -use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Str; -use Psalm\LaravelPlugin\Handlers\Eloquent\Schema\SchemaAggregator; use function config; use function get_class; -use function implode; use function in_array; +use function implode; -class FakeModelsCommand extends ModelsCommand +trait FakeModelsCommandLogic { - /** @var SchemaAggregator */ - private $schema; - /** @var array */ private $model_classes = []; - public function __construct(Filesystem $files, SchemaAggregator $schema) - { - parent::__construct($files); - $this->schema = $schema; - } - /** @return array */ - public function getModels() + public function getModels(): array { return $this->model_classes + $this->loadModels(); } diff --git a/src/Providers/FakeModelsCommandProvider.php b/src/Providers/FakeModelsCommandProvider.php new file mode 100644 index 0000000..dd3aebf --- /dev/null +++ b/src/Providers/FakeModelsCommandProvider.php @@ -0,0 +1,37 @@ +ExampleListener + + + Example + + $casts