Updated Rector to commit dce60231f7

dce60231f7 [TypeDeclaration][Php 8] Enable ReturnTypeDeclarationRector (#184)
This commit is contained in:
Tomas Votruba 2021-06-18 17:31:16 +00:00
parent 6736aed6b9
commit 281d0518a0
38 changed files with 157 additions and 102 deletions

View File

@ -3,7 +3,11 @@
declare (strict_types=1); declare (strict_types=1);
namespace Rector\BetterPhpDocParser\PhpDocParser; namespace Rector\BetterPhpDocParser\PhpDocParser;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFalseNode;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode;
use PHPStan\PhpDocParser\Lexer\Lexer; use PHPStan\PhpDocParser\Lexer\Lexer;
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
use Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser; use Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser;
use Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\PlainValueParser; use Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\PlainValueParser;
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator; use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
@ -45,7 +49,7 @@ final class StaticDoctrineAnnotationParser
} }
/** /**
* @see https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1215-L1224 * @see https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1215-L1224
* @return mixed|mixed[] * @return \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode|string|mixed[]|\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFalseNode|\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode|\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode|\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
*/ */
public function resolveAnnotationValue(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) public function resolveAnnotationValue(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator)
{ {
@ -57,6 +61,7 @@ final class StaticDoctrineAnnotationParser
return $this->parseValue($tokenIterator); return $this->parseValue($tokenIterator);
} }
// 2. assign key = value - mimics FieldAssignment() https://github.com/doctrine/annotations/blob/0cb0cd2950a5c6cdbf22adbe2bfd5fd1ea68588f/lib/Doctrine/Common/Annotations/DocParser.php#L1291-L1303 // 2. assign key = value - mimics FieldAssignment() https://github.com/doctrine/annotations/blob/0cb0cd2950a5c6cdbf22adbe2bfd5fd1ea68588f/lib/Doctrine/Common/Annotations/DocParser.php#L1291-L1303
/** @var int $key */
$key = $this->parseValue($tokenIterator); $key = $this->parseValue($tokenIterator);
$tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL); $tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL);
// mimics https://github.com/doctrine/annotations/blob/1.13.x/lib/Doctrine/Common/Annotations/DocParser.php#L1236-L1238 // mimics https://github.com/doctrine/annotations/blob/1.13.x/lib/Doctrine/Common/Annotations/DocParser.php#L1236-L1238
@ -68,7 +73,7 @@ final class StaticDoctrineAnnotationParser
} }
/** /**
* @see https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1051-L1079 * @see https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1051-L1079
* @return array<mixed, mixed> * @return array<mixed>
*/ */
private function resolveAnnotationValues(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : array private function resolveAnnotationValues(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : array
{ {
@ -91,7 +96,7 @@ final class StaticDoctrineAnnotationParser
return $values; return $values;
} }
/** /**
* @return bool|int|mixed|mixed[]|string * @return \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode|string|mixed[]|\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFalseNode|\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode|\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode|\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
*/ */
private function parseValue(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) private function parseValue(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator)
{ {

View File

@ -47,7 +47,7 @@ final class PlainValueParser
$this->arrayParser = $arrayParser; $this->arrayParser = $arrayParser;
} }
/** /**
* @return bool|int|mixed|string * @return string|mixed[]|\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFalseNode|\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode|\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode|\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
*/ */
public function parseValue(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) public function parseValue(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator)
{ {

View File

@ -422,7 +422,8 @@ final class NodeRepository
if (!$classReflection->hasMethod($arrayCallable->getMethod())) { if (!$classReflection->hasMethod($arrayCallable->getMethod())) {
return; return;
} }
$this->arrayCallablesByTypeAndMethod[$arrayCallable->getClass()][\strtolower($arrayCallable->getMethod())][] = $arrayCallable; $methodName = \strtolower($arrayCallable->getMethod());
$this->arrayCallablesByTypeAndMethod[$arrayCallable->getClass()][$methodName][] = $arrayCallable;
} }
private function addMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void private function addMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : void
{ {

View File

@ -9,10 +9,12 @@ use PHPStan\Type\FloatType;
use PHPStan\Type\IntegerType; use PHPStan\Type\IntegerType;
use PHPStan\Type\MixedType; use PHPStan\Type\MixedType;
use PHPStan\Type\StringType; use PHPStan\Type\StringType;
use PHPStan\Type\Type;
final class IdentifierTypeResolver final class IdentifierTypeResolver
{ {
public function resolve(\PhpParser\Node\Identifier $identifier) : \PHPStan\Type\Type /**
* @return \PHPStan\Type\StringType|\PHPStan\Type\BooleanType|\PHPStan\Type\IntegerType|\PHPStan\Type\FloatType|\PHPStan\Type\MixedType
*/
public function resolve(\PhpParser\Node\Identifier $identifier)
{ {
if ($identifier->toLowerString() === 'string') { if ($identifier->toLowerString() === 'string') {
return new \PHPStan\Type\StringType(); return new \PHPStan\Type\StringType();

View File

@ -45,9 +45,9 @@ final class NameTypeResolver implements \Rector\NodeTypeResolver\Contract\NodeTy
return new \PHPStan\Type\ObjectType($fullyQualifiedName); return new \PHPStan\Type\ObjectType($fullyQualifiedName);
} }
/** /**
* @return ObjectType|UnionType|MixedType * @return \PHPStan\Type\MixedType|\PHPStan\Type\ObjectType|\PHPStan\Type\UnionType
*/ */
private function resolveParent(\PhpParser\Node\Name $name) : \PHPStan\Type\Type private function resolveParent(\PhpParser\Node\Name $name)
{ {
$className = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NAME); $className = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NAME);
if ($className === null) { if ($className === null) {

View File

@ -15,7 +15,6 @@ use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\Constant\ConstantStringType; use PHPStan\Type\Constant\ConstantStringType;
use PHPStan\Type\Generic\GenericClassStringType; use PHPStan\Type\Generic\GenericClassStringType;
use PHPStan\Type\ObjectType; use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use PHPStan\Type\UnionType; use PHPStan\Type\UnionType;
use Rector\Core\Contract\Rector\RectorInterface; use Rector\Core\Contract\Rector\RectorInterface;
use Rector\NodeTypeResolver\NodeTypeCorrector\GenericClassStringTypeCorrector; use Rector\NodeTypeResolver\NodeTypeCorrector\GenericClassStringTypeCorrector;
@ -56,9 +55,9 @@ final class UnionTypeCommonTypeNarrower
return null; return null;
} }
/** /**
* @return GenericClassStringType|UnionType * @return \PHPStan\Type\UnionType|\PHPStan\Type\Generic\GenericClassStringType
*/ */
public function narrowToGenericClassStringType(\PHPStan\Type\UnionType $unionType) : \PHPStan\Type\Type public function narrowToGenericClassStringType(\PHPStan\Type\UnionType $unionType)
{ {
$availableTypes = []; $availableTypes = [];
foreach ($unionType->getTypes() as $unionedType) { foreach ($unionType->getTypes() as $unionedType) {

View File

@ -12,7 +12,6 @@ use PHPStan\Type\IterableType;
use PHPStan\Type\MixedType; use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType; use PHPStan\Type\ObjectType;
use PHPStan\Type\StaticType; use PHPStan\Type\StaticType;
use PHPStan\Type\SubtractableType;
use PHPStan\Type\Type; use PHPStan\Type\Type;
use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver; use Rector\NodeCollector\ScopeResolver\ParentClassScopeResolver;
use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\Node\AttributeKey;
@ -79,7 +78,10 @@ final class IdentifierTypeMapper implements \Rector\StaticTypeMapper\Contract\Ph
$objectType = new \PHPStan\Type\ObjectType($typeNode->name); $objectType = new \PHPStan\Type\ObjectType($typeNode->name);
return $this->objectTypeSpecifier->narrowToFullyQualifiedOrAliasedObjectType($node, $objectType); return $this->objectTypeSpecifier->narrowToFullyQualifiedOrAliasedObjectType($node, $objectType);
} }
private function mapSelf(\PhpParser\Node $node) : \PHPStan\Type\SubtractableType /**
* @return \PHPStan\Type\MixedType|\Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType
*/
private function mapSelf(\PhpParser\Node $node)
{ {
/** @var string|null $className */ /** @var string|null $className */
$className = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NAME); $className = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NAME);
@ -89,7 +91,10 @@ final class IdentifierTypeMapper implements \Rector\StaticTypeMapper\Contract\Ph
} }
return new \Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType($className); return new \Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType($className);
} }
private function mapParent(\PhpParser\Node $node) : \PHPStan\Type\Type /**
* @return \Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType|\PHPStan\Type\MixedType
*/
private function mapParent(\PhpParser\Node $node)
{ {
$parentClassName = $this->parentClassScopeResolver->resolveParentClassName($node); $parentClassName = $this->parentClassScopeResolver->resolveParentClassName($node);
if ($parentClassName !== null) { if ($parentClassName !== null) {
@ -97,7 +102,10 @@ final class IdentifierTypeMapper implements \Rector\StaticTypeMapper\Contract\Ph
} }
return new \PHPStan\Type\MixedType(); return new \PHPStan\Type\MixedType();
} }
private function mapStatic(\PhpParser\Node $node) : \PHPStan\Type\Type /**
* @return \PHPStan\Type\MixedType|\PHPStan\Type\StaticType
*/
private function mapStatic(\PhpParser\Node $node)
{ {
/** @var string|null $className */ /** @var string|null $className */
$className = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NAME); $className = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NAME);

View File

@ -65,7 +65,10 @@ final class NameNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParse
$oldToNewClasses = $this->renamedClassesCollector->getOldToNewClasses(); $oldToNewClasses = $this->renamedClassesCollector->getOldToNewClasses();
return \in_array($name, $oldToNewClasses, \true); return \in_array($name, $oldToNewClasses, \true);
} }
private function createClassReferenceType(\PhpParser\Node\Name $name, string $reference) : \PHPStan\Type\Type /**
* @return \PHPStan\Type\MixedType|\PHPStan\Type\StaticType|\PHPStan\Type\ThisType
*/
private function createClassReferenceType(\PhpParser\Node\Name $name, string $reference)
{ {
$className = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NAME); $className = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CLASS_NAME);
if ($className === null) { if ($className === null) {
@ -80,7 +83,10 @@ final class NameNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParse
} }
return new \PHPStan\Type\ThisType($className); return new \PHPStan\Type\ThisType($className);
} }
private function createScalarType(string $name) : \PHPStan\Type\Type /**
* @return \PHPStan\Type\ArrayType|\PHPStan\Type\IntegerType|\PHPStan\Type\FloatType|\PHPStan\Type\StringType|\PHPStan\Type\Constant\ConstantBooleanType|\PHPStan\Type\BooleanType|\PHPStan\Type\MixedType
*/
private function createScalarType(string $name)
{ {
if ($name === 'array') { if ($name === 'array') {
return new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType()); return new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType());

View File

@ -5,7 +5,6 @@ namespace Rector\CodeQuality\Rector\Concat;
use RectorPrefix20210618\Nette\Utils\Strings; use RectorPrefix20210618\Nette\Utils\Strings;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp\Concat; use PhpParser\Node\Expr\BinaryOp\Concat;
use PhpParser\Node\Scalar\String_; use PhpParser\Node\Scalar\String_;
use Rector\Core\Rector\AbstractRector; use Rector\Core\Rector\AbstractRector;
@ -78,9 +77,9 @@ CODE_SAMPLE
return !$parent instanceof \PhpParser\Node\Expr\BinaryOp\Concat; return !$parent instanceof \PhpParser\Node\Expr\BinaryOp\Concat;
} }
/** /**
* @return Concat|String_ * @return \PhpParser\Node\Expr\BinaryOp\Concat|\PhpParser\Node\Scalar\String_
*/ */
private function joinConcatIfStrings(\PhpParser\Node\Expr\BinaryOp\Concat $node) : \PhpParser\Node\Expr private function joinConcatIfStrings(\PhpParser\Node\Expr\BinaryOp\Concat $node)
{ {
$concat = clone $node; $concat = clone $node;
if ($concat->left instanceof \PhpParser\Node\Expr\BinaryOp\Concat) { if ($concat->left instanceof \PhpParser\Node\Expr\BinaryOp\Concat) {

View File

@ -136,9 +136,9 @@ CODE_SAMPLE
return null; return null;
} }
/** /**
* @return Identical|Greater * @return \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\Greater
*/ */
private function resolveCount(bool $isNegated, \PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr\BinaryOp private function resolveCount(bool $isNegated, \PhpParser\Node\Expr\FuncCall $funcCall)
{ {
$lNumber = new \PhpParser\Node\Scalar\LNumber(0); $lNumber = new \PhpParser\Node\Scalar\LNumber(0);
// compare === 0, assumption // compare === 0, assumption
@ -163,9 +163,9 @@ CODE_SAMPLE
return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $array); return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $array);
} }
/** /**
* @return Identical|NotIdentical * @return \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical
*/ */
private function resolveString(bool $isNegated, \PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr\BinaryOp private function resolveString(bool $isNegated, \PhpParser\Node\Expr $expr)
{ {
$string = new \PhpParser\Node\Scalar\String_(''); $string = new \PhpParser\Node\Scalar\String_('');
// compare === '' // compare === ''
@ -175,9 +175,9 @@ CODE_SAMPLE
return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $string); return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $string);
} }
/** /**
* @return Identical|NotIdentical * @return \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical
*/ */
private function resolveInteger(bool $isNegated, \PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr\BinaryOp private function resolveInteger(bool $isNegated, \PhpParser\Node\Expr $expr)
{ {
$lNumber = new \PhpParser\Node\Scalar\LNumber(0); $lNumber = new \PhpParser\Node\Scalar\LNumber(0);
if ($isNegated) { if ($isNegated) {
@ -185,7 +185,10 @@ CODE_SAMPLE
} }
return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $lNumber); return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $lNumber);
} }
private function resolveFloat(bool $isNegated, \PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr\BinaryOp /**
* @return \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical
*/
private function resolveFloat(bool $isNegated, \PhpParser\Node\Expr $expr)
{ {
$dNumber = new \PhpParser\Node\Scalar\DNumber(0.0); $dNumber = new \PhpParser\Node\Scalar\DNumber(0.0);
if ($isNegated) { if ($isNegated) {
@ -194,9 +197,9 @@ CODE_SAMPLE
return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $dNumber); return new \PhpParser\Node\Expr\BinaryOp\NotIdentical($expr, $dNumber);
} }
/** /**
* @return Identical|NotIdentical * @return \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\BinaryOp\NotIdentical
*/ */
private function resolveNullable(bool $isNegated, \PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr\BinaryOp private function resolveNullable(bool $isNegated, \PhpParser\Node\Expr $expr)
{ {
$constFetch = $this->nodeFactory->createNull(); $constFetch = $this->nodeFactory->createNull();
if ($isNegated) { if ($isNegated) {

View File

@ -96,7 +96,10 @@ CODE_SAMPLE
} }
return $expr->name->toString() === 'PHP_VERSION'; return $expr->name->toString() === 'PHP_VERSION';
} }
private function getNewNodeForArg(\PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr /**
* @return \PhpParser\Node\Expr\ConstFetch|\PhpParser\Node\Scalar\LNumber
*/
private function getNewNodeForArg(\PhpParser\Node\Expr $expr)
{ {
if ($this->isPhpVersionConstant($expr)) { if ($this->isPhpVersionConstant($expr)) {
return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('PHP_VERSION_ID')); return new \PhpParser\Node\Expr\ConstFetch(new \PhpParser\Node\Name('PHP_VERSION_ID'));

View File

@ -83,9 +83,10 @@ CODE_SAMPLE
return $node instanceof \PhpParser\Node\Stmt\Expression; return $node instanceof \PhpParser\Node\Stmt\Expression;
} }
/** /**
* @param PostInc|PostDec $node * @param \PhpParser\Node\Expr\PostInc|\PhpParser\Node\Expr\PostDec $node
* @return \PhpParser\Node\Expr\PreInc|\PhpParser\Node\Expr\PreDec
*/ */
private function processPrePost(\PhpParser\Node $node) : \PhpParser\Node\Expr private function processPrePost($node)
{ {
if ($node instanceof \PhpParser\Node\Expr\PostInc) { if ($node instanceof \PhpParser\Node\Expr\PostInc) {
return new \PhpParser\Node\Expr\PreInc($node->var); return new \PhpParser\Node\Expr\PreInc($node->var);
@ -93,9 +94,9 @@ CODE_SAMPLE
return new \PhpParser\Node\Expr\PreDec($node->var); return new \PhpParser\Node\Expr\PreDec($node->var);
} }
/** /**
* @param PostInc|PostDec $node * @param \PhpParser\Node\Expr\PostInc|\PhpParser\Node\Expr\PostDec $node
*/ */
private function processPreArray(\PhpParser\Node $node, \PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : ?\PhpParser\Node\Expr private function processPreArray($node, \PhpParser\Node\Expr\ArrayDimFetch $arrayDimFetch) : ?\PhpParser\Node\Expr
{ {
$parentOfArrayDimFetch = $arrayDimFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); $parentOfArrayDimFetch = $arrayDimFetch->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
if (!$this->isAnExpression($parentOfArrayDimFetch)) { if (!$this->isAnExpression($parentOfArrayDimFetch)) {
@ -107,8 +108,9 @@ CODE_SAMPLE
} }
/** /**
* @param PostInc|PostDec $node * @param PostInc|PostDec $node
* @return \PhpParser\Node\Expr\PreDec|\PhpParser\Node\Expr\PreInc
*/ */
private function processPreFor(\PhpParser\Node $node, \PhpParser\Node\Stmt\For_ $for) : \PhpParser\Node\Expr private function processPreFor(\PhpParser\Node $node, \PhpParser\Node\Stmt\For_ $for)
{ {
$for->loop = [$this->processPrePost($node)]; $for->loop = [$this->processPrePost($node)];
return $for->loop[0]; return $for->loop[0];

View File

@ -25,9 +25,9 @@ final class NameAndParent
$this->parentNode = $parentNode; $this->parentNode = $parentNode;
} }
/** /**
* @return Name|Identifier * @return \PhpParser\Node\Identifier|\PhpParser\Node\Name
*/ */
public function getNameNode() : \PhpParser\Node public function getNameNode()
{ {
return $this->nameNode; return $this->nameNode;
} }

View File

@ -4,9 +4,9 @@ declare (strict_types=1);
namespace Rector\DeadCode\Rector\MethodCall; namespace Rector\DeadCode\Rector\MethodCall;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\ArrowFunction; use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\ClassMethod;
@ -117,7 +117,10 @@ CODE_SAMPLE
} }
return (array) $classMethod->stmts !== []; return (array) $classMethod->stmts !== [];
} }
private function processArrowFunction(\PhpParser\Node\Expr\ArrowFunction $arrowFunction, \PhpParser\Node\Expr\MethodCall $methodCall) : \PhpParser\Node\Expr /**
* @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\ConstFetch
*/
private function processArrowFunction(\PhpParser\Node\Expr\ArrowFunction $arrowFunction, \PhpParser\Node\Expr\MethodCall $methodCall)
{ {
$parentOfParent = $arrowFunction->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); $parentOfParent = $arrowFunction->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
if ($parentOfParent instanceof \PhpParser\Node\Stmt\Expression) { if ($parentOfParent instanceof \PhpParser\Node\Stmt\Expression) {

View File

@ -8,6 +8,7 @@ use PhpParser\Node\Expr;
use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\New_; use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Return_; use PhpParser\Node\Stmt\Return_;
use PhpParser\NodeFinder; use PhpParser\NodeFinder;
@ -171,7 +172,10 @@ final class FluentChainMethodCallNodeAnalyzer
} }
return $variableType->isSuperTypeOf($type)->yes(); return $variableType->isSuperTypeOf($type)->yes();
} }
public function resolveRootExpr(\PhpParser\Node\Expr\MethodCall $methodCall) : \PhpParser\Node /**
* @return \PhpParser\Node\Expr|\PhpParser\Node\Name
*/
public function resolveRootExpr(\PhpParser\Node\Expr\MethodCall $methodCall)
{ {
$callerNode = $methodCall->var; $callerNode = $methodCall->var;
while ($callerNode instanceof \PhpParser\Node\Expr\MethodCall || $callerNode instanceof \PhpParser\Node\Expr\StaticCall) { while ($callerNode instanceof \PhpParser\Node\Expr\MethodCall || $callerNode instanceof \PhpParser\Node\Expr\StaticCall) {

View File

@ -136,8 +136,9 @@ CODE_SAMPLE
/** /**
* @param MethodCall|StaticCall $node * @param MethodCall|StaticCall $node
* @param Arg[] $args * @param Arg[] $args
* @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall
*/ */
private function processRemoveNamedArgument(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node $node, array $args) : \PhpParser\Node\Expr private function processRemoveNamedArgument(\PhpParser\Node\Stmt\ClassMethod $classMethod, \PhpParser\Node $node, array $args)
{ {
$params = $classMethod->params; $params = $classMethod->params;
/** @var Arg[] $newArgs */ /** @var Arg[] $newArgs */

View File

@ -79,7 +79,10 @@ CODE_SAMPLE
$funcCall->args[0]->value = $this->joinStringWithNode('DROP DATABASE', $funcCall->args[0]->value); $funcCall->args[0]->value = $this->joinStringWithNode('DROP DATABASE', $funcCall->args[0]->value);
return $funcCall; return $funcCall;
} }
private function joinStringWithNode(string $string, \PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr /**
* @return \PhpParser\Node\Scalar\String_|\PhpParser\Node\Expr\BinaryOp\Concat
*/
private function joinStringWithNode(string $string, \PhpParser\Node\Expr $expr)
{ {
if ($expr instanceof \PhpParser\Node\Scalar\String_) { if ($expr instanceof \PhpParser\Node\Scalar\String_) {
return new \PhpParser\Node\Scalar\String_($string . ' ' . $expr->value); return new \PhpParser\Node\Scalar\String_($string . ' ' . $expr->value);

View File

@ -59,7 +59,10 @@ CODE_SAMPLE
$node->args[0]->value = $this->joinStringWithNode('p:', $node->args[0]->value); $node->args[0]->value = $this->joinStringWithNode('p:', $node->args[0]->value);
return $node; return $node;
} }
private function joinStringWithNode(string $string, \PhpParser\Node\Expr $expr) : \PhpParser\Node\Expr /**
* @return \PhpParser\Node\Scalar\String_|\PhpParser\Node\Expr\BinaryOp\Concat
*/
private function joinStringWithNode(string $string, \PhpParser\Node\Expr $expr)
{ {
if ($expr instanceof \PhpParser\Node\Scalar\String_) { if ($expr instanceof \PhpParser\Node\Scalar\String_) {
return new \PhpParser\Node\Scalar\String_($string . $expr->value); return new \PhpParser\Node\Scalar\String_($string . $expr->value);

View File

@ -52,9 +52,9 @@ final class VariableAndCallAssign
return $this->variable; return $this->variable;
} }
/** /**
* @return FuncCall|StaticCall|MethodCall * @return \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall
*/ */
public function getCall() : \PhpParser\Node\Expr public function getCall()
{ {
return $this->call; return $this->call;
} }
@ -63,9 +63,9 @@ final class VariableAndCallAssign
return $this->variableName; return $this->variableName;
} }
/** /**
* @return ClassMethod|Function_|Closure * @return \PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_
*/ */
public function getFunctionLike() : \PhpParser\Node\FunctionLike public function getFunctionLike()
{ {
return $this->functionLike; return $this->functionLike;
} }

View File

@ -46,9 +46,9 @@ final class VariableAndCallForeach
return $this->variable; return $this->variable;
} }
/** /**
* @return FuncCall|StaticCall|MethodCall * @return \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall
*/ */
public function getCall() : \PhpParser\Node\Expr public function getCall()
{ {
return $this->call; return $this->call;
} }
@ -57,9 +57,9 @@ final class VariableAndCallForeach
return $this->variableName; return $this->variableName;
} }
/** /**
* @return ClassMethod|Function_|Closure * @return \PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_
*/ */
public function getFunctionLike() : \PhpParser\Node\FunctionLike public function getFunctionLike()
{ {
return $this->functionLike; return $this->functionLike;
} }

View File

@ -6,7 +6,6 @@ namespace Rector\Php52\Rector\Switch_;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Expr\Variable; use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\LNumber; use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Break_; use PhpParser\Node\Stmt\Break_;
use PhpParser\Node\Stmt\Continue_; use PhpParser\Node\Stmt\Continue_;
use PhpParser\Node\Stmt\Switch_; use PhpParser\Node\Stmt\Switch_;
@ -73,7 +72,10 @@ CODE_SAMPLE
} }
return $node; return $node;
} }
private function processContinueStatement(\PhpParser\Node\Stmt\Continue_ $continue) : \PhpParser\Node\Stmt /**
* @return \PhpParser\Node\Stmt\Break_|\PhpParser\Node\Stmt\Continue_
*/
private function processContinueStatement(\PhpParser\Node\Stmt\Continue_ $continue)
{ {
if ($continue->num === null) { if ($continue->num === null) {
return new \PhpParser\Node\Stmt\Break_(); return new \PhpParser\Node\Stmt\Break_();
@ -88,7 +90,10 @@ CODE_SAMPLE
} }
return $continue; return $continue;
} }
private function processVariableNum(\PhpParser\Node\Stmt\Continue_ $continue, \PhpParser\Node\Expr\Variable $numVariable) : \PhpParser\Node\Stmt /**
* @return \PhpParser\Node\Stmt\Continue_|\PhpParser\Node\Stmt\Break_
*/
private function processVariableNum(\PhpParser\Node\Stmt\Continue_ $continue, \PhpParser\Node\Expr\Variable $numVariable)
{ {
$staticType = $this->getStaticType($numVariable); $staticType = $this->getStaticType($numVariable);
if (!$staticType instanceof \PHPStan\Type\ConstantType) { if (!$staticType instanceof \PHPStan\Type\ConstantType) {

View File

@ -4,7 +4,6 @@ declare (strict_types=1);
namespace Rector\Php70\ValueObject; namespace Rector\Php70\ValueObject;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\ArrayDimFetch; use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\AssignOp; use PhpParser\Node\Expr\AssignOp;
@ -32,16 +31,16 @@ final class VariableAssignPair
$this->assign = $assign; $this->assign = $assign;
} }
/** /**
* @return Variable|ArrayDimFetch|PropertyFetch|StaticPropertyFetch * @return \PhpParser\Node\Expr\ArrayDimFetch|\PhpParser\Node\Expr\PropertyFetch|\PhpParser\Node\Expr\StaticPropertyFetch|\PhpParser\Node\Expr\Variable
*/ */
public function getVariable() : \PhpParser\Node\Expr public function getVariable()
{ {
return $this->variable; return $this->variable;
} }
/** /**
* @return Assign|AssignOp|AssignRef * @return \PhpParser\Node\Expr\Assign|\PhpParser\Node\Expr\AssignOp|\PhpParser\Node\Expr\AssignRef
*/ */
public function getAssign() : \PhpParser\Node\Expr public function getAssign()
{ {
return $this->assign; return $this->assign;
} }

View File

@ -4,7 +4,6 @@ declare (strict_types=1);
namespace Rector\Php80\NodeFactory; namespace Rector\Php80\NodeFactory;
use PhpParser\Node\Arg; use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BooleanNot; use PhpParser\Node\Expr\BooleanNot;
use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Name; use PhpParser\Node\Name;
@ -12,9 +11,9 @@ use Rector\Php80\ValueObject\StrStartsWith;
final class StrStartsWithFuncCallFactory final class StrStartsWithFuncCallFactory
{ {
/** /**
* @return FuncCall|BooleanNot * @return \PhpParser\Node\Expr\FuncCall|\PhpParser\Node\Expr\BooleanNot
*/ */
public function createStrStartsWith(\Rector\Php80\ValueObject\StrStartsWith $strStartsWith) : \PhpParser\Node\Expr public function createStrStartsWith(\Rector\Php80\ValueObject\StrStartsWith $strStartsWith)
{ {
$args = [new \PhpParser\Node\Arg($strStartsWith->getHaystackExpr()), new \PhpParser\Node\Arg($strStartsWith->getNeedleExpr())]; $args = [new \PhpParser\Node\Arg($strStartsWith->getHaystackExpr()), new \PhpParser\Node\Arg($strStartsWith->getNeedleExpr())];
$funcCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('str_starts_with'), $args); $funcCall = new \PhpParser\Node\Expr\FuncCall(new \PhpParser\Node\Name('str_starts_with'), $args);

View File

@ -260,7 +260,10 @@ final class TokenManipulator
} }
return \false; return \false;
} }
private function matchParentNodeInCaseOfIdenticalTrue(\PhpParser\Node\Expr\FuncCall $funcCall) : \PhpParser\Node\Expr /**
* @return \PhpParser\Node\Expr\BinaryOp\Identical|\PhpParser\Node\Expr\FuncCall
*/
private function matchParentNodeInCaseOfIdenticalTrue(\PhpParser\Node\Expr\FuncCall $funcCall)
{ {
$parentNode = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); $parentNode = $funcCall->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
if ($parentNode instanceof \PhpParser\Node\Expr\BinaryOp\Identical) { if ($parentNode instanceof \PhpParser\Node\Expr\BinaryOp\Identical) {

View File

@ -3,7 +3,6 @@
declare (strict_types=1); declare (strict_types=1);
namespace Rector\Transform\NodeAnalyzer; namespace Rector\Transform\NodeAnalyzer;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\Variable; use PhpParser\Node\Expr\Variable;
@ -55,9 +54,9 @@ final class FuncCallStaticCallToMethodCallAnalyzer
} }
/** /**
* @param ClassMethod|Function_ $functionLike * @param ClassMethod|Function_ $functionLike
* @return MethodCall|PropertyFetch|Variable * @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\PropertyFetch|\PhpParser\Node\Expr\Variable
*/ */
public function matchTypeProvidingExpr(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\FunctionLike $functionLike, \PHPStan\Type\ObjectType $objectType) : \PhpParser\Node\Expr public function matchTypeProvidingExpr(\PhpParser\Node\Stmt\Class_ $class, \PhpParser\Node\FunctionLike $functionLike, \PHPStan\Type\ObjectType $objectType)
{ {
$expr = $this->typeProvidingExprFromClassResolver->resolveTypeProvidingExprFromClass($class, $functionLike, $objectType); $expr = $this->typeProvidingExprFromClassResolver->resolveTypeProvidingExprFromClass($class, $functionLike, $objectType);
if ($expr !== null) { if ($expr !== null) {

View File

@ -6,7 +6,6 @@ namespace Rector\Transform\Rector\FileWithoutNamespace;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\Namespace_; use PhpParser\Node\Stmt\Namespace_;
@ -146,9 +145,9 @@ CODE_SAMPLE
} }
/** /**
* @param Namespace_|FileWithoutNamespace $node * @param Namespace_|FileWithoutNamespace $node
* @return Namespace_|Class_ * @return \PhpParser\Node\Stmt\Namespace_|\PhpParser\Node\Stmt\Class_
*/ */
private function resolveNodeToPrint(\PhpParser\Node $node, \PhpParser\Node\Stmt\Class_ $class) : \PhpParser\Node\Stmt private function resolveNodeToPrint(\PhpParser\Node $node, \PhpParser\Node\Stmt\Class_ $class)
{ {
if ($node instanceof \PhpParser\Node\Stmt\Namespace_) { if ($node instanceof \PhpParser\Node\Stmt\Namespace_) {
return new \PhpParser\Node\Stmt\Namespace_($node->name, [$class]); return new \PhpParser\Node\Stmt\Namespace_($node->name, [$class]);

View File

@ -4,7 +4,6 @@ declare (strict_types=1);
namespace Rector\Transform\Rector\FuncCall; namespace Rector\Transform\Rector\FuncCall;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Expr\PropertyFetch;
@ -181,9 +180,9 @@ CODE_SAMPLE
return $this->createMethodCallArrayFunctionToMethodCall($funcCall, $arrayFuncCallToMethodCall, $propertyFetch); return $this->createMethodCallArrayFunctionToMethodCall($funcCall, $arrayFuncCallToMethodCall, $propertyFetch);
} }
/** /**
* @return PropertyFetch|MethodCall * @return \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\PropertyFetch
*/ */
private function refactorEmptyFuncCallArgs(\Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall $argumentFuncCallToMethodCall, \PhpParser\Node\Expr\PropertyFetch $propertyFetch) : \PhpParser\Node\Expr private function refactorEmptyFuncCallArgs(\Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall $argumentFuncCallToMethodCall, \PhpParser\Node\Expr\PropertyFetch $propertyFetch)
{ {
if ($argumentFuncCallToMethodCall->getMethodIfNoArgs()) { if ($argumentFuncCallToMethodCall->getMethodIfNoArgs()) {
$methodName = $argumentFuncCallToMethodCall->getMethodIfNoArgs(); $methodName = $argumentFuncCallToMethodCall->getMethodIfNoArgs();

View File

@ -13,7 +13,6 @@ use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ReflectionProvider; use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\MixedType; use PHPStan\Type\MixedType;
use PHPStan\Type\ObjectType; use PHPStan\Type\ObjectType;
use PHPStan\Type\SubtractableType;
use PHPStan\Type\Type; use PHPStan\Type\Type;
use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType;
@ -30,9 +29,9 @@ final class ObjectTypeSpecifier
$this->reflectionProvider = $reflectionProvider; $this->reflectionProvider = $reflectionProvider;
} }
/** /**
* @return AliasedObjectType|FullyQualifiedObjectType|ObjectType|MixedType * @return \PHPStan\Type\ObjectType|\Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType|\Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType|\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType|\PHPStan\Type\MixedType
*/ */
public function narrowToFullyQualifiedOrAliasedObjectType(\PhpParser\Node $node, \PHPStan\Type\ObjectType $objectType) : \PHPStan\Type\SubtractableType public function narrowToFullyQualifiedOrAliasedObjectType(\PhpParser\Node $node, \PHPStan\Type\ObjectType $objectType)
{ {
/** @var Use_[]|null $uses */ /** @var Use_[]|null $uses */
$uses = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::USE_NODES); $uses = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::USE_NODES);

View File

@ -8,7 +8,6 @@ use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\Identifier; use PhpParser\Node\Identifier;
use PhpParser\Node\Name; use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified; use PhpParser\Node\Name\FullyQualified;
@ -113,8 +112,9 @@ CODE_SAMPLE
} }
/** /**
* @param ClassMethod|Function_|Closure $node * @param ClassMethod|Function_|Closure $node
* @return \PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_
*/ */
private function processSingleUnionType(\PhpParser\Node $node, \PHPStan\Type\UnionType $unionType, \PhpParser\Node\NullableType $nullableType) : \PhpParser\Node\FunctionLike private function processSingleUnionType(\PhpParser\Node $node, \PHPStan\Type\UnionType $unionType, \PhpParser\Node\NullableType $nullableType)
{ {
$types = $unionType->getTypes(); $types = $unionType->getTypes();
$returnType = $types[0] instanceof \PHPStan\Type\ObjectType && $types[1] instanceof \PHPStan\Type\NullType ? new \PhpParser\Node\NullableType(new \PhpParser\Node\Name\FullyQualified($types[0]->getClassName())) : $nullableType; $returnType = $types[0] instanceof \PHPStan\Type\ObjectType && $types[1] instanceof \PHPStan\Type\NullType ? new \PhpParser\Node\NullableType(new \PhpParser\Node\Name\FullyQualified($types[0]->getClassName())) : $nullableType;
@ -200,8 +200,9 @@ CODE_SAMPLE
/** /**
* @param \PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\NullableType|PhpParserUnionType $returnedStrictTypeNode * @param \PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\NullableType|PhpParserUnionType $returnedStrictTypeNode
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike * @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure $functionLike
* @return \PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_
*/ */
private function refactorSingleReturnType(\PhpParser\Node\Stmt\Return_ $return, $returnedStrictTypeNode, $functionLike) : \PhpParser\Node\FunctionLike private function refactorSingleReturnType(\PhpParser\Node\Stmt\Return_ $return, $returnedStrictTypeNode, $functionLike)
{ {
$resolvedType = $this->nodeTypeResolver->resolve($return); $resolvedType = $this->nodeTypeResolver->resolve($return);
if ($resolvedType instanceof \PHPStan\Type\UnionType) { if ($resolvedType instanceof \PHPStan\Type\UnionType) {

View File

@ -145,7 +145,10 @@ final class PHPUnitDataProviderParamTypeInferer implements \Rector\TypeDeclarati
} }
return $this->typeFactory->createMixedPassedOrUnionType($paramOnPositionTypes); return $this->typeFactory->createMixedPassedOrUnionType($paramOnPositionTypes);
} }
private function getTypeFromClassMethodYield(\PhpParser\Node\Expr\Array_ $classMethodYieldArrayNode) : \PHPStan\Type\Type /**
* @return \PHPStan\Type\MixedType|\PHPStan\Type\Constant\ConstantArrayType
*/
private function getTypeFromClassMethodYield(\PhpParser\Node\Expr\Array_ $classMethodYieldArrayNode)
{ {
$arrayTypes = $this->nodeTypeResolver->resolve($classMethodYieldArrayNode); $arrayTypes = $this->nodeTypeResolver->resolve($classMethodYieldArrayNode);
// impossible to resolve // impossible to resolve

View File

@ -113,7 +113,10 @@ final class ReturnedNodesReturnTypeInferer implements \Rector\TypeDeclaration\Co
}); });
return $returns; return $returns;
} }
private function resolveNoLocalReturnNodes(\PhpParser\Node\Stmt\ClassLike $classLike, \PhpParser\Node\FunctionLike $functionLike) : \PHPStan\Type\Type /**
* @return \PHPStan\Type\VoidType|\PHPStan\Type\MixedType
*/
private function resolveNoLocalReturnNodes(\PhpParser\Node\Stmt\ClassLike $classLike, \PhpParser\Node\FunctionLike $functionLike)
{ {
// void type // void type
if (!$this->isAbstractMethod($classLike, $functionLike)) { if (!$this->isAbstractMethod($classLike, $functionLike)) {

View File

@ -129,8 +129,9 @@ final class TypeNormalizer
} }
/** /**
* @param NestedArrayType[] $collectedNestedArrayTypes * @param NestedArrayType[] $collectedNestedArrayTypes
* @return \PHPStan\Type\UnionType|\PHPStan\Type\ArrayType
*/ */
private function createUnionedTypesFromArrayTypes(array $collectedNestedArrayTypes) : \PHPStan\Type\Type private function createUnionedTypesFromArrayTypes(array $collectedNestedArrayTypes)
{ {
$unionedTypes = []; $unionedTypes = [];
foreach ($collectedNestedArrayTypes as $collectedNestedArrayType) { foreach ($collectedNestedArrayTypes as $collectedNestedArrayType) {

View File

@ -16,11 +16,11 @@ final class VersionResolver
/** /**
* @var string * @var string
*/ */
public const PACKAGE_VERSION = 'e783801584b7778aa0d0b15fc0ec918d81b2af6a'; public const PACKAGE_VERSION = 'dce60231f7fe8777847a5f845572711999db650f';
/** /**
* @var string * @var string
*/ */
public const RELEASE_DATE = '2021-06-18 19:02:24'; public const RELEASE_DATE = '2021-06-18 17:19:36';
public static function resolvePackageVersion() : string public static function resolvePackageVersion() : string
{ {
$process = new \RectorPrefix20210618\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__); $process = new \RectorPrefix20210618\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

View File

@ -385,7 +385,10 @@ abstract class AbstractRector extends \PhpParser\NodeVisitorAbstract implements
} }
return $currentArgs; return $currentArgs;
} }
protected function unwrapExpression(\PhpParser\Node\Stmt $stmt) : \PhpParser\Node /**
* @return \PhpParser\Node\Expr|\PhpParser\Node\Stmt
*/
protected function unwrapExpression(\PhpParser\Node\Stmt $stmt)
{ {
if ($stmt instanceof \PhpParser\Node\Stmt\Expression) { if ($stmt instanceof \PhpParser\Node\Stmt\Expression) {
return $stmt->expr; return $stmt->expr;

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php'; require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit106ee273518d782c1bdbc00419d61d8e::getLoader(); return ComposerAutoloaderInit2ae2f6e0aa81490d538740629dbe54a9::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer // autoload_real.php @generated by Composer
class ComposerAutoloaderInit106ee273518d782c1bdbc00419d61d8e class ComposerAutoloaderInit2ae2f6e0aa81490d538740629dbe54a9
{ {
private static $loader; private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit106ee273518d782c1bdbc00419d61d8e
return self::$loader; return self::$loader;
} }
spl_autoload_register(array('ComposerAutoloaderInit106ee273518d782c1bdbc00419d61d8e', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInit2ae2f6e0aa81490d538740629dbe54a9', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit106ee273518d782c1bdbc00419d61d8e', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInit2ae2f6e0aa81490d538740629dbe54a9', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) { if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php'; require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit106ee273518d782c1bdbc00419d61d8e::getInitializer($loader)); call_user_func(\Composer\Autoload\ComposerStaticInit2ae2f6e0aa81490d538740629dbe54a9::getInitializer($loader));
} else { } else {
$classMap = require __DIR__ . '/autoload_classmap.php'; $classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) { if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit106ee273518d782c1bdbc00419d61d8e
$loader->register(true); $loader->register(true);
if ($useStaticLoader) { if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit106ee273518d782c1bdbc00419d61d8e::$files; $includeFiles = Composer\Autoload\ComposerStaticInit2ae2f6e0aa81490d538740629dbe54a9::$files;
} else { } else {
$includeFiles = require __DIR__ . '/autoload_files.php'; $includeFiles = require __DIR__ . '/autoload_files.php';
} }
foreach ($includeFiles as $fileIdentifier => $file) { foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire106ee273518d782c1bdbc00419d61d8e($fileIdentifier, $file); composerRequire2ae2f6e0aa81490d538740629dbe54a9($fileIdentifier, $file);
} }
return $loader; return $loader;
} }
} }
function composerRequire106ee273518d782c1bdbc00419d61d8e($fileIdentifier, $file) function composerRequire2ae2f6e0aa81490d538740629dbe54a9($fileIdentifier, $file)
{ {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file; require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload; namespace Composer\Autoload;
class ComposerStaticInit106ee273518d782c1bdbc00419d61d8e class ComposerStaticInit2ae2f6e0aa81490d538740629dbe54a9
{ {
public static $files = array ( public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3875,9 +3875,9 @@ class ComposerStaticInit106ee273518d782c1bdbc00419d61d8e
public static function getInitializer(ClassLoader $loader) public static function getInitializer(ClassLoader $loader)
{ {
return \Closure::bind(function () use ($loader) { return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit106ee273518d782c1bdbc00419d61d8e::$prefixLengthsPsr4; $loader->prefixLengthsPsr4 = ComposerStaticInit2ae2f6e0aa81490d538740629dbe54a9::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit106ee273518d782c1bdbc00419d61d8e::$prefixDirsPsr4; $loader->prefixDirsPsr4 = ComposerStaticInit2ae2f6e0aa81490d538740629dbe54a9::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit106ee273518d782c1bdbc00419d61d8e::$classMap; $loader->classMap = ComposerStaticInit2ae2f6e0aa81490d538740629dbe54a9::$classMap;
}, null, ClassLoader::class); }, null, ClassLoader::class);
} }

View File

@ -21,8 +21,8 @@ if (!class_exists('SomeTestCase', false) && !interface_exists('SomeTestCase', fa
if (!class_exists('CheckoutEntityFactory', false) && !interface_exists('CheckoutEntityFactory', false) && !trait_exists('CheckoutEntityFactory', false)) { if (!class_exists('CheckoutEntityFactory', false) && !interface_exists('CheckoutEntityFactory', false) && !trait_exists('CheckoutEntityFactory', false)) {
spl_autoload_call('RectorPrefix20210618\CheckoutEntityFactory'); spl_autoload_call('RectorPrefix20210618\CheckoutEntityFactory');
} }
if (!class_exists('ComposerAutoloaderInit106ee273518d782c1bdbc00419d61d8e', false) && !interface_exists('ComposerAutoloaderInit106ee273518d782c1bdbc00419d61d8e', false) && !trait_exists('ComposerAutoloaderInit106ee273518d782c1bdbc00419d61d8e', false)) { if (!class_exists('ComposerAutoloaderInit2ae2f6e0aa81490d538740629dbe54a9', false) && !interface_exists('ComposerAutoloaderInit2ae2f6e0aa81490d538740629dbe54a9', false) && !trait_exists('ComposerAutoloaderInit2ae2f6e0aa81490d538740629dbe54a9', false)) {
spl_autoload_call('RectorPrefix20210618\ComposerAutoloaderInit106ee273518d782c1bdbc00419d61d8e'); spl_autoload_call('RectorPrefix20210618\ComposerAutoloaderInit2ae2f6e0aa81490d538740629dbe54a9');
} }
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) { if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
spl_autoload_call('RectorPrefix20210618\Doctrine\Inflector\Inflector'); spl_autoload_call('RectorPrefix20210618\Doctrine\Inflector\Inflector');
@ -3323,9 +3323,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20210618\print_node(...func_get_args()); return \RectorPrefix20210618\print_node(...func_get_args());
} }
} }
if (!function_exists('composerRequire106ee273518d782c1bdbc00419d61d8e')) { if (!function_exists('composerRequire2ae2f6e0aa81490d538740629dbe54a9')) {
function composerRequire106ee273518d782c1bdbc00419d61d8e() { function composerRequire2ae2f6e0aa81490d538740629dbe54a9() {
return \RectorPrefix20210618\composerRequire106ee273518d782c1bdbc00419d61d8e(...func_get_args()); return \RectorPrefix20210618\composerRequire2ae2f6e0aa81490d538740629dbe54a9(...func_get_args());
} }
} }
if (!function_exists('parseArgs')) { if (!function_exists('parseArgs')) {