Skip to content

Commit

Permalink
Fix types.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrolGenhald committed Feb 24, 2022
1 parent 43764f0 commit 5f9a8c9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
23 changes: 11 additions & 12 deletions src/Psalm/Internal/Analyzer/AttributesAnalyzer.php
Expand Up @@ -25,6 +25,7 @@
use RuntimeException;

use function array_shift;
use function array_values;
use function assert;
use function count;
use function reset;
Expand All @@ -42,9 +43,9 @@ class AttributesAnalyzer
];

/**
* @param list<AttributeGroup> $attribute_groups
* @param 1|2|4|8|16|32 $target
* @param array<int, string> $suppressed_issues
* @param array<array-key, AttributeGroup> $attribute_groups
* @param 1|2|4|8|16|32|40 $target
* @param array<array-key, string> $suppressed_issues
*/
public static function analyze(
SourceAnalyzer $source,
Expand Down Expand Up @@ -80,7 +81,6 @@ public static function analyze(
$context,
$attribute_storage,
$attribute,
$attribute_class_storage,
$suppressed_issues,
$storage instanceof ClassLikeStorage ? $storage : null
);
Expand Down Expand Up @@ -119,14 +119,13 @@ public static function analyze(
}

/**
* @param array<int, string> $suppressed_issues
* @param array<array-key, string> $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 {
Expand Down Expand Up @@ -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(
Expand All @@ -219,7 +218,7 @@ private static function analyzeAttributeConstruction(
}

/**
* @param array<int, string> $suppressed_issues
* @param array<array-key, string> $suppressed_issues
*/
private static function getAttributeClassFlags(
SourceAnalyzer $source,
Expand Down Expand Up @@ -278,11 +277,11 @@ private static function getAttributeClassFlags(
}

/**
* @param list<AttributeGroup> $attribute_groups
* @param iterable<AttributeGroup> $attribute_groups
*
* @return iterator<int, Attribute>
* @return Generator<int, Attribute>
*/
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) {
Expand Down Expand Up @@ -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;
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5f9a8c9

Please sign in to comment.