Fix some Psalm errors and bump version

This commit is contained in:
Matthew Brown 2020-01-08 00:10:08 -05:00
parent f9d530f17a
commit 77e1b8a321
7 changed files with 16 additions and 8 deletions

View File

@ -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",

View File

@ -14,7 +14,7 @@ abstract class AbstractPlugin implements PluginEntryPointInterface
{
use CreatesApplication;
/** @var array<class-string> */
/** @var array<string> */
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,

View File

@ -14,6 +14,7 @@ class AppInterfaceProvider implements
\Psalm\Plugin\Hook\MethodVisibilityProviderInterface,
\Psalm\Plugin\Hook\MethodParamsProviderInterface
{
/** @return array<string> */
public static function getClassLikeNames() : array
{
return [

View File

@ -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)
{

View File

@ -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.");
});
}

View File

@ -13,6 +13,7 @@ class ModelPropertyProvider
\Psalm\Plugin\Hook\PropertyVisibilityProviderInterface,
\Psalm\Plugin\Hook\PropertyTypeProviderInterface
{
/** @return array<string, string> */
public static function getClassLikeNames() : array
{
return \Psalm\LaravelPlugin\AbstractPlugin::$model_classes;

View File

@ -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;
}
}