diff --git a/build/target-repository/.github/workflows/along_other_packages.yaml b/build/target-repository/.github/workflows/along_other_packages.yaml index fb8e1544a19..10c04aad409 100644 --- a/build/target-repository/.github/workflows/along_other_packages.yaml +++ b/build/target-repository/.github/workflows/along_other_packages.yaml @@ -26,7 +26,7 @@ jobs: - name: 'Along PHPStan' - install: composer require phpstan/phpstan:^0.12.94 --dev --ansi + install: composer require phpstan/phpstan:^0.12.95 --dev --ansi name: "PHP ${{ matrix.php_version }}" diff --git a/build/target-repository/composer.json b/build/target-repository/composer.json index 7cec9b00717..c080414679f 100644 --- a/build/target-repository/composer.json +++ b/build/target-repository/composer.json @@ -7,7 +7,7 @@ ], "require": { "php": "^7.1|^8.0", - "phpstan/phpstan": "0.12.94" + "phpstan/phpstan": "0.12.95" }, "autoload": { "files": [ diff --git a/composer.json b/composer.json index d8de7bc720c..38301a5e940 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "nette/utils": "^3.2", "nikic/php-parser": "4.12.0", "phpstan/phpdoc-parser": "^0.5.5", - "phpstan/phpstan": "0.12.94", + "phpstan/phpstan": "0.12.95", "phpstan/phpstan-phpunit": "^0.12.21", "rector/extension-installer": "^0.11.0", "rector/rector-cakephp": "^0.11.3", diff --git a/phpstan.neon b/phpstan.neon index 84d3078285a..dfff48c0419 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -538,3 +538,15 @@ parameters: - rules/Php70/Rector/FuncCall/MultiDirnameRector.php - src/Application/FileProcessor.php - src/PhpParser/Node/BetterNodeFinder.php + + - + message: '#Parameter \#1 \$separator of function explode expects non\-empty\-string, string given#' + paths: + - rules/PSR4/FileRelocationResolver.php + - rules/Privatization/Rector/Class_/RepeatedLiteralToClassConstantRector.php + - rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php + + - + message: '#Parameter \#2 \$length of function str_split expects int<1, max\>, int given#' + paths: + - rules/Php74/Rector/LNumber/AddLiteralSeparatorToNumberRector.php diff --git a/rules/Privatization/TypeManipulator/NormalizeTypeToRespectArrayScalarType.php b/rules/Privatization/TypeManipulator/NormalizeTypeToRespectArrayScalarType.php index b14c4db8ffd..8b30a541b5d 100644 --- a/rules/Privatization/TypeManipulator/NormalizeTypeToRespectArrayScalarType.php +++ b/rules/Privatization/TypeManipulator/NormalizeTypeToRespectArrayScalarType.php @@ -5,7 +5,9 @@ declare(strict_types=1); namespace Rector\Privatization\TypeManipulator; use PhpParser\Node; +use PHPStan\Type\Accessory\NonEmptyArrayType; use PHPStan\Type\ArrayType; +use PHPStan\Type\IntersectionType; use PHPStan\Type\MixedType; use PHPStan\Type\Type; use PHPStan\Type\UnionType; @@ -36,9 +38,30 @@ final class NormalizeTypeToRespectArrayScalarType return new ArrayType($type, $type); } + if ($type instanceof ArrayType) { + return $this->resolveArrayType($type); + } + return $type; } + private function resolveArrayType(ArrayType $arrayType): ArrayType + { + $itemType = $arrayType->getItemType(); + if (! $itemType instanceof IntersectionType) { + return $arrayType; + } + + $types = $itemType->getTypes(); + foreach ($types as $key => $itemTypeType) { + if ($itemTypeType instanceof NonEmptyArrayType) { + unset($types[$key]); + } + } + + return new ArrayType($arrayType->getKeyType(), new IntersectionType($types)); + } + private function normalizeUnionType(UnionType $unionType): UnionType { $normalizedTypes = [];