This commit is contained in:
Tomas Votruba 2021-03-09 01:29:10 +01:00 committed by GitHub
parent 4d694008f6
commit 7f8d0d5af8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 4 deletions

View File

@ -152,7 +152,12 @@ final class TypeFactory
$flattenItemTypes = TypeUtils::flattenTypes($constantArrayType->getItemType());
foreach ($flattenItemTypes as $position => $nestedFlattenItemType) {
/** @var Type|null $nestedFlattenKeyType */
$nestedFlattenKeyType = $flattenKeyTypes[$position];
if ($nestedFlattenKeyType === null) {
$nestedFlattenKeyType = new MixedType();
}
$unwrappedTypes[] = new ArrayType($nestedFlattenKeyType, $nestedFlattenItemType);
}

View File

@ -636,3 +636,8 @@ parameters:
- packages/static-type-mapper/src/ValueObject/Type/FullyQualifiedGenericObjectType.php
- '#(.*?) class\-string, string given#'
-
message: '#Strict comparison using \=\=\= between PHPStan\\Type\\Type and null will always evaluate to false#'
paths:
- packages/node-type-resolver/src/PHPStan/Type/TypeFactory.php

View File

@ -10,6 +10,7 @@ use PhpParser\Node\Expr\StaticCall;
use PHPStan\Type\FloatType;
use PHPStan\Type\IntegerType;
use PHPStan\Type\StringType;
use PHPStan\Type\Type;
use Rector\Core\Rector\AbstractRector;
use Rector\Core\Util\StaticInstanceOf;
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
@ -34,7 +35,7 @@ final class AssertEqualsToSameRector extends AbstractRector
* - bool because this is taken care of AssertEqualsParameterToSpecificMethodsTypeRector
* - null because this is taken care of AssertEqualsParameterToSpecificMethodsTypeRector
*
* @var array<class-string<\PHPStan\Type\Type>>
* @var array<class-string<Type>>
*/
private const SCALAR_TYPES = [FloatType::class, IntegerType::class, StringType::class];

View File

@ -89,7 +89,7 @@ final class AssertTrueFalseToSpecificMethodRector extends AbstractRector
}
$firstArgumentValue = $node->args[0]->value;
if ($firstArgumentValue instanceof StaticCall || $firstArgumentValue instanceof MethodCall) {
if (! $firstArgumentValue instanceof FuncCall && ! $firstArgumentValue instanceof Empty_) {
return null;
}

View File

@ -110,10 +110,11 @@ CODE_SAMPLE
return null;
}
if (! $onlyStmt->expr instanceof PropertyFetch) {
$returnedExpr = $onlyStmt->expr;
if (! $returnedExpr instanceof PropertyFetch) {
return null;
}
return $onlyStmt->expr;
return $returnedExpr;
}
}