diff --git a/composer.json b/composer.json index 9b9f11d..0d18eb1 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "psalm-plugin", "require": { "barryvdh/laravel-ide-helper": "^2.6", - "vimeo/psalm": "^3.7", + "vimeo/psalm": "^3.8.2", "orchestra/testbench": "^3.5 || ^4.0" }, "license": "MIT", diff --git a/src/AbstractPlugin.php b/src/AbstractPlugin.php index 5771ac2..f7ead5d 100644 --- a/src/AbstractPlugin.php +++ b/src/AbstractPlugin.php @@ -14,7 +14,7 @@ abstract class AbstractPlugin implements PluginEntryPointInterface { use CreatesApplication; - /** @var array */ + /** @var array */ public static $model_classes = []; /** @@ -76,7 +76,7 @@ abstract class AbstractPlugin implements PluginEntryPointInterface \Illuminate\Filesystem\Filesystem $fake_filesystem, $view_factory, string $cache_dir - ) { + ) : void { $stubs_generator_command = new \Barryvdh\LaravelIdeHelper\Console\GeneratorCommand( $app['config'], $fake_filesystem, diff --git a/src/AppInterfaceProvider.php b/src/AppInterfaceProvider.php index 0051597..0b27e1b 100644 --- a/src/AppInterfaceProvider.php +++ b/src/AppInterfaceProvider.php @@ -14,6 +14,7 @@ class AppInterfaceProvider implements \Psalm\Plugin\Hook\MethodVisibilityProviderInterface, \Psalm\Plugin\Hook\MethodParamsProviderInterface { + /** @return array */ public static function getClassLikeNames() : array { return [ diff --git a/src/FakeFilesystem.php b/src/FakeFilesystem.php index abaf8d0..bca2ef3 100644 --- a/src/FakeFilesystem.php +++ b/src/FakeFilesystem.php @@ -13,7 +13,7 @@ class FakeFilesystem extends \Illuminate\Filesystem\Filesystem * @param string $path * @param string $contents * @param bool $lock - * @return int + * @return bool|int */ public function put($path, $contents, $lock = false) { diff --git a/src/FakeMetaCommand.php b/src/FakeMetaCommand.php index 2c8a83f..1054f93 100644 --- a/src/FakeMetaCommand.php +++ b/src/FakeMetaCommand.php @@ -7,7 +7,7 @@ class FakeMetaCommand extends \Barryvdh\LaravelIdeHelper\Console\MetaCommand * @return void */ protected function registerClassAutoloadExceptions() { - spl_autoload_register(function ($class) { + spl_autoload_register(function (string $class) { throw new \ReflectionException("Class '$class' not found."); }); } diff --git a/src/PropertyProvider/ModelPropertyProvider.php b/src/PropertyProvider/ModelPropertyProvider.php index 8646e65..679c782 100644 --- a/src/PropertyProvider/ModelPropertyProvider.php +++ b/src/PropertyProvider/ModelPropertyProvider.php @@ -13,6 +13,7 @@ class ModelPropertyProvider \Psalm\Plugin\Hook\PropertyVisibilityProviderInterface, \Psalm\Plugin\Hook\PropertyTypeProviderInterface { + /** @return array */ public static function getClassLikeNames() : array { return \Psalm\LaravelPlugin\AbstractPlugin::$model_classes; diff --git a/src/SchemaAggregator.php b/src/SchemaAggregator.php index e3004b0..7ffeba5 100644 --- a/src/SchemaAggregator.php +++ b/src/SchemaAggregator.php @@ -28,6 +28,7 @@ class SchemaAggregator foreach ($stmts as $stmt) { if ($stmt instanceof PhpParser\Node\Stmt\ClassMethod && $stmt->name->name === 'up' + && $stmt->stmts ) { $this->addUpMethodStatements($stmt->stmts); } @@ -94,9 +95,13 @@ class SchemaAggregator $update_closure = $call->args[1]->value; - $call_arg_name = $call->args[1]->value->params[0]->var->name; + if ($call->args[1]->value->params[0]->var instanceof PhpParser\Node\Expr\Variable + && is_string($call->args[1]->value->params[0]->var->name) + ) { + $call_arg_name = $call->args[1]->value->params[0]->var->name; - $this->processColumnUpdates($table_name, $call_arg_name, $update_closure->stmts); + $this->processColumnUpdates($table_name, $call_arg_name, $update_closure->stmts); + } } private function dropTable(PhpParser\Node\Expr\StaticCall $call) : void @@ -172,6 +177,7 @@ class SchemaAggregator if ($root_var instanceof PhpParser\Node\Expr\Variable && $root_var->name === $call_arg_name + && $first_method_call->name instanceof PhpParser\Node\Identifier ) { $first_arg = $first_method_call->args[0]->value ?? null; $second_arg = $first_method_call->args[1]->value ?? null; @@ -234,7 +240,7 @@ class SchemaAggregator $second_arg_array = []; foreach ($second_arg->items as $array_item) { - if ($array_item->value instanceof PhpParser\Node\Scalar\String_) { + if ($array_item && $array_item->value instanceof PhpParser\Node\Scalar\String_) { $second_arg_array[] = $array_item->value->value; } }