From 056f85bbc946dd5dfe064cc3e798ab5b1fde7c8a Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 16:25:38 +0200 Subject: [PATCH 01/29] undefined property --- src/Psalm/Internal/Codebase/Scanner.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Psalm/Internal/Codebase/Scanner.php b/src/Psalm/Internal/Codebase/Scanner.php index 0e41e9414d8..6270c8ea0cf 100644 --- a/src/Psalm/Internal/Codebase/Scanner.php +++ b/src/Psalm/Internal/Codebase/Scanner.php @@ -678,10 +678,6 @@ private function fileExistsForClassLike(ClassLikes $classlikes, string $fq_class return false; } - if (isset($this->existing_classlikes_lc[$fq_class_name_lc])) { - throw new \InvalidArgumentException('Why are you asking about a builtin class?'); - } - $composer_file_path = $this->config->getComposerFilePathForClassLike($fq_class_name); if ($composer_file_path && file_exists($composer_file_path)) { From 0780b85c30097b188178aacc2c055c680746f2c0 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 16:30:38 +0200 Subject: [PATCH 02/29] undefined param --- src/Psalm/Type/Atomic/TEnumCase.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Psalm/Type/Atomic/TEnumCase.php b/src/Psalm/Type/Atomic/TEnumCase.php index 2e221f4d05b..9e3815c558c 100644 --- a/src/Psalm/Type/Atomic/TEnumCase.php +++ b/src/Psalm/Type/Atomic/TEnumCase.php @@ -11,9 +11,6 @@ class TEnumCase extends TNamedObject */ public $case_name; - /** - * @param string $value the name of the object - */ public function __construct(string $fq_enum_name, string $case_name) { parent::__construct($fq_enum_name, false); From ddcd2e6930200328e24a0f6ef1838ca4e854b153 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 16:31:48 +0200 Subject: [PATCH 03/29] undefined param --- src/Psalm/Plugin/Shepherd.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Psalm/Plugin/Shepherd.php b/src/Psalm/Plugin/Shepherd.php index a41f001a83e..9e4f5a86149 100644 --- a/src/Psalm/Plugin/Shepherd.php +++ b/src/Psalm/Plugin/Shepherd.php @@ -32,8 +32,6 @@ class Shepherd implements \Psalm\Plugin\EventHandler\AfterAnalysisInterface { /** * Called after analysis is complete - * - * @param array> $issues */ public static function afterAnalysis( AfterAnalysisEvent $event From 56dcfe8b99b8713528721b2cc6e693185be9e744 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 16:34:36 +0200 Subject: [PATCH 04/29] weird syntax + class-string param --- src/Psalm/FileBasedPluginAdapter.php | 3 +++ src/Psalm/Plugin/RegistrationInterface.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Psalm/FileBasedPluginAdapter.php b/src/Psalm/FileBasedPluginAdapter.php index 14c39a69ccc..6a838bb3cbd 100644 --- a/src/Psalm/FileBasedPluginAdapter.php +++ b/src/Psalm/FileBasedPluginAdapter.php @@ -5,6 +5,7 @@ use Psalm\Internal\Scanner\FileScanner; use SimpleXMLElement; +use function class_exists; use function reset; class FileBasedPluginAdapter implements Plugin\PluginEntryPointInterface @@ -39,6 +40,8 @@ public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLE /** @psalm-suppress UnresolvableInclude */ require_once($this->path); + \assert(class_exists($fq_class_name)); + $registration->registerHooksFromClass($fq_class_name); } diff --git a/src/Psalm/Plugin/RegistrationInterface.php b/src/Psalm/Plugin/RegistrationInterface.php index 8bc8a8e0880..c8fedb08f46 100644 --- a/src/Psalm/Plugin/RegistrationInterface.php +++ b/src/Psalm/Plugin/RegistrationInterface.php @@ -9,7 +9,7 @@ interface RegistrationInterface public function addStubFile(string $file_name): void; /** - * @param string class-string $handler + * @param class-string $handler */ public function registerHooksFromClass(string $handler): void; From 1f2316f1244309eb74dd611d9ac77a12141d40a0 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 16:40:52 +0200 Subject: [PATCH 05/29] polymorphism --- src/Psalm/Internal/Type/TypeCombiner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Type/TypeCombiner.php b/src/Psalm/Internal/Type/TypeCombiner.php index 73bf6160928..320ebc0f379 100644 --- a/src/Psalm/Internal/Type/TypeCombiner.php +++ b/src/Psalm/Internal/Type/TypeCombiner.php @@ -1455,7 +1455,7 @@ private static function getArrayTypeFromGenericParams( if (is_int($property_name)) { $objectlike_keys[$property_name] = new TLiteralInt($property_name); - } elseif (isset($type->class_strings[$property_name])) { + } elseif ($type instanceof TKeyedArray && isset($type->class_strings[$property_name])) { $objectlike_keys[$property_name] = new TLiteralClassString($property_name); } else { $objectlike_keys[$property_name] = new TLiteralString($property_name); From 2f82f259340088742a4ff71091d73e21c3f68e76 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 16:41:22 +0200 Subject: [PATCH 06/29] undefined param --- .../Provider/ReturnTypeProvider/ExplodeReturnTypeProvider.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ExplodeReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ExplodeReturnTypeProvider.php index ae078fcdb34..4e509d97d86 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ExplodeReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ExplodeReturnTypeProvider.php @@ -15,9 +15,6 @@ public static function getFunctionIds() : array return ['explode']; } - /** - * @param list $call_args - */ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $event) : Type\Union { $statements_source = $event->getStatementsSource(); From b4e0f8318621a5b1050fc214ee9b4eb53ce8a1c9 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 16:47:38 +0200 Subject: [PATCH 07/29] unparsable types --- .../Internal/Provider/NodeDataProvider.php | 52 +++++++------------ 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/src/Psalm/Internal/Provider/NodeDataProvider.php b/src/Psalm/Internal/Provider/NodeDataProvider.php index 40fe9fc42b0..ce95d7b007d 100644 --- a/src/Psalm/Internal/Provider/NodeDataProvider.php +++ b/src/Psalm/Internal/Provider/NodeDataProvider.php @@ -3,26 +3,24 @@ namespace Psalm\Internal\Provider; use PhpParser; +use PhpParser\Node; use Psalm\Type\Union; use SplObjectStorage; class NodeDataProvider implements \Psalm\NodeTypeProvider { - /** @var SplObjectStorage */ + /** @var SplObjectStorage */ private $node_types; /** - * @var SplObjectStorage< - * PhpParser\Node, - * list>>>|null - * > + * @var SplObjectStorage>>>|null> */ private $node_assertions; - /** @var SplObjectStorage> */ + /** @var SplObjectStorage> */ private $node_if_true_assertions; - /** @var SplObjectStorage> */ + /** @var SplObjectStorage> */ private $node_if_false_assertions; /** @var bool */ @@ -37,7 +35,7 @@ public function __construct() } /** - * @param PhpParser\Node\Expr|PhpParser\Node\Name|PhpParser\Node\Stmt\Return_ $node + * @param Node\Expr|Node\Name|Node\Stmt\Return_ $node */ public function setType(PhpParser\NodeAbstract $node, Union $type) : void { @@ -45,7 +43,7 @@ public function setType(PhpParser\NodeAbstract $node, Union $type) : void } /** - * @param PhpParser\Node\Expr|PhpParser\Node\Name|PhpParser\Node\Stmt\Return_ $node + * @param Node\Expr|Node\Name|Node\Stmt\Return_ $node */ public function getType(PhpParser\NodeAbstract $node) : ?Union { @@ -55,7 +53,7 @@ public function getType(PhpParser\NodeAbstract $node) : ?Union /** * @param list>>>|null $assertions */ - public function setAssertions(PhpParser\Node\Expr $node, ?array $assertions) : void + public function setAssertions(Node\Expr $node, ?array $assertions) : void { if (!$this->cache_assertions) { return; @@ -67,7 +65,7 @@ public function setAssertions(PhpParser\Node\Expr $node, ?array $assertions) : v /** * @return list>>>|null */ - public function getAssertions(PhpParser\Node\Expr $node) : ?array + public function getAssertions(Node\Expr $node) : ?array { if (!$this->cache_assertions) { return null; @@ -77,61 +75,49 @@ public function getAssertions(PhpParser\Node\Expr $node) : ?array } /** - * @param PhpParser\Node\Expr\FuncCall - * |PhpParser\Node\Expr\MethodCall - * |PhpParser\Node\Expr\StaticCall - * |PhpParser\Node\Expr\New_ $node + * @param Node\Expr\FuncCall|Node\Expr\MethodCall|Node\Expr\StaticCall|Node\Expr\New_ $node * @param array $assertions */ - public function setIfTrueAssertions(PhpParser\Node\Expr $node, array $assertions) : void + public function setIfTrueAssertions(Node\Expr $node, array $assertions) : void { $this->node_if_true_assertions[$node] = $assertions; } /** - * @param PhpParser\Node\Expr\FuncCall - * |PhpParser\Node\Expr\MethodCall - * |PhpParser\Node\Expr\StaticCall - * |PhpParser\Node\Expr\New_ $node + * @param Node\Expr\FuncCall|Node\Expr\MethodCall|Node\Expr\StaticCall|Node\Expr\New_ $node * @return array|null */ - public function getIfTrueAssertions(PhpParser\Node\Expr $node) : ?array + public function getIfTrueAssertions(Node\Expr $node) : ?array { return $this->node_if_true_assertions[$node] ?? null; } /** - * @param PhpParser\Node\Expr\FuncCall - * |PhpParser\Node\Expr\MethodCall - * |PhpParser\Node\Expr\StaticCall - * |PhpParser\Node\Expr\New_ $node + * @param Node\Expr\FuncCall|Node\Expr\MethodCall|Node\Expr\StaticCall|Node\Expr\New_ $node * @param array $assertions */ - public function setIfFalseAssertions(PhpParser\Node\Expr $node, array $assertions) : void + public function setIfFalseAssertions(Node\Expr $node, array $assertions) : void { $this->node_if_false_assertions[$node] = $assertions; } /** - * @param PhpParser\Node\Expr\FuncCall - * |PhpParser\Node\Expr\MethodCall - * |PhpParser\Node\Expr\StaticCall - * |PhpParser\Node\Expr\New_ $node + * @param Node\Expr\FuncCall|Node\Expr\MethodCall|Node\Expr\StaticCall|Node\Expr\New_ $node * @return array|null */ - public function getIfFalseAssertions(PhpParser\Node\Expr $node) : ?array + public function getIfFalseAssertions(Node\Expr $node) : ?array { return $this->node_if_false_assertions[$node] ?? null; } - public function isPureCompatible(PhpParser\Node\Expr $node) : bool + public function isPureCompatible(Node\Expr $node) : bool { $node_type = $this->getType($node); return ($node_type && $node_type->reference_free) || isset($node->pure); } - public function clearNodeOfTypeAndAssertions(PhpParser\Node\Expr $node) : void + public function clearNodeOfTypeAndAssertions(Node\Expr $node) : void { unset($this->node_types[$node], $this->node_assertions[$node]); } From e61d4906620ef05e091d440a7cc9f59a9efdc218 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 16:49:46 +0200 Subject: [PATCH 08/29] missing return --- src/Psalm/Internal/PhpVisitor/OffsetShifterVisitor.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Psalm/Internal/PhpVisitor/OffsetShifterVisitor.php b/src/Psalm/Internal/PhpVisitor/OffsetShifterVisitor.php index 4a22e8d33c4..499b5f3e199 100644 --- a/src/Psalm/Internal/PhpVisitor/OffsetShifterVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/OffsetShifterVisitor.php @@ -69,5 +69,7 @@ public function enterNode(PhpParser\Node $node) $attrs['endFilePos'] + $this->file_offset + ($this->extra_offsets[$attrs['endFilePos']] ?? 0) ); $node->setAttribute('startLine', $attrs['startLine'] + $this->line_offset); + + return null; } } From ebef0de9b488a7ddf51aa8d541410955cad4aa21 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 16:49:53 +0200 Subject: [PATCH 09/29] missing variable --- src/Psalm/Internal/PluginManager/ComposerLock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/PluginManager/ComposerLock.php b/src/Psalm/Internal/PluginManager/ComposerLock.php index 8fd55bd18c2..2a51b4c0dbc 100644 --- a/src/Psalm/Internal/PluginManager/ComposerLock.php +++ b/src/Psalm/Internal/PluginManager/ComposerLock.php @@ -78,7 +78,7 @@ private function getAllPluginPackages(): array /** @psalm-suppress MixedAssignment */ foreach ($packages as $package) { if ($this->isPlugin($package)) { - /** @var array{name:string,extra:array{psalm:array{pluginClass:string}}} */ + /** @var array{name:string,extra:array{psalm:array{pluginClass:string}}} $ret */ $ret[] = $package; } } From 06f497fca9921e6a99bbb6fc6e0c47415776e46f Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 16:50:14 +0200 Subject: [PATCH 10/29] missing return --- src/Psalm/Internal/PhpVisitor/NodeCounterVisitor.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Psalm/Internal/PhpVisitor/NodeCounterVisitor.php b/src/Psalm/Internal/PhpVisitor/NodeCounterVisitor.php index 1e86a9be8eb..91aa4a8709c 100644 --- a/src/Psalm/Internal/PhpVisitor/NodeCounterVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/NodeCounterVisitor.php @@ -17,5 +17,7 @@ class NodeCounterVisitor extends PhpParser\NodeVisitorAbstract public function enterNode(PhpParser\Node $node) { $this->count++; + + return null; } } From 7b1ee0924ebeb12418f0d67aa181322ebe65730f Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 16:59:23 +0200 Subject: [PATCH 11/29] unnecessary phpdoc --- src/Psalm/Internal/Diff/AstDiffer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Psalm/Internal/Diff/AstDiffer.php b/src/Psalm/Internal/Diff/AstDiffer.php index 89f35a5cd7e..d95ea966b00 100644 --- a/src/Psalm/Internal/Diff/AstDiffer.php +++ b/src/Psalm/Internal/Diff/AstDiffer.php @@ -52,7 +52,6 @@ protected static function calculateTrace( $body_change = false; while ($x < $n && $y < $m && ($is_equal)($a[$x], $b[$y], $a_code, $b_code, $body_change)) { - /** @var bool */ $bc[$x] = $body_change; ++$x; ++$y; From 04afe1fb861a43f972123a4aaa6afb239cc6b00c Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 16:59:34 +0200 Subject: [PATCH 12/29] improved assertion --- src/Psalm/Internal/PluginManager/ComposerLock.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Psalm/Internal/PluginManager/ComposerLock.php b/src/Psalm/Internal/PluginManager/ComposerLock.php index 2a51b4c0dbc..b78da0999c9 100644 --- a/src/Psalm/Internal/PluginManager/ComposerLock.php +++ b/src/Psalm/Internal/PluginManager/ComposerLock.php @@ -25,7 +25,7 @@ public function __construct(array $file_names) /** * @param mixed $package * - * @psalm-assert-if-true array $package + * @psalm-assert-if-true array{name: string, extra: array{psalm: array{pluginClass: string}}} $package * * @psalm-pure */ @@ -78,7 +78,6 @@ private function getAllPluginPackages(): array /** @psalm-suppress MixedAssignment */ foreach ($packages as $package) { if ($this->isPlugin($package)) { - /** @var array{name:string,extra:array{psalm:array{pluginClass:string}}} $ret */ $ret[] = $package; } } From a865090a01fed9cfc8ed8541747e9c5e96e9117e Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 17:06:49 +0200 Subject: [PATCH 13/29] missing types --- src/Psalm/Internal/Scope/IfConditionalScope.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Psalm/Internal/Scope/IfConditionalScope.php b/src/Psalm/Internal/Scope/IfConditionalScope.php index a6791a06566..becf526c905 100644 --- a/src/Psalm/Internal/Scope/IfConditionalScope.php +++ b/src/Psalm/Internal/Scope/IfConditionalScope.php @@ -8,8 +8,10 @@ */ class IfConditionalScope { + /** @var Context */ public $if_context; + /** @var Context */ public $post_if_context; /** From f0b054056370ed415c12a060f40749b4fd1ea410 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 17:08:38 +0200 Subject: [PATCH 14/29] unparsable types --- .../Expression/Call/ArgumentAnalyzer.php | 69 +++++++++---------- 1 file changed, 32 insertions(+), 37 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php index d7bd9b6ccb6..e4c51bec0a8 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php @@ -39,10 +39,7 @@ use Psalm\Plugin\EventHandler\Event\AddRemoveTaintsEvent; use Psalm\Storage\FunctionLikeParameter; use Psalm\Type; -use Psalm\Type\Atomic\TArray; -use Psalm\Type\Atomic\TCallable; -use Psalm\Type\Atomic\TClassString; -use Psalm\Type\Atomic\TList; +use Psalm\Type\Atomic; use function array_merge; use function count; @@ -101,11 +98,11 @@ public static function checkArgumentMatches( ) { /** * @psalm-suppress PossiblyUndefinedStringArrayOffset - * @var TList|TArray + * @var Atomic\TList|Atomic\TArray */ $array_type = $param_type->getAtomicTypes()['array']; - if ($array_type instanceof TList) { + if ($array_type instanceof Atomic\TList) { $param_type = $array_type->type_param; } else { $param_type = $array_type->type_params[1]; @@ -313,20 +310,20 @@ private static function checkFunctionLikeTypeMatches( $arg_type_param = null; foreach ($arg_type->getAtomicTypes() as $arg_atomic_type) { - if ($arg_atomic_type instanceof Type\Atomic\TArray - || $arg_atomic_type instanceof Type\Atomic\TList - || $arg_atomic_type instanceof Type\Atomic\TKeyedArray + if ($arg_atomic_type instanceof Atomic\TArray + || $arg_atomic_type instanceof Atomic\TList + || $arg_atomic_type instanceof Atomic\TKeyedArray ) { - if ($arg_atomic_type instanceof Type\Atomic\TKeyedArray) { + if ($arg_atomic_type instanceof Atomic\TKeyedArray) { $arg_type_param = $arg_atomic_type->getGenericValueType(); - } elseif ($arg_atomic_type instanceof Type\Atomic\TList) { + } elseif ($arg_atomic_type instanceof Atomic\TList) { $arg_type_param = $arg_atomic_type->type_param; } else { $arg_type_param = $arg_atomic_type->type_params[1]; } - } elseif ($arg_atomic_type instanceof Type\Atomic\TIterable) { + } elseif ($arg_atomic_type instanceof Atomic\TIterable) { $arg_type_param = $arg_atomic_type->type_params[1]; - } elseif ($arg_atomic_type instanceof Type\Atomic\TNamedObject) { + } elseif ($arg_atomic_type instanceof Atomic\TNamedObject) { ForeachAnalyzer::getKeyValueParamsForTraversableObject( $arg_atomic_type, $codebase, @@ -457,12 +454,12 @@ private static function checkFunctionLikeTypeMatches( if ($arg_type->hasArray()) { /** * @psalm-suppress PossiblyUndefinedStringArrayOffset - * @var Type\Atomic\TArray|Type\Atomic\TList|Type\Atomic\TKeyedArray|Type\Atomic\TClassStringMap + * @var Atomic\TArray|Atomic\TList|Atomic\TKeyedArray|Atomic\TClassStringMap */ $unpacked_atomic_array = $arg_type->getAtomicTypes()['array']; $arg_key_allowed = true; - if ($unpacked_atomic_array instanceof Type\Atomic\TKeyedArray) { + if ($unpacked_atomic_array instanceof Atomic\TKeyedArray) { if (!$allow_named_args && !$unpacked_atomic_array->getGenericKeyType()->isInt()) { $arg_key_allowed = false; } @@ -493,9 +490,9 @@ private static function checkFunctionLikeTypeMatches( } else { $arg_type = Type::getMixed(); } - } elseif ($unpacked_atomic_array instanceof Type\Atomic\TList) { + } elseif ($unpacked_atomic_array instanceof Atomic\TList) { $arg_type = $unpacked_atomic_array->type_param; - } elseif ($unpacked_atomic_array instanceof Type\Atomic\TClassStringMap) { + } elseif ($unpacked_atomic_array instanceof Atomic\TClassStringMap) { $arg_type = Type::getMixed(); } else { if (!$allow_named_args && !$unpacked_atomic_array->type_params[0]->isInt()) { @@ -653,8 +650,7 @@ private static function checkFunctionLikeTypeMatches( } /** - * @param Type\Atomic\TKeyedArray|Type\Atomic\TArray|Type\Atomic\TList|Type\Atomic\TClassStringMap - * $unpacked_atomic_array + * @param Atomic\TKeyedArray|Atomic\TArray|Atomic\TList|Atomic\TClassStringMap $unpacked_atomic_array * @return null|false */ public static function verifyType( @@ -835,7 +831,7 @@ public static function verifyType( // we do this replacement early because later we don't have access to the // $statements_analyzer, which is necessary to understand string function names foreach ($input_type->getAtomicTypes() as $key => $atomic_type) { - if (!$atomic_type instanceof Type\Atomic\TLiteralString + if (!$atomic_type instanceof Atomic\TLiteralString || \Psalm\Internal\Codebase\InternalCallMapHandler::inCallMap($atomic_type->value) ) { continue; @@ -902,7 +898,7 @@ public static function verifyType( $potential_method_ids = []; foreach ($input_type->getAtomicTypes() as $input_type_part) { - if ($input_type_part instanceof Type\Atomic\TKeyedArray) { + if ($input_type_part instanceof Atomic\TKeyedArray) { $potential_method_id = CallableTypeComparator::getCallableMethodIdFromTKeyedArray( $input_type_part, $codebase, @@ -913,7 +909,7 @@ public static function verifyType( if ($potential_method_id && $potential_method_id !== 'not-callable') { $potential_method_ids[] = $potential_method_id; } - } elseif ($input_type_part instanceof Type\Atomic\TLiteralString + } elseif ($input_type_part instanceof Atomic\TLiteralString && strpos($input_type_part->value, '::') ) { $parts = explode('::', $input_type_part->value); @@ -1183,7 +1179,7 @@ private static function verifyExplicitParam( $codebase = $statements_analyzer->getCodebase(); foreach ($param_type->getAtomicTypes() as $param_type_part) { - if ($param_type_part instanceof TClassString + if ($param_type_part instanceof Atomic\TClassString && $input_expr instanceof PhpParser\Node\Scalar\String_ && $param_type->isSingle() ) { @@ -1199,11 +1195,11 @@ private static function verifyExplicitParam( ) { return; } - } elseif ($param_type_part instanceof TArray + } elseif ($param_type_part instanceof Atomic\TArray && $input_expr instanceof PhpParser\Node\Expr\Array_ ) { foreach ($param_type_part->type_params[1]->getAtomicTypes() as $param_array_type_part) { - if ($param_array_type_part instanceof TClassString) { + if ($param_array_type_part instanceof Atomic\TClassString) { foreach ($input_expr->items as $item) { if ($item && $item->value instanceof PhpParser\Node\Scalar\String_) { if (ClassLikeAnalyzer::checkFullyQualifiedClassLikeName( @@ -1222,7 +1218,7 @@ private static function verifyExplicitParam( } } } - } elseif ($param_type_part instanceof TCallable) { + } elseif ($param_type_part instanceof Atomic\TCallable) { $can_be_callable_like_array = false; if ($param_type->hasArray()) { /** @@ -1231,11 +1227,11 @@ private static function verifyExplicitParam( $param_array_type = $param_type->getAtomicTypes()['array']; $row_type = null; - if ($param_array_type instanceof TList) { + if ($param_array_type instanceof Atomic\TList) { $row_type = $param_array_type->type_param; - } elseif ($param_array_type instanceof TArray) { + } elseif ($param_array_type instanceof Atomic\TArray) { $row_type = $param_array_type->type_params[1]; - } elseif ($param_array_type instanceof Type\Atomic\TKeyedArray) { + } elseif ($param_array_type instanceof Atomic\TKeyedArray) { $row_type = $param_array_type->getGenericArrayType()->type_params[1]; } @@ -1350,8 +1346,7 @@ private static function verifyExplicitParam( } /** - * @param Type\Atomic\TKeyedArray|Type\Atomic\TArray|Type\Atomic\TList|Type\Atomic\TClassStringMap - * $unpacked_atomic_array + * @param Atomic\TKeyedArray|Atomic\TArray|Atomic\TList|Atomic\TClassStringMap $unpacked_atomic_array */ private static function coerceValueAfterGatekeeperArgument( StatementsAnalyzer $statements_analyzer, @@ -1372,9 +1367,9 @@ private static function coerceValueAfterGatekeeperArgument( $input_type = clone $input_type; foreach ($param_type->getAtomicTypes() as $param_atomic_type) { - if ($param_atomic_type instanceof Type\Atomic\TGenericObject) { + if ($param_atomic_type instanceof Atomic\TGenericObject) { foreach ($input_type->getAtomicTypes() as $input_atomic_type) { - if ($input_atomic_type instanceof Type\Atomic\TGenericObject + if ($input_atomic_type instanceof Atomic\TGenericObject && $input_atomic_type->value === $param_atomic_type->value ) { foreach ($input_atomic_type->type_params as $i => $type_param) { @@ -1445,17 +1440,17 @@ private static function coerceValueAfterGatekeeperArgument( } if ($unpack) { - if ($unpacked_atomic_array instanceof Type\Atomic\TList) { + if ($unpacked_atomic_array instanceof Atomic\TList) { $unpacked_atomic_array = clone $unpacked_atomic_array; $unpacked_atomic_array->type_param = $input_type; $context->vars_in_scope[$var_id] = new Type\Union([$unpacked_atomic_array]); - } elseif ($unpacked_atomic_array instanceof Type\Atomic\TArray) { + } elseif ($unpacked_atomic_array instanceof Atomic\TArray) { $unpacked_atomic_array = clone $unpacked_atomic_array; $unpacked_atomic_array->type_params[1] = $input_type; $context->vars_in_scope[$var_id] = new Type\Union([$unpacked_atomic_array]); - } elseif ($unpacked_atomic_array instanceof Type\Atomic\TKeyedArray + } elseif ($unpacked_atomic_array instanceof Atomic\TKeyedArray && $unpacked_atomic_array->is_list ) { $unpacked_atomic_array = $unpacked_atomic_array->getList(); @@ -1464,7 +1459,7 @@ private static function coerceValueAfterGatekeeperArgument( $context->vars_in_scope[$var_id] = new Type\Union([$unpacked_atomic_array]); } else { $context->vars_in_scope[$var_id] = new Type\Union([ - new TArray([ + new Atomic\TArray([ Type::getInt(), $input_type ]), From 671a175debed1aa1d9674b6b4485f332882562e4 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 17:08:51 +0200 Subject: [PATCH 15/29] unnecessary phpdoc --- .../Expression/Call/Method/AtomicMethodCallAnalyzer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php index 999c0e2e026..c4f01a12fad 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php @@ -471,7 +471,6 @@ private static function getIntersectionReturnType( foreach ($intersection_types as $intersection_type) { $intersection_result = clone $result; - /** @var ?Type\Union */ $intersection_result->return_type = null; self::analyze( From a9b1248e9fbab1404baf9f2670581941fbf4270a Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 17:13:58 +0200 Subject: [PATCH 16/29] unnecessary phpdoc is necessary --- .../Expression/Call/Method/AtomicMethodCallAnalyzer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php index c4f01a12fad..af816fa7052 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php @@ -471,6 +471,7 @@ private static function getIntersectionReturnType( foreach ($intersection_types as $intersection_type) { $intersection_result = clone $result; + /** @var ?Type\Union $intersection_result->return_type */ $intersection_result->return_type = null; self::analyze( From 89f5c12be22376bd03939dd4558847406881054d Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 17:14:10 +0200 Subject: [PATCH 17/29] unparsable types --- .../Internal/Analyzer/Statements/Expression/CallAnalyzer.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php index 43a0a13c65d..1b94c2abf64 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php @@ -467,8 +467,7 @@ public static function getGenericParamForOffset( } /** - * @param PhpParser\Node\Scalar\String_|PhpParser\Node\Expr\Array_|PhpParser\Node\Expr\BinaryOp\Concat - * $callable_arg + * @param PhpParser\Node\Scalar\String_|PhpParser\Node\Expr\Array_|PhpParser\Node\Expr\BinaryOp\Concat $callable_arg * * @return list * From 748d58a1d680bf2ffef1c07fe5b1a8b80fddfd87 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 17:14:57 +0200 Subject: [PATCH 18/29] unparsable types --- .../Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php | 4 ++-- .../Statements/Expression/BinaryOp/ConcatAnalyzer.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php index 2327d90e063..01dd1162704 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ArithmeticOpAnalyzer.php @@ -289,8 +289,8 @@ private static function getNumericalType($result): Type\Union } /** - * @param string[] &$invalid_left_messages - * @param string[] &$invalid_right_messages + * @param string[] $invalid_left_messages + * @param string[] $invalid_right_messages */ private static function analyzeOperands( ?StatementsSource $statements_source, diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php index a5c2ba130a0..e5f6d515f91 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/ConcatAnalyzer.php @@ -36,7 +36,7 @@ class ConcatAnalyzer { /** - * @param Type\Union|null &$result_type + * @param Type\Union|null $result_type */ public static function analyze( StatementsAnalyzer $statements_analyzer, From cc77abaa40c8fc1306f78656eb8ba23fc04347cf Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 17:19:45 +0200 Subject: [PATCH 19/29] unparsable types --- src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php index 3d4321764cf..a444bf3c8bb 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php @@ -58,7 +58,7 @@ public static function analyze( $existing_thrown_exceptions = $context->possibly_thrown_exceptions; /** - * @var array> + * @var array> $context->possibly_thrown_exceptions */ $context->possibly_thrown_exceptions = []; @@ -270,9 +270,6 @@ public static function analyze( } } - /** - * @var array> - */ $catch_context->possibly_thrown_exceptions = []; } From 7891e6136a3dc4c2b6c6ea92b5829bf8e3b3cfcc Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 17:19:50 +0200 Subject: [PATCH 20/29] unparsable types --- .../Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php index 4996ba30157..a84a19e2995 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/BinaryOp/AndAnalyzer.php @@ -55,7 +55,7 @@ public static function analyze( $left_context->referenced_var_ids = []; $left_context->assigned_var_ids = []; - /** @var list */ + /** @var list $left_context->reconciled_expression_clauses */ $left_context->reconciled_expression_clauses = []; if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->left, $left_context) === false) { From 146d02e3e10512545fcebbb6fa31340f22856bb5 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 17:28:51 +0200 Subject: [PATCH 21/29] unset instead of reassign --- src/Psalm/Internal/Scope/CaseScope.php | 2 +- src/Psalm/Internal/Scope/LoopScope.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Psalm/Internal/Scope/CaseScope.php b/src/Psalm/Internal/Scope/CaseScope.php index 220ac60e5e3..fa921007efd 100644 --- a/src/Psalm/Internal/Scope/CaseScope.php +++ b/src/Psalm/Internal/Scope/CaseScope.php @@ -26,6 +26,6 @@ public function __construct(Context $parent_context) public function __destruct() { - $this->parent_context = null; + unset($this->parent_context); } } diff --git a/src/Psalm/Internal/Scope/LoopScope.php b/src/Psalm/Internal/Scope/LoopScope.php index aa4092df46d..2bbfe903b95 100644 --- a/src/Psalm/Internal/Scope/LoopScope.php +++ b/src/Psalm/Internal/Scope/LoopScope.php @@ -67,7 +67,7 @@ public function __construct(Context $loop_context, Context $parent_context) public function __destruct() { - $this->loop_context = null; - $this->loop_parent_context = null; + unset($this->loop_context); + unset($this->loop_parent_context); } } From bff08670f5c91408d7f7e013b2c5d34474214e74 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 17:32:04 +0200 Subject: [PATCH 22/29] put int instead of float --- src/Psalm/Internal/Provider/FakeFileProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/Provider/FakeFileProvider.php b/src/Psalm/Internal/Provider/FakeFileProvider.php index 0a7de8e8303..596fecd9d24 100644 --- a/src/Psalm/Internal/Provider/FakeFileProvider.php +++ b/src/Psalm/Internal/Provider/FakeFileProvider.php @@ -63,7 +63,7 @@ public function getModifiedTime(string $file_path): int public function registerFile(string $file_path, string $file_contents): void { $this->fake_files[$file_path] = $file_contents; - $this->fake_file_times[$file_path] = microtime(true); + $this->fake_file_times[$file_path] = (int)microtime(true); } /** From 6c892125c392846c28b2bbe09d5cdd8d941b3b72 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 17:33:12 +0200 Subject: [PATCH 23/29] interface compat --- src/Psalm/Internal/PhpVisitor/TypeMappingVisitor.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/PhpVisitor/TypeMappingVisitor.php b/src/Psalm/Internal/PhpVisitor/TypeMappingVisitor.php index 2a3cbbe5cb2..5266c587f16 100644 --- a/src/Psalm/Internal/PhpVisitor/TypeMappingVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/TypeMappingVisitor.php @@ -18,7 +18,7 @@ public function __construct( $this->real_type_provider = $real_type_provider; } - public function enterNode(Node $node): void + public function enterNode(Node $node) { $origNode = $node; @@ -29,5 +29,7 @@ public function enterNode(Node $node): void /** @psalm-suppress ArgumentTypeCoercion */ $this->real_type_provider->setType($origNode, clone $node_type); } + + return null; } } From 74474891338b5ddc5a922599e31e1d67c8214e76 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 17:57:18 +0200 Subject: [PATCH 24/29] better types --- .../Internal/PhpVisitor/SimpleNameResolver.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php b/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php index e53d99feec7..045a988f0d8 100644 --- a/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php +++ b/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php @@ -8,8 +8,11 @@ use PhpParser\NameContext; use PhpParser\Node; use PhpParser\Node\Expr; +use PhpParser\Node\Identifier; use PhpParser\Node\Name; +use PhpParser\Node\NullableType; use PhpParser\Node\Stmt; +use PhpParser\Node\UnionType; use PhpParser\NodeVisitorAbstract; /** @@ -167,16 +170,14 @@ private function resolveSignature(PhpParser\NodeAbstract $node): void } /** - * @param PhpParser\Node|string|null $node - * - * @return null|PhpParser\Node\Identifier|PhpParser\Node\Name|PhpParser\Node\NullableType - * @psalm-suppress InvalidReturnType - * @psalm-suppress InvalidReturnStatement + * @template T of Node|null + * @param T $node + * @return ($node is NullableType ? NullableType : ($node is Name ? Name : T)) + * @psalm-suppress LessSpecificReturnType */ - private function resolveType($node): ?Node + private function resolveType(?Node $node): ?Node { if ($node instanceof Node\NullableType) { - /** @psalm-suppress PossiblyInvalidPropertyAssignmentValue */ $node->type = $this->resolveType($node->type); return $node; From 06da96843aab1ba4ecfce1d38d44721acd294dbf Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 18:09:49 +0200 Subject: [PATCH 25/29] interface compat --- src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php index 6972bd48aca..8c1a4c320dd 100644 --- a/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php +++ b/src/Psalm/Internal/PhpVisitor/ReflectorVisitor.php @@ -636,8 +636,10 @@ public function getAliases(): Aliases return $this->aliases; } - public function afterTraverse(array $nodes): void + public function afterTraverse(array $nodes) { $this->file_storage->type_aliases = $this->type_aliases; + + return null; } } From 41ea541084d097bb6d0a63a0e6e1f22fcbebb968 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 18:11:54 +0200 Subject: [PATCH 26/29] unset instead of reassign --- .../Internal/Analyzer/ClassLikeAnalyzer.php | 4 +-- src/Psalm/Internal/Analyzer/FileAnalyzer.php | 3 +- .../Internal/Analyzer/SourceAnalyzer.php | 2 +- .../Statements/Block/SwitchCaseAnalyzer.php | 28 ++++++++----------- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php index 825d9a52a4b..f1b66b95e4c 100644 --- a/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/ClassLikeAnalyzer.php @@ -106,8 +106,8 @@ public function __construct(PhpParser\Node\Stmt\ClassLike $class, SourceAnalyzer public function __destruct() { - $this->source = null; - $this->file_analyzer = null; + unset($this->source); + unset($this->file_analyzer); } public function getMethodMutations( diff --git a/src/Psalm/Internal/Analyzer/FileAnalyzer.php b/src/Psalm/Internal/Analyzer/FileAnalyzer.php index fe8c61bebb0..1e6a46c9eb1 100644 --- a/src/Psalm/Internal/Analyzer/FileAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/FileAnalyzer.php @@ -662,7 +662,6 @@ public function getReturnType() : ?Type\Union public function clearSourceBeforeDestruction() : void { - /** @psalm-suppress PossiblyNullPropertyAssignmentValue */ - $this->source = null; + unset($this->source); } } diff --git a/src/Psalm/Internal/Analyzer/SourceAnalyzer.php b/src/Psalm/Internal/Analyzer/SourceAnalyzer.php index 8e6739564da..ba8d0c31998 100644 --- a/src/Psalm/Internal/Analyzer/SourceAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/SourceAnalyzer.php @@ -18,7 +18,7 @@ abstract class SourceAnalyzer implements StatementsSource public function __destruct() { - $this->source = null; + unset($this->source); } public function getAliases(): Aliases diff --git a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php index 920fd7e43fc..bbedadc6c62 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Block/SwitchCaseAnalyzer.php @@ -98,10 +98,9 @@ public static function analyze( $case_context->inside_conditional = true; if (ExpressionAnalyzer::analyze($statements_analyzer, $case->cond, $case_context) === false) { - /** @psalm-suppress PossiblyNullPropertyAssignmentValue */ - $case_scope->parent_context = null; - $case_context->case_scope = null; - $case_context->parent_context = null; + unset($case_scope->parent_context); + unset($case_context->case_scope); + unset($case_context->parent_context); return false; } @@ -273,10 +272,9 @@ public static function analyze( $switch_scope->leftover_statements = [$case_if_stmt]; } - /** @psalm-suppress PossiblyNullPropertyAssignmentValue */ - $case_scope->parent_context = null; - $case_context->case_scope = null; - $case_context->parent_context = null; + unset($case_scope->parent_context); + unset($case_context->case_scope); + unset($case_context->parent_context); $statements_analyzer->node_data = $old_node_data; @@ -500,10 +498,9 @@ public static function analyze( $case_exit_type, $switch_scope ) === false) { - /** @psalm-suppress PossiblyNullPropertyAssignmentValue */ - $case_scope->parent_context = null; - $case_context->case_scope = null; - $case_context->parent_context = null; + unset($case_scope->parent_context); + unset($case_context->case_scope); + unset($case_context->parent_context); return false; } @@ -558,10 +555,9 @@ public static function analyze( } } - /** @psalm-suppress PossiblyNullPropertyAssignmentValue */ - $case_scope->parent_context = null; - $case_context->case_scope = null; - $case_context->parent_context = null; + unset($case_scope->parent_context); + unset($case_context->case_scope); + unset($case_context->parent_context); return null; } From f1e5ecf876f7d4dd81ded451818869e021a0acf9 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 18:28:25 +0200 Subject: [PATCH 27/29] CS fix --- src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php b/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php index 045a988f0d8..6ccdf98793e 100644 --- a/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php +++ b/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php @@ -8,11 +8,8 @@ use PhpParser\NameContext; use PhpParser\Node; use PhpParser\Node\Expr; -use PhpParser\Node\Identifier; use PhpParser\Node\Name; -use PhpParser\Node\NullableType; use PhpParser\Node\Stmt; -use PhpParser\Node\UnionType; use PhpParser\NodeVisitorAbstract; /** From f4fa1f7a1b9b7699b2c596b233186dca2d48e830 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 18:35:18 +0200 Subject: [PATCH 28/29] CS fix --- src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php b/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php index 6ccdf98793e..133fe825584 100644 --- a/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php +++ b/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php @@ -9,6 +9,7 @@ use PhpParser\Node; use PhpParser\Node\Expr; use PhpParser\Node\Name; +use PhpParser\Node\NullableType; use PhpParser\Node\Stmt; use PhpParser\NodeVisitorAbstract; From a214b1438837a30631539d82e568bdc592f4f161 Mon Sep 17 00:00:00 2001 From: orklah Date: Sat, 25 Sep 2021 18:38:01 +0200 Subject: [PATCH 29/29] CS fix --- src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php b/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php index 133fe825584..04d41daa332 100644 --- a/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php +++ b/src/Psalm/Internal/PhpVisitor/SimpleNameResolver.php @@ -175,7 +175,7 @@ private function resolveSignature(PhpParser\NodeAbstract $node): void */ private function resolveType(?Node $node): ?Node { - if ($node instanceof Node\NullableType) { + if ($node instanceof NullableType) { $node->type = $this->resolveType($node->type); return $node;