Skip to content

Commit

Permalink
Updated Rector to commit 19863767c63503e19aed359d849fa55bbf3a1df9
Browse files Browse the repository at this point in the history
rectorphp/rector-src@1986376 [TypeDeclaration] Skip unitialized property on EmptyOnNullableObjectToInstanceOfRector (#5889)
  • Loading branch information
TomasVotruba committed May 17, 2024
1 parent 264e16f commit c6998bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@
use PhpParser\Node\Expr\Empty_;
use PhpParser\Node\Expr\Instanceof_;
use PhpParser\Node\Name;
use PHPStan\Analyser\Scope;
use PHPStan\Type\ObjectType;
use PHPStan\Type\TypeCombinator;
use PHPStan\Type\UnionType;
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
use Rector\Rector\AbstractRector;
use Rector\Rector\AbstractScopeAwareRector;
use Rector\StaticTypeMapper\StaticTypeMapper;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector\EmptyOnNullableObjectToInstanceOfRectorTest
*/
final class EmptyOnNullableObjectToInstanceOfRector extends AbstractRector
final class EmptyOnNullableObjectToInstanceOfRector extends AbstractScopeAwareRector
{
/**
* @readonly
Expand Down Expand Up @@ -68,8 +71,9 @@ public function getNodeTypes() : array
}
/**
* @param Empty_|BooleanNot $node
* @return null|\PhpParser\Node\Expr\Instanceof_|\PhpParser\Node\Expr\BooleanNot
*/
public function refactor(Node $node) : ?Node
public function refactorWithScope(Node $node, Scope $scope)
{
if ($node instanceof BooleanNot) {
if (!$node->expr instanceof Empty_) {
Expand All @@ -84,7 +88,11 @@ public function refactor(Node $node) : ?Node
if ($empty->expr instanceof ArrayDimFetch) {
return null;
}
$exprType = $this->nodeTypeResolver->getNativeType($empty->expr);
$exprType = $scope->getNativeType($empty->expr);
if (!$exprType instanceof UnionType) {
return null;
}
$exprType = TypeCombinator::removeNull($exprType);
if (!$exprType instanceof ObjectType) {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '2deccac9b501bc1aa09ba7e8bfe6271b73e5b8dc';
public const PACKAGE_VERSION = '19863767c63503e19aed359d849fa55bbf3a1df9';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-05-16 21:44:18';
public const RELEASE_DATE = '2024-05-17 09:53:42';
/**
* @var int
*/
Expand Down

0 comments on commit c6998bf

Please sign in to comment.