Updated Rector to commit 7607b334736d241820f9f307423f6050801b46af

7607b33473 NullableCompareToNullRector: Don't trust phpdocs (#5225)
This commit is contained in:
Tomas Votruba 2023-11-06 09:13:25 +00:00
parent 5990b98c4e
commit 95582bf2b1
2 changed files with 12 additions and 22 deletions

View File

@ -15,6 +15,7 @@ use PHPStan\Type\IntegerType;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
use PHPStan\Type\StringType;
use PHPStan\Type\TypeCombinator;
use PHPStan\Type\UnionType;
use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
@ -68,35 +69,24 @@ CODE_SAMPLE
}
private function isNullableNonScalarType(Expr $expr) : bool
{
$staticType = $this->getType($expr);
if ($staticType instanceof MixedType) {
return \false;
}
if (!$staticType instanceof UnionType) {
return \false;
}
$nativeType = $this->nodeTypeResolver->getNativeType($expr);
// is non-nullable?
if ($staticType->isSuperTypeOf(new NullType())->no()) {
if (!TypeCombinator::containsNull($nativeType)) {
return \false;
}
if (!$nativeType instanceof UnionType) {
return \false;
}
// is array?
foreach ($staticType->getTypes() as $subType) {
foreach ($nativeType->getTypes() as $subType) {
if ($subType->isArray()->yes()) {
return \false;
}
}
// is string?
if ($staticType->isSuperTypeOf(new StringType())->yes()) {
$nativeType = TypeCombinator::removeNull($nativeType);
if ($nativeType->isScalar()->yes()) {
return \false;
}
// is number?
if ($staticType->isSuperTypeOf(new IntegerType())->yes()) {
return \false;
}
// is bool?
if ($staticType->isSuperTypeOf(new BooleanType())->yes()) {
return \false;
}
return !$staticType->isSuperTypeOf(new FloatType())->yes();
return \true;
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '8615d40f4c8acb58a000f5bc7e0d0a0cfd353b7f';
public const PACKAGE_VERSION = '7607b334736d241820f9f307423f6050801b46af';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-11-05 20:55:04';
public const RELEASE_DATE = '2023-11-06 16:09:43';
/**
* @var int
*/