Skip to content
Closed
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
33 changes: 21 additions & 12 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,30 @@ parameters:

-
identifier: argument.type
message: '#(.*?) class\-string, string given#'
message: '#Parameter \#1 \$phpVersion of method Rector\\Config\\RectorConfig\:\:phpVersion\(\) expects 50200\|50300\|50400\|50500\|50600\|70000\|70100\|70200\|70300\|70400\|80000\|80100\|80200\|80300\|80400\|80500\|80600\|100000, 79999 given#'

# class name string resolved from AST/ObjectType, not statically provable as class-string
-
identifier: argument.type
message: '#Parameter \#1 \$phpVersion of method Rector\\Config\\RectorConfig\:\:phpVersion\(\) expects 50200\|50300\|50400\|50500\|50600\|70000\|70100\|70200\|70300\|70400\|80000\|80100\|80200\|80300\|80400\|80500\|80600\|100000, 79999 given#'
message: '#class\-string, string given#'
paths:
- rules/TypeDeclaration/PHPStan/ObjectTypeSpecifier.php
- rules/TypeDeclaration/Rector/FunctionLike/AddClosureParamTypeFromIterableMethodCallRector.php
- src/PhpParser/AstResolver.php
- src/StaticTypeMapper/ValueObject/Type/FullyQualifiedObjectType.php
- tests/BetterPhpDocParser/PhpDocParser/TagValueNodeReprint/TagValueNodeReprintTest.php

# getObjectClassNames() returns string[], semantically a class-string
-
identifier: return.type
message: '#should return class-string\|null but returns string#'
path: src/StaticTypeMapper/Resolver/ClassNameFromObjectTypeResolver.php

# deliberately widened token param on parser wrapper
-
identifier: argument.type
message: '#expects list<array\{string, int, int\}>, array<int, mixed> given#'
path: src/BetterPhpDocParser/ValueObject/Parser/BetterTokenIterator.php

# node vs stmts mix
-
Expand All @@ -116,11 +135,6 @@ parameters:
identifier: argument.type
message: '#Parameter \#3 \$nodeCallback of method PHPStan\\Analyser\\NodeScopeResolver\:\:processNodes\(\) expects callable\(PhpParser\\Node, PHPStan\\Analyser\\Scope\)\: void, callable\(PhpParser\\Node, PHPStan\\Analyser\\MutatingScope\)\: void given#'

# list vs array
-
identifier: argument.type
message: '#Parameter (.*?) expects list<(.*?)>, array<(.*?)> given#'

-
identifier: argument.type
paths:
Expand Down Expand Up @@ -254,11 +268,6 @@ parameters:
identifier: return.type
message: '#Method (.*?) should return 50200\|50300\|50400\|50500\|50600\|70000\|70100\|70200\|70300\|70400\|80000\|80100\|80200\|80300\|80400\|80500\|80600\|100000 but returns int#'

# from constant string
-
identifier: return.type
message: '#Method Rector\\.*::filterPolyfillPackages\(\) should return array\<#'

-
identifier: return.type
paths:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private function createNextClassConsts(array $consts, ClassConst $classConst): a
[$const],
$classConst->flags,
$classConst->getAttributes(),
$classConst->attrGroups,
array_values($classConst->attrGroups),
$classConst->type
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private function resolveKeyType(ConstantArrayType $constantArrayType): Type
return $uniqueKeyTypes[0];
}

return new UnionType($uniqueKeyTypes);
return new UnionType(array_values($uniqueKeyTypes));
}

return new MixedType();
Expand Down
2 changes: 1 addition & 1 deletion src/Application/RectorRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private function prepareRectors(): void
return;
}

$activeRectors = $this->phpVersionedFilter->filter($this->rectors);
$activeRectors = $this->phpVersionedFilter->filter(array_values($this->rectors));
$activeRectors = $this->composerPackageConstraintFilter->filter($activeRectors);

$this->activeRectors = $this->configurationRuleFilter->filter($activeRectors);
Expand Down
1 change: 0 additions & 1 deletion src/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,6 @@ public function getArrayItemNodeClassNames(): array
}

/**
* @param class-string $desiredClass
* @return DoctrineAnnotationTagValueNode[]
*/
public function findByAnnotationClass(string $desiredClass): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public function findDoctrineAnnotationsByClasses(PhpDocNode $phpDocNode, array $
}

/**
* @param class-string $desiredClass
* @return DoctrineAnnotationTagValueNode[]
*/
public function findDoctrineAnnotationsByClass(PhpDocNode $phpDocNode, string $desiredClass): array
Expand Down
7 changes: 3 additions & 4 deletions src/Php/PolyfillPackagesProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
use Nette\Utils\Json;
use Rector\Configuration\Option;
use Rector\Configuration\Parameter\SimpleParameterProvider;
use Rector\ValueObject\PolyfillPackage;

final class PolyfillPackagesProvider
{
/**
* @var null|array<int, PolyfillPackage::*>
* @var null|array<int, string>
*/
private null|array $cachedPolyfillPackages = null;

/**
* @return array<int, PolyfillPackage::*>
* @return array<int, string>
*/
public function provide(): array
{
Expand Down Expand Up @@ -48,7 +47,7 @@ public function provide(): array

/**
* @param array<string, string> $require
* @return array<int, PolyfillPackage::*>
* @return array<int, string>
*/
private function filterPolyfillPackages(array $require): array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

final class ClassNameFromObjectTypeResolver
{
/**
* @return class-string|null
*/
public static function resolve(Type $type): ?string
{
$objectClassNames = $type->getObjectClassNames();
Expand Down
Loading