mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-21 10:32:24 +00:00
Updated Rector to commit a27370519f4e17bf73f0d548e098de448895401d
a27370519f
[CodeQuality] Handle negated isset on IssetOnPropertyObjectToPropertyExistsRector on property not exists (#5206)
This commit is contained in:
parent
102128ffca
commit
f5adafb1c4
|
@ -7,6 +7,7 @@ use PhpParser\Node;
|
|||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
|
||||
use PhpParser\Node\Expr\BinaryOp\BooleanOr;
|
||||
use PhpParser\Node\Expr\BinaryOp\Identical;
|
||||
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||
use PhpParser\Node\Expr\BooleanNot;
|
||||
|
@ -121,7 +122,7 @@ CODE_SAMPLE
|
|||
continue;
|
||||
}
|
||||
if (!$classReflection->hasProperty($propertyFetchName) || $classReflection->isBuiltin()) {
|
||||
$newNodes[] = $this->replaceToPropertyExistsWithNullCheck($issetExpr->var, $propertyFetchName, $issetExpr);
|
||||
$newNodes[] = $this->replaceToPropertyExistsWithNullCheck($issetExpr->var, $propertyFetchName, $issetExpr, $isNegated);
|
||||
} elseif ($isNegated) {
|
||||
$newNodes[] = $this->createIdenticalToNull($issetExpr);
|
||||
} else {
|
||||
|
@ -130,10 +131,17 @@ CODE_SAMPLE
|
|||
}
|
||||
return $this->nodeFactory->createReturnBooleanAnd($newNodes);
|
||||
}
|
||||
private function replaceToPropertyExistsWithNullCheck(Expr $expr, string $property, PropertyFetch $propertyFetch) : BooleanAnd
|
||||
/**
|
||||
* @return \PhpParser\Node\Expr\BinaryOp\BooleanAnd|\PhpParser\Node\Expr\BinaryOp\BooleanOr
|
||||
*/
|
||||
private function replaceToPropertyExistsWithNullCheck(Expr $expr, string $property, PropertyFetch $propertyFetch, bool $isNegated)
|
||||
{
|
||||
$args = [new Arg($expr), new Arg(new String_($property))];
|
||||
$propertyExistsFuncCall = $this->nodeFactory->createFuncCall('property_exists', $args);
|
||||
if ($isNegated) {
|
||||
$booleanNot = new BooleanNot($propertyExistsFuncCall);
|
||||
return new BooleanOr($booleanNot, $this->createIdenticalToNull($propertyFetch));
|
||||
}
|
||||
return new BooleanAnd($propertyExistsFuncCall, $this->createNotIdenticalToNull($propertyFetch));
|
||||
}
|
||||
private function createNotIdenticalToNull(PropertyFetch $propertyFetch) : NotIdentical
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '89b3e62f82ad480b57f002096cc16af16d7ac597';
|
||||
public const PACKAGE_VERSION = 'a27370519f4e17bf73f0d548e098de448895401d';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-10-27 01:41:41';
|
||||
public const RELEASE_DATE = '2023-10-27 19:10:40';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
|
@ -15,6 +15,7 @@ use PhpParser\Node\Expr\Array_;
|
|||
use PhpParser\Node\Expr\ArrayItem;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
|
||||
use PhpParser\Node\Expr\BinaryOp\BooleanOr;
|
||||
use PhpParser\Node\Expr\BinaryOp\Concat;
|
||||
use PhpParser\Node\Expr\BinaryOp\Identical;
|
||||
use PhpParser\Node\Expr\BinaryOp\NotIdentical;
|
||||
|
@ -305,7 +306,7 @@ final class NodeFactory
|
|||
return $this->builderFactory->classConstFetch($className, $constantName);
|
||||
}
|
||||
/**
|
||||
* @param array<NotIdentical|BooleanAnd|Identical> $newNodes
|
||||
* @param array<NotIdentical|BooleanAnd|BooleanOr|Identical> $newNodes
|
||||
*/
|
||||
public function createReturnBooleanAnd(array $newNodes) : ?Expr
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user