diff --git a/src/Psalm/Internal/Analyzer/AttributesAnalyzer.php b/src/Psalm/Internal/Analyzer/AttributesAnalyzer.php index 3fa20363f3c..38f163c1af8 100644 --- a/src/Psalm/Internal/Analyzer/AttributesAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/AttributesAnalyzer.php @@ -25,6 +25,7 @@ use RuntimeException; use function array_shift; +use function array_values; use function assert; use function count; use function reset; @@ -42,9 +43,9 @@ class AttributesAnalyzer ]; /** - * @param list $attribute_groups - * @param 1|2|4|8|16|32 $target - * @param array $suppressed_issues + * @param array $attribute_groups + * @param 1|2|4|8|16|32|40 $target + * @param array $suppressed_issues */ public static function analyze( SourceAnalyzer $source, @@ -80,7 +81,6 @@ public static function analyze( $context, $attribute_storage, $attribute, - $attribute_class_storage, $suppressed_issues, $storage instanceof ClassLikeStorage ? $storage : null ); @@ -119,14 +119,13 @@ public static function analyze( } /** - * @param array $suppressed_issues + * @param array $suppressed_issues */ private static function analyzeAttributeConstruction( SourceAnalyzer $source, Context $context, AttributeStorage $attribute_storage, Attribute $attribute, - ?ClassLikeStorage $attribute_class_storage, array $suppressed_issues, ?ClassLikeStorage $classlike_storage = null ): void { @@ -199,7 +198,7 @@ private static function analyzeAttributeConstruction( $source, new NodeDataProvider() ); - $statements_analyzer->addSuppressedIssues($suppressed_issues); + $statements_analyzer->addSuppressedIssues(array_values($suppressed_issues)); IssueBuffer::startRecording(); $statements_analyzer->analyze( @@ -219,7 +218,7 @@ private static function analyzeAttributeConstruction( } /** - * @param array $suppressed_issues + * @param array $suppressed_issues */ private static function getAttributeClassFlags( SourceAnalyzer $source, @@ -278,11 +277,11 @@ private static function getAttributeClassFlags( } /** - * @param list $attribute_groups + * @param iterable $attribute_groups * - * @return iterator + * @return Generator */ - private static function iterateAttributeNodes(array $attribute_groups): Generator + private static function iterateAttributeNodes(iterable $attribute_groups): Generator { foreach ($attribute_groups as $attribute_group) { foreach ($attribute_group->attrs as $attribute) { @@ -333,7 +332,7 @@ public static function analyzeGetAttributes( $arg = $args[0]; if ($arg->name !== null) { - for (; $arg !== null || $arg->name !== null && $arg->name->name !== "name"; $arg = array_shift($args)); + for (; !empty($args) && ($arg->name->name ?? null) !== "name"; $arg = array_shift($args)); if ($arg->name->name ?? null !== "name") { // No named argument for "name" parameter return; diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php index aea81f3fe8c..c3930b74cb8 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentsAnalyzer.php @@ -55,6 +55,7 @@ use function array_map; use function array_reverse; use function array_slice; +use function array_values; use function count; use function in_array; use function is_string; @@ -268,7 +269,7 @@ public static function analyze( || $method_id === "ReflectionParameter::getattributes" || $method_id === "ReflectionProperty::getattributes" ) { - AttributesAnalyzer::analyzeGetAttributes($statements_analyzer, $method_id, $args); + AttributesAnalyzer::analyzeGetAttributes($statements_analyzer, $method_id, array_values($args)); } return null;