Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spread list usages in Reflection, Scope, Type #3530

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Analyser/MutatingScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ public function getVariableType(string $variableName): Type

/**
* @api
* @return array<int, string>
* @return list<string>
*/
public function getDefinedVariables(): array
{
Expand All @@ -573,7 +573,7 @@ public function getDefinedVariables(): array

/**
* @api
* @return array<int, string>
* @return list<string>
*/
public function getMaybeDefinedVariables(): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Analyser/StatementResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getExitPoints(): array

/**
* @param class-string<Stmt\Continue_>|class-string<Stmt\Break_> $stmtClass
* @return StatementExitPoint[]
* @return list<StatementExitPoint>
*/
public function getExitPointsByType(string $stmtClass): array
{
Expand Down Expand Up @@ -115,7 +115,7 @@ public function getExitPointsByType(string $stmtClass): array
}

/**
* @return StatementExitPoint[]
* @return list<StatementExitPoint>
*/
public function getExitPointsForOuterLoop(): array
{
Expand Down
7 changes: 4 additions & 3 deletions src/PhpDoc/TypeNodeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
use Traversable;
use function array_key_exists;
use function array_map;
use function array_values;
use function count;
use function explode;
use function get_class;
Expand Down Expand Up @@ -927,7 +928,7 @@ private function resolveCallableTypeNode(CallableTypeNode $typeNode, NameScope $
$mainType = $this->resolve($typeNode->identifier, $nameScope);

$isVariadic = false;
$parameters = array_map(
$parameters = array_values(array_map(
function (CallableTypeParameterNode $parameterNode) use ($nameScope, &$isVariadic): NativeParameterReflection {
$isVariadic = $isVariadic || $parameterNode->isVariadic;
$parameterName = $parameterNode->parameterName;
Expand All @@ -945,7 +946,7 @@ function (CallableTypeParameterNode $parameterNode) use ($nameScope, &$isVariadi
);
},
$typeNode->parameters,
);
));

$returnType = $this->resolve($typeNode->returnType, $nameScope);

Expand Down Expand Up @@ -1196,7 +1197,7 @@ private function expandIntMaskToType(Type $type): ?Type
/**
* @api
* @param TypeNode[] $typeNodes
* @return Type[]
* @return list<Type>
*/
public function resolveMultiple(array $typeNodes, NameScope $nameScope): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Reflection/Annotations/AnnotationMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
final class AnnotationMethodReflection implements ExtendedMethodReflection
{

/** @var ExtendedFunctionVariant[]|null */
/** @var list<ExtendedFunctionVariant>|null */
private ?array $variants = null;

/**
* @param AnnotationsMethodParameterReflection[] $parameters
* @param list<AnnotationsMethodParameterReflection> $parameters
*/
public function __construct(
private string $name,
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/Callables/FunctionCallableVariant.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function getResolvedTemplateTypeMap(): TemplateTypeMap
}

/**
* @return array<int, ExtendedParameterReflection>
* @return list<ExtendedParameterReflection>
*/
public function getParameters(): array
{
Expand Down
20 changes: 10 additions & 10 deletions src/Reflection/ClassReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ final class ClassReflection

private false|ResolvedPhpDocBlock $traitContextResolvedPhpDocBlock = false;

/** @var ClassReflection[]|null */
/** @var array<string, ClassReflection>|null */
private ?array $cachedInterfaces = null;

private ClassReflection|false|null $cachedParentClass = false;
Expand Down Expand Up @@ -360,7 +360,7 @@ public function getClassHierarchyDistances(): array
}

/**
* @return ReflectionClass[]
* @return list<ReflectionClass>
*/
private function collectTraits(ReflectionClass|ReflectionEnum $class): array
{
Expand Down Expand Up @@ -845,7 +845,7 @@ public function implementsInterface(string $className): bool
}

/**
* @return ClassReflection[]
* @return list<ClassReflection>
*/
public function getParents(): array
{
Expand All @@ -860,7 +860,7 @@ public function getParents(): array
}

/**
* @return ClassReflection[]
* @return array<string, ClassReflection>
*/
public function getInterfaces(): array
{
Expand Down Expand Up @@ -894,7 +894,7 @@ public function getInterfaces(): array
}

/**
* @return ClassReflection[]
* @return array<string, ClassReflection>
*/
private function collectInterfaces(ClassReflection $interface): array
{
Expand All @@ -910,7 +910,7 @@ private function collectInterfaces(ClassReflection $interface): array
}

/**
* @return ClassReflection[]
* @return array<string, ClassReflection>
*/
public function getImmediateInterfaces(): array
{
Expand Down Expand Up @@ -1102,7 +1102,7 @@ public function hasTraitUse(string $traitName): bool
}

/**
* @return string[]
* @return list<string>
*/
private function getTraitNames(): array
{
Expand Down Expand Up @@ -1459,7 +1459,7 @@ public function varianceMapFromList(array $variances): TemplateTypeVarianceMap
return new TemplateTypeVarianceMap($map);
}

/** @return array<int, Type> */
/** @return list<Type> */
public function typeMapToList(TemplateTypeMap $typeMap): array
{
$resolvedPhpDoc = $this->getResolvedPhpDoc();
Expand All @@ -1475,7 +1475,7 @@ public function typeMapToList(TemplateTypeMap $typeMap): array
return $list;
}

/** @return array<int, TemplateTypeVariance> */
/** @return list<TemplateTypeVariance> */
public function varianceMapToList(TemplateTypeVarianceMap $varianceMap): array
{
$resolvedPhpDoc = $this->getResolvedPhpDoc();
Expand Down Expand Up @@ -1775,7 +1775,7 @@ public function getMethodTags(): array
}

/**
* @return array<Type>
* @return list<Type>
*/
public function getResolvedMixinTypes(): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/Reflection/Dummy/ChangedTypeMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ final class ChangedTypeMethodReflection implements ExtendedMethodReflection
{

/**
* @param ExtendedParametersAcceptor[] $variants
* @param ExtendedParametersAcceptor[]|null $namedArgumentsVariants
* @param list<ExtendedParametersAcceptor> $variants
* @param list<ExtendedParametersAcceptor>|null $namedArgumentsVariants
*/
public function __construct(private ClassReflection $declaringClass, private ExtendedMethodReflection $reflection, private array $variants, private ?array $namedArgumentsVariants)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/ExtendedCallableFunctionVariant.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class ExtendedCallableFunctionVariant extends ExtendedFunctionVariant impl
{

/**
* @param array<int, ExtendedParameterReflection> $parameters
* @param list<ExtendedParameterReflection> $parameters
* @param SimpleThrowPoint[] $throwPoints
* @param SimpleImpurePoint[] $impurePoints
* @param InvalidateExprNode[] $invalidateExpressions
Expand Down
6 changes: 3 additions & 3 deletions src/Reflection/ExtendedFunctionVariant.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ExtendedFunctionVariant extends FunctionVariant implements ExtendedParamet
{

/**
* @param array<int, ExtendedParameterReflection> $parameters
* @param list<ExtendedParameterReflection> $parameters
* @api
*/
public function __construct(
Expand All @@ -38,11 +38,11 @@ public function __construct(
}

/**
* @return array<int, ExtendedParameterReflection>
* @return list<ExtendedParameterReflection>
*/
public function getParameters(): array
{
/** @var array<int, ExtendedParameterReflection> $parameters */
/** @var list<ExtendedParameterReflection> $parameters */
$parameters = parent::getParameters();

return $parameters;
Expand Down
4 changes: 2 additions & 2 deletions src/Reflection/ExtendedMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface ExtendedMethodReflection extends MethodReflection
{

/**
* @return ExtendedParametersAcceptor[]
* @return list<ExtendedParametersAcceptor>
*/
public function getVariants(): array;

Expand All @@ -33,7 +33,7 @@ public function getVariants(): array;
public function getOnlyVariant(): ExtendedParametersAcceptor;

/**
* @return ExtendedParametersAcceptor[]|null
* @return list<ExtendedParametersAcceptor>|null
*/
public function getNamedArgumentsVariants(): ?array;

Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/ExtendedParametersAcceptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface ExtendedParametersAcceptor extends ParametersAcceptor
{

/**
* @return array<int, ExtendedParameterReflection>
* @return list<ExtendedParameterReflection>
*/
public function getParameters(): array;

Expand Down
4 changes: 2 additions & 2 deletions src/Reflection/FunctionReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function getName(): string;
public function getFileName(): ?string;

/**
* @return ExtendedParametersAcceptor[]
* @return list<ExtendedParametersAcceptor>
*/
public function getVariants(): array;

Expand All @@ -24,7 +24,7 @@ public function getVariants(): array;
public function getOnlyVariant(): ExtendedParametersAcceptor;

/**
* @return ExtendedParametersAcceptor[]|null
* @return list<ExtendedParametersAcceptor>|null
*/
public function getNamedArgumentsVariants(): ?array;

Expand Down
4 changes: 2 additions & 2 deletions src/Reflection/FunctionVariant.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FunctionVariant implements ParametersAcceptor

/**
* @api
* @param array<int, ParameterReflection> $parameters
* @param list<ParameterReflection> $parameters
*/
public function __construct(
private TemplateTypeMap $templateTypeMap,
Expand Down Expand Up @@ -46,7 +46,7 @@ public function getCallSiteVarianceMap(): TemplateTypeVarianceMap
}

/**
* @return array<int, ParameterReflection>
* @return list<ParameterReflection>
*/
public function getParameters(): array
{
Expand Down
3 changes: 0 additions & 3 deletions src/Reflection/InaccessibleMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ public function getCallSiteVarianceMap(): TemplateTypeVarianceMap
return TemplateTypeVarianceMap::createEmpty();
}

/**
* @return array<int, ParameterReflection>
*/
public function getParameters(): array
{
return [];
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/MethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function getName(): string;
public function getPrototype(): ClassMemberReflection;

/**
* @return ParametersAcceptor[]
* @return list<ParametersAcceptor>
*/
public function getVariants(): array;

Expand Down
4 changes: 2 additions & 2 deletions src/Reflection/Native/NativeFunctionReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ final class NativeFunctionReflection implements FunctionReflection
private TrinaryLogic $returnsByReference;

/**
* @param ExtendedParametersAcceptor[] $variants
* @param ExtendedParametersAcceptor[]|null $namedArgumentsVariants
* @param list<ExtendedParametersAcceptor> $variants
* @param list<ExtendedParametersAcceptor>|null $namedArgumentsVariants
*/
public function __construct(
private string $name,
Expand Down
4 changes: 2 additions & 2 deletions src/Reflection/Native/NativeMethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ final class NativeMethodReflection implements ExtendedMethodReflection
{

/**
* @param ExtendedParametersAcceptor[] $variants
* @param ExtendedParametersAcceptor[]|null $namedArgumentsVariants
* @param list<ExtendedParametersAcceptor> $variants
* @param list<ExtendedParametersAcceptor>|null $namedArgumentsVariants
*/
public function __construct(
private ReflectionProvider $reflectionProvider,
Expand Down
2 changes: 1 addition & 1 deletion src/Reflection/ParametersAcceptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function getTemplateTypeMap(): TemplateTypeMap;
public function getResolvedTemplateTypeMap(): TemplateTypeMap;

/**
* @return array<int, ParameterReflection>
* @return list<ParameterReflection>
*/
public function getParameters(): array;

Expand Down
Loading
Loading