mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit 557c3c6071
cb028ac9c7
remove NodeNameResolver config, breaks much more rules557c3c6071
fix cs
This commit is contained in:
parent
0334d1bfd6
commit
6a0e872ef0
|
@ -0,0 +1,4 @@
|
|||
services:
|
||||
defaultAnalysisParser:
|
||||
factory: @currentPhpVersionRichParser
|
||||
arguments!: []
|
|
@ -12,6 +12,7 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
|
|||
__DIR__ . '/../packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php',
|
||||
__DIR__ . '/../packages/Testing/PHPUnit',
|
||||
__DIR__ . '/../packages/BetterPhpDocParser/PhpDoc',
|
||||
__DIR__ . '/../packages/PHPStanStaticTypeMapper/Enum',
|
||||
__DIR__ . '/../packages/Caching/Cache.php',
|
||||
__DIR__ . '/../packages/NodeTypeResolver/NodeVisitor/FileNodeVisitor.php',
|
||||
// used in PHPStan
|
||||
|
|
|
@ -14,12 +14,12 @@ use PhpParser\Lexer;
|
|||
use PhpParser\NodeFinder;
|
||||
use PhpParser\NodeVisitor\CloningVisitor;
|
||||
use PhpParser\NodeVisitor\NodeConnectingVisitor;
|
||||
use PhpParser\Parser;
|
||||
use PhpParser\ParserFactory;
|
||||
use PHPStan\Analyser\NodeScopeResolver;
|
||||
use PHPStan\Analyser\ScopeFactory;
|
||||
use PHPStan\Dependency\DependencyResolver;
|
||||
use PHPStan\File\FileHelper;
|
||||
use PHPStan\Parser\Parser;
|
||||
use PHPStan\PhpDoc\TypeNodeResolver;
|
||||
use PHPStan\PhpDocParser\Parser\PhpDocParser;
|
||||
use PHPStan\PhpDocParser\Parser\TypeParser;
|
||||
|
@ -29,8 +29,6 @@ use Rector\BetterPhpDocParser\PhpDocParser\BetterTypeParser;
|
|||
use Rector\Caching\Cache;
|
||||
use Rector\Caching\CacheFactory;
|
||||
use Rector\Core\Console\ConsoleApplication;
|
||||
use Rector\Core\PhpParser\Parser\NikicPhpParserFactory;
|
||||
use Rector\Core\PhpParser\Parser\PhpParserLexerFactory;
|
||||
use Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory;
|
||||
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator;
|
||||
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider;
|
||||
|
@ -62,8 +60,8 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
|
|||
$services->set(\PhpParser\BuilderFactory::class);
|
||||
$services->set(\PhpParser\NodeVisitor\CloningVisitor::class);
|
||||
$services->set(\PhpParser\NodeFinder::class);
|
||||
$services->set(\PhpParser\Parser::class)->factory([\RectorPrefix20211027\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Core\PhpParser\Parser\NikicPhpParserFactory::class), 'create']);
|
||||
$services->set(\PhpParser\Lexer::class)->factory([\RectorPrefix20211027\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Core\PhpParser\Parser\PhpParserLexerFactory::class), 'create']);
|
||||
$services->set(\PHPStan\Parser\Parser::class)->factory([\RectorPrefix20211027\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createPHPStanParser']);
|
||||
$services->set(\PhpParser\Lexer::class)->factory([\RectorPrefix20211027\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createEmulativeLexer']);
|
||||
// symplify/package-builder
|
||||
$services->set(\RectorPrefix20211027\Symplify\PackageBuilder\Reflection\PrivatesAccessor::class);
|
||||
$services->set(\RectorPrefix20211027\Symplify\PackageBuilder\Reflection\PrivatesCaller::class);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
declare (strict_types=1);
|
||||
namespace RectorPrefix20211027;
|
||||
|
||||
use Rector\Php53\Rector\AssignRef\ClearReturnNewByReferenceRector;
|
||||
use Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector;
|
||||
use Rector\Php53\Rector\Ternary\TernaryToElvisRector;
|
||||
use Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector;
|
||||
|
@ -12,6 +11,5 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
|
|||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php53\Rector\Ternary\TernaryToElvisRector::class);
|
||||
$services->set(\Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector::class);
|
||||
$services->set(\Rector\Php53\Rector\AssignRef\ClearReturnNewByReferenceRector::class);
|
||||
$services->set(\Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector::class);
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
|||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use Rector\TypeDeclaration\PhpDocParser\ParamPhpDocNodeFactory;
|
||||
final class PhpDocTypeChanger
|
||||
|
@ -60,7 +60,7 @@ final class PhpDocTypeChanger
|
|||
return;
|
||||
}
|
||||
// override existing type
|
||||
$newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY());
|
||||
$newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());
|
||||
$currentVarTagValueNode = $phpDocInfo->getVarTagValueNode();
|
||||
if ($currentVarTagValueNode !== null) {
|
||||
// only change type
|
||||
|
@ -82,7 +82,7 @@ final class PhpDocTypeChanger
|
|||
return;
|
||||
}
|
||||
// override existing type
|
||||
$newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
$newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
$currentReturnTagValueNode = $phpDocInfo->getReturnTagValue();
|
||||
if ($currentReturnTagValueNode !== null) {
|
||||
// only change type
|
||||
|
@ -99,7 +99,7 @@ final class PhpDocTypeChanger
|
|||
if ($phpDocInfo->hasInvalidTag('@param')) {
|
||||
return;
|
||||
}
|
||||
$phpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PARAM());
|
||||
$phpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM());
|
||||
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramName);
|
||||
// override existing type
|
||||
if ($paramTagValueNode !== null) {
|
||||
|
|
|
@ -15,7 +15,7 @@ final class DependencyResolver
|
|||
*/
|
||||
private $nodeScopeResolver;
|
||||
/**
|
||||
* @var PHPStanDependencyResolver
|
||||
* @var \PHPStan\Dependency\DependencyResolver
|
||||
*/
|
||||
private $phpStanDependencyResolver;
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,7 @@ use Rector\Core\PhpParser\Parser\SimplePhpParser;
|
|||
use Rector\FamilyTree\ValueObject\PropertyType;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use RectorPrefix20211027\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
final class FamilyRelationsAnalyzer
|
||||
|
@ -87,7 +87,7 @@ final class FamilyRelationsAnalyzer
|
|||
return $childrenClassReflections;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Name|\PhpParser\Node\NullableType|PhpParserUnionType|null $propertyTypeNode
|
||||
* @param \PhpParser\Node\Name|\PhpParser\Node\NullableType|\PhpParser\Node\UnionType|null $propertyTypeNode
|
||||
*/
|
||||
public function getPossibleUnionPropertyType(\PhpParser\Node\Stmt\Property $property, \PHPStan\Type\Type $varType, ?\PHPStan\Analyser\Scope $scope, $propertyTypeNode) : \Rector\FamilyTree\ValueObject\PropertyType
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ final class FamilyRelationsAnalyzer
|
|||
continue;
|
||||
}
|
||||
$fileName = $ancestorClassReflection->getFileName();
|
||||
if ($fileName === \false) {
|
||||
if ($fileName === null) {
|
||||
continue;
|
||||
}
|
||||
$stmts = $this->simplePhpParser->parseFile($fileName);
|
||||
|
@ -123,7 +123,7 @@ final class FamilyRelationsAnalyzer
|
|||
continue;
|
||||
}
|
||||
$varType = new \PHPStan\Type\UnionType([$varType, new \PHPStan\Type\NullType()]);
|
||||
$propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY());
|
||||
$propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());
|
||||
return new \Rector\FamilyTree\ValueObject\PropertyType($varType, $propertyTypeNode);
|
||||
}
|
||||
return new \Rector\FamilyTree\ValueObject\PropertyType($varType, $propertyTypeNode);
|
||||
|
|
|
@ -21,10 +21,6 @@ final class ParentClassScopeResolver
|
|||
if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) {
|
||||
return null;
|
||||
}
|
||||
$parentClassReflection = $classReflection->getParentClass();
|
||||
if ($parentClassReflection instanceof \PHPStan\Reflection\ClassReflection) {
|
||||
return $parentClassReflection;
|
||||
}
|
||||
return null;
|
||||
return $classReflection->getParentClass();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
declare (strict_types=1);
|
||||
namespace Rector\NodeTypeResolver\DependencyInjection;
|
||||
|
||||
use PhpParser\Lexer;
|
||||
use PHPStan\Analyser\NodeScopeResolver;
|
||||
use PHPStan\Analyser\ScopeFactory;
|
||||
use PHPStan\Dependency\DependencyResolver;
|
||||
|
@ -10,6 +11,7 @@ use PHPStan\DependencyInjection\Container;
|
|||
use PHPStan\DependencyInjection\ContainerFactory;
|
||||
use PHPStan\ExtensionInstaller\GeneratedConfig;
|
||||
use PHPStan\File\FileHelper;
|
||||
use PHPStan\Parser\Parser;
|
||||
use PHPStan\PhpDoc\TypeNodeResolver;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use Rector\Core\Configuration\Option;
|
||||
|
@ -34,6 +36,7 @@ final class PHPStanServicesFactory
|
|||
$additionalConfigFiles[] = $parameterProvider->provideStringParameter(\Rector\Core\Configuration\Option::PHPSTAN_FOR_RECTOR_PATH);
|
||||
$additionalConfigFiles[] = __DIR__ . '/../../../config/phpstan/static-reflection.neon';
|
||||
$additionalConfigFiles[] = __DIR__ . '/../../../config/phpstan/better-infer.neon';
|
||||
$additionalConfigFiles[] = __DIR__ . '/../../../config/phpstan/parser.neon';
|
||||
$extensionConfigFiles = $this->resolveExtensionConfigs();
|
||||
$additionalConfigFiles = \array_merge($additionalConfigFiles, $extensionConfigFiles);
|
||||
$existingAdditionalConfigFiles = \array_filter($additionalConfigFiles, 'file_exists');
|
||||
|
@ -46,6 +49,20 @@ final class PHPStanServicesFactory
|
|||
{
|
||||
return $this->container->getByType(\PHPStan\Reflection\ReflectionProvider::class);
|
||||
}
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
public function createEmulativeLexer() : \PhpParser\Lexer
|
||||
{
|
||||
return $this->container->getService('currentPhpVersionLexer');
|
||||
}
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
public function createPHPStanParser() : \PHPStan\Parser\Parser
|
||||
{
|
||||
return $this->container->getService('currentPhpVersionRichParser');
|
||||
}
|
||||
/**
|
||||
* @api
|
||||
*/
|
||||
|
|
|
@ -10,7 +10,7 @@ use Symplify\SmartFileSystem\SmartFileInfo;
|
|||
final class ScopeFactory
|
||||
{
|
||||
/**
|
||||
* @var PHPStanScopeFactory
|
||||
* @var \PHPStan\Analyser\ScopeFactory
|
||||
*/
|
||||
private $phpStanScopeFactory;
|
||||
public function __construct(\PHPStan\Analyser\ScopeFactory $phpStanScopeFactory)
|
||||
|
|
|
@ -11,7 +11,7 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
|||
use Rector\Core\Configuration\CurrentNodeProvider;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\NodeTypeResolver\ValueObject\OldToNewType;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\ShortenedObjectType;
|
||||
use RectorPrefix20211027\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
||||
|
@ -58,7 +58,7 @@ final class ClassRenamePhpDocNodeVisitor extends \RectorPrefix20211027\Symplify\
|
|||
if (!$staticType->equals($oldToNewType->getOldType())) {
|
||||
continue;
|
||||
}
|
||||
$newTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($oldToNewType->getNewType(), \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::ANY());
|
||||
$newTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($oldToNewType->getNewType(), \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::ANY());
|
||||
$parentType = $node->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT);
|
||||
if ($parentType instanceof \PHPStan\PhpDocParser\Ast\Type\TypeNode) {
|
||||
// mirror attributes
|
||||
|
|
|
@ -26,7 +26,7 @@ use RectorPrefix20211027\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractP
|
|||
final class NameImportingPhpDocNodeVisitor extends \RectorPrefix20211027\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor
|
||||
{
|
||||
/**
|
||||
* @var PhpParserNode|null
|
||||
* @var \PhpParser\Node|null
|
||||
*/
|
||||
private $currentPhpParserNode;
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvi
|
|||
|
||||
use PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator;
|
||||
use PHPStan\BetterReflection\SourceLocator\Type\SourceLocator;
|
||||
use PHPStan\Php\PhpVersion;
|
||||
use PHPStan\Reflection\BetterReflection\SourceLocator\FileNodesFetcher;
|
||||
use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedDirectorySourceLocator;
|
||||
use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedSingleFileSourceLocator;
|
||||
|
@ -29,9 +30,14 @@ final class DynamicSourceLocatorProvider implements \Rector\NodeTypeResolver\Con
|
|||
* @var \PHPStan\Reflection\BetterReflection\SourceLocator\FileNodesFetcher
|
||||
*/
|
||||
private $fileNodesFetcher;
|
||||
public function __construct(\PHPStan\Reflection\BetterReflection\SourceLocator\FileNodesFetcher $fileNodesFetcher)
|
||||
/**
|
||||
* @var \PHPStan\Php\PhpVersion
|
||||
*/
|
||||
private $phpVersion;
|
||||
public function __construct(\PHPStan\Reflection\BetterReflection\SourceLocator\FileNodesFetcher $fileNodesFetcher, \PHPStan\Php\PhpVersion $phpVersion)
|
||||
{
|
||||
$this->fileNodesFetcher = $fileNodesFetcher;
|
||||
$this->phpVersion = $phpVersion;
|
||||
}
|
||||
/**
|
||||
* @param \Symplify\SmartFileSystem\SmartFileInfo $fileInfo
|
||||
|
@ -59,7 +65,7 @@ final class DynamicSourceLocatorProvider implements \Rector\NodeTypeResolver\Con
|
|||
$sourceLocators[] = new \PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedSingleFileSourceLocator($this->fileNodesFetcher, $file);
|
||||
}
|
||||
foreach ($this->filesByDirectory as $files) {
|
||||
$sourceLocators[] = new \PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedDirectorySourceLocator($this->fileNodesFetcher, $files);
|
||||
$sourceLocators[] = new \PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedDirectorySourceLocator($this->fileNodesFetcher, $this->phpVersion, $files);
|
||||
}
|
||||
$this->aggregateSourceLocator = new \PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator($sourceLocators);
|
||||
return $this->aggregateSourceLocator;
|
||||
|
|
|
@ -9,7 +9,7 @@ use PhpParser\Node\NullableType;
|
|||
use PhpParser\Node\UnionType;
|
||||
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @template T of Type
|
||||
*/
|
||||
|
@ -21,13 +21,13 @@ interface TypeMapperInterface
|
|||
public function getNodeClass() : string;
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @return Name|NullableType|UnionType|null
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\PHPStanStaticTypeMapper\ValueObject;
|
||||
namespace Rector\PHPStanStaticTypeMapper\Enum;
|
||||
|
||||
use RectorPrefix20211027\MyCLabs\Enum\Enum;
|
||||
/**
|
|
@ -13,7 +13,7 @@ use PHPStan\Type\Accessory\HasMethodType;
|
|||
use PHPStan\Type\Type;
|
||||
use Rector\Core\Exception\NotImplementedYetException;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
final class PHPStanStaticTypeMapper
|
||||
{
|
||||
/**
|
||||
|
@ -27,7 +27,7 @@ final class PHPStanStaticTypeMapper
|
|||
{
|
||||
$this->typeMappers = $typeMappers;
|
||||
}
|
||||
public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
foreach ($this->typeMappers as $typeMapper) {
|
||||
if (!\is_a($type, $typeMapper->getNodeClass(), \true)) {
|
||||
|
@ -46,7 +46,7 @@ final class PHPStanStaticTypeMapper
|
|||
/**
|
||||
* @return \PhpParser\Node\Name|\PhpParser\Node\NullableType|\PhpParser\Node\UnionType|null
|
||||
*/
|
||||
public function mapToPhpParserNode(\PHPStan\Type\Type $type, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind)
|
||||
public function mapToPhpParserNode(\PHPStan\Type\Type $type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind)
|
||||
{
|
||||
foreach ($this->typeMappers as $typeMapper) {
|
||||
if (!\is_a($type, $typeMapper->getNodeClass(), \true)) {
|
||||
|
|
|
@ -10,7 +10,7 @@ use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|||
use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<AccessoryNonEmptyStringType>
|
||||
*/
|
||||
|
@ -25,7 +25,7 @@ final class AccessoryNonEmptyStringTypeMapper implements \Rector\PHPStanStaticTy
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ final class AccessoryNonEmptyStringTypeMapper implements \Rector\PHPStanStaticTy
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -23,9 +23,9 @@ use PHPStan\Type\UnionType;
|
|||
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
|
||||
use Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeCommonTypeNarrower;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\TypeDeclaration\NodeTypeAnalyzer\DetailedTypeAnalyzer;
|
||||
use Rector\TypeDeclaration\TypeAnalyzer\GenericClassStringTypeNormalizer;
|
||||
use RectorPrefix20211027\Symfony\Contracts\Service\Attribute\Required;
|
||||
|
@ -81,7 +81,7 @@ final class ArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -104,13 +104,13 @@ final class ArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
return new \PhpParser\Node\Name('array');
|
||||
}
|
||||
private function createArrayTypeNodeFromUnionType(\PHPStan\Type\UnionType $unionType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind) : \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode
|
||||
private function createArrayTypeNodeFromUnionType(\PHPStan\Type\UnionType $unionType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind) : \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode
|
||||
{
|
||||
$unionedArrayType = [];
|
||||
foreach ($unionType->getTypes() as $unionedType) {
|
||||
|
@ -154,7 +154,7 @@ final class ArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\
|
|||
}
|
||||
return \false;
|
||||
}
|
||||
private function createGenericArrayType(\PHPStan\Type\ArrayType $arrayType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind, bool $withKey = \false) : \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode
|
||||
private function createGenericArrayType(\PHPStan\Type\ArrayType $arrayType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind, bool $withKey = \false) : \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode
|
||||
{
|
||||
$itemType = $arrayType->getItemType();
|
||||
$itemTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($itemType, $typeKind);
|
||||
|
@ -198,7 +198,7 @@ final class ArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\
|
|||
}
|
||||
return !$arrayType->getItemType() instanceof \PHPStan\Type\ArrayType;
|
||||
}
|
||||
private function narrowConstantArrayTypeOfUnionType(\PHPStan\Type\ArrayType $arrayType, \PHPStan\Type\Type $itemType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind) : ?\PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
private function narrowConstantArrayTypeOfUnionType(\PHPStan\Type\ArrayType $arrayType, \PHPStan\Type\Type $itemType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind) : ?\PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
if ($arrayType instanceof \PHPStan\Type\Constant\ConstantArrayType && $itemType instanceof \PHPStan\Type\UnionType) {
|
||||
$narrowedItemType = $this->unionTypeCommonTypeNarrower->narrowToSharedObjectType($itemType);
|
||||
|
@ -216,7 +216,7 @@ final class ArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\
|
|||
/**
|
||||
* @return \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode|\PHPStan\PhpDocParser\Ast\Type\GenericTypeNode
|
||||
*/
|
||||
private function createTypeNodeFromGenericClassStringType(\PHPStan\Type\Generic\GenericClassStringType $genericClassStringType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind)
|
||||
private function createTypeNodeFromGenericClassStringType(\PHPStan\Type\Generic\GenericClassStringType $genericClassStringType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind)
|
||||
{
|
||||
$genericType = $genericClassStringType->getGenericType();
|
||||
if ($genericType instanceof \PHPStan\Type\ObjectType && !$this->reflectionProvider->hasClass($genericType->getClassName())) {
|
||||
|
|
|
@ -13,7 +13,7 @@ use PHPStan\Type\Type;
|
|||
use Rector\Core\Php\PhpVersionProvider;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<BooleanType>
|
||||
*/
|
||||
|
@ -36,7 +36,7 @@ final class BooleanTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contrac
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ final class BooleanTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contrac
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -12,8 +12,8 @@ use PHPStan\Type\ClosureType;
|
|||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use RectorPrefix20211027\Symfony\Contracts\Service\Attribute\Required;
|
||||
/**
|
||||
* @implements TypeMapperInterface<CallableType>
|
||||
|
@ -40,7 +40,7 @@ final class CallableTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contra
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -49,11 +49,11 @@ final class CallableTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contra
|
|||
}
|
||||
/**
|
||||
* @param CallableType|ClosureType $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY())) {
|
||||
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY())) {
|
||||
return null;
|
||||
}
|
||||
return new \PhpParser\Node\Name('callable');
|
||||
|
|
|
@ -13,8 +13,8 @@ use PHPStan\Type\Generic\GenericClassStringType;
|
|||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use RectorPrefix20211027\Symfony\Contracts\Service\Attribute\Required;
|
||||
/**
|
||||
* @implements TypeMapperInterface<ClassStringType>
|
||||
|
@ -34,7 +34,7 @@ final class ClassStringTypeMapper implements \Rector\PHPStanStaticTypeMapper\Con
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ final class ClassStringTypeMapper implements \Rector\PHPStanStaticTypeMapper\Con
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -11,8 +11,8 @@ use PHPStan\Type\ClosureType;
|
|||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use RectorPrefix20211027\Symfony\Contracts\Service\Attribute\Required;
|
||||
/**
|
||||
* @implements TypeMapperInterface<ClosureType>
|
||||
|
@ -32,7 +32,7 @@ final class ClosureTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contrac
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -42,11 +42,11 @@ final class ClosureTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contrac
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY())) {
|
||||
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY())) {
|
||||
return null;
|
||||
}
|
||||
return new \PhpParser\Node\Name('callable');
|
||||
|
|
|
@ -12,7 +12,7 @@ use PHPStan\Type\Type;
|
|||
use Rector\Core\Php\PhpVersionProvider;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<FloatType>
|
||||
*/
|
||||
|
@ -35,7 +35,7 @@ final class FloatTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ final class FloatTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ use PHPStan\Type\Accessory\HasOffsetType;
|
|||
use PHPStan\Type\Type;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<HasOffsetType>
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@ final class HasOffsetTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contr
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ final class HasOffsetTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contr
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ use PHPStan\Type\Type;
|
|||
use Rector\Core\Php\PhpVersionProvider;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<IntegerType>
|
||||
*/
|
||||
|
@ -35,7 +35,7 @@ final class IntegerTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contrac
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ final class IntegerTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contrac
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -9,8 +9,8 @@ use PHPStan\Type\IntersectionType;
|
|||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use RectorPrefix20211027\Symfony\Contracts\Service\Attribute\Required;
|
||||
/**
|
||||
* @implements TypeMapperInterface<IntersectionType>
|
||||
|
@ -37,7 +37,7 @@ final class IntersectionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Co
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ final class IntersectionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Co
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -13,8 +13,8 @@ use PHPStan\Type\Type;
|
|||
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use RectorPrefix20211027\Symfony\Contracts\Service\Attribute\Required;
|
||||
/**
|
||||
* @implements TypeMapperInterface<IterableType>
|
||||
|
@ -41,7 +41,7 @@ final class IterableTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contra
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ final class IterableTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contra
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@ use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<MixedType>
|
||||
*/
|
||||
|
@ -24,7 +24,7 @@ final class MixedTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ final class MixedTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@ use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|||
use PHPStan\Type\NeverType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<NeverType>
|
||||
*/
|
||||
|
@ -24,18 +24,18 @@ final class NeverTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN())) {
|
||||
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN())) {
|
||||
return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('never');
|
||||
}
|
||||
return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode('mixed');
|
||||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ use PHPStan\Type\Accessory\NonEmptyArrayType;
|
|||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<NonEmptyArrayType>
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@ final class NonEmptyArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\C
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ final class NonEmptyArrayTypeMapper implements \Rector\PHPStanStaticTypeMapper\C
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|||
use PHPStan\Type\NullType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<NullType>
|
||||
*/
|
||||
|
@ -25,7 +25,7 @@ final class NullTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\T
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -33,18 +33,18 @@ final class NullTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\T
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY())) {
|
||||
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY())) {
|
||||
return null;
|
||||
}
|
||||
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PARAM())) {
|
||||
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM())) {
|
||||
return null;
|
||||
}
|
||||
// return type cannot be only null
|
||||
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN())) {
|
||||
if ($typeKind->equals(\Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN())) {
|
||||
return null;
|
||||
}
|
||||
return new \PhpParser\Node\Name('null');
|
||||
|
|
|
@ -14,8 +14,8 @@ use PHPStan\Type\MixedType;
|
|||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedGenericObjectType;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
|
||||
|
@ -40,7 +40,7 @@ final class ObjectTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ final class ObjectTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
@ -94,7 +94,7 @@ final class ObjectTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract
|
|||
{
|
||||
$this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper;
|
||||
}
|
||||
private function mapGenericObjectType(\PHPStan\Type\Generic\GenericObjectType $genericObjectType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
private function mapGenericObjectType(\PHPStan\Type\Generic\GenericObjectType $genericObjectType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
$name = $this->resolveGenericObjectTypeName($genericObjectType);
|
||||
$identifierTypeNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($name);
|
||||
|
|
|
@ -14,8 +14,8 @@ use Rector\BetterPhpDocParser\ValueObject\Type\EmptyGenericTypeNode;
|
|||
use Rector\Core\Php\PhpVersionProvider;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\ParentObjectWithoutClassType;
|
||||
use RectorPrefix20211027\Symfony\Contracts\Service\Attribute\Required;
|
||||
/**
|
||||
|
@ -44,7 +44,7 @@ final class ObjectWithoutClassTypeMapper implements \Rector\PHPStanStaticTypeMap
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ final class ObjectWithoutClassTypeMapper implements \Rector\PHPStanStaticTypeMap
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|||
use PHPStan\Type\Type;
|
||||
use Rector\Core\Enum\ObjectReference;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType;
|
||||
/**
|
||||
* @implements TypeMapperInterface<ParentStaticType>
|
||||
|
@ -26,7 +26,7 @@ final class ParentStaticTypeMapper implements \Rector\PHPStanStaticTypeMapper\Co
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ final class ParentStaticTypeMapper implements \Rector\PHPStanStaticTypeMapper\Co
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@ use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|||
use PHPStan\Type\ResourceType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<ResourceType>
|
||||
*/
|
||||
|
@ -24,7 +24,7 @@ final class ResourceTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contra
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -32,7 +32,7 @@ final class ResourceTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contra
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -9,7 +9,7 @@ use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
|
|||
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType;
|
||||
/**
|
||||
* @implements TypeMapperInterface<SelfObjectType>
|
||||
|
@ -25,7 +25,7 @@ final class SelfObjectTypeMapper implements \Rector\PHPStanStaticTypeMapper\Cont
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ final class SelfObjectTypeMapper implements \Rector\PHPStanStaticTypeMapper\Cont
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -13,7 +13,7 @@ use Rector\Core\Enum\ObjectReference;
|
|||
use Rector\Core\Php\PhpVersionProvider;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\SelfStaticType;
|
||||
/**
|
||||
* @see \Rector\Tests\NodeTypeResolver\StaticTypeMapper\StaticTypeMapperTest
|
||||
|
@ -39,7 +39,7 @@ final class StaticTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ final class StaticTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|||
use PHPStan\Type\StrictMixedType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<StrictMixedType>
|
||||
*/
|
||||
|
@ -29,7 +29,7 @@ final class StrictMixedTypeMapper implements \Rector\PHPStanStaticTypeMapper\Con
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ final class StrictMixedTypeMapper implements \Rector\PHPStanStaticTypeMapper\Con
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ use PHPStan\Type\Type;
|
|||
use Rector\Core\Php\PhpVersionProvider;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<StringType>
|
||||
*/
|
||||
|
@ -35,7 +35,7 @@ final class StringTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ final class StringTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|||
use PHPStan\Type\ThisType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<ThisType>
|
||||
*/
|
||||
|
@ -25,7 +25,7 @@ final class ThisTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\T
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ final class ThisTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\T
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -12,7 +12,7 @@ use PHPStan\Type\TypeWithClassName;
|
|||
use Rector\Core\Php\PhpVersionProvider;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<TypeWithClassName>
|
||||
*/
|
||||
|
@ -35,7 +35,7 @@ final class TypeWithClassNameTypeMapper implements \Rector\PHPStanStaticTypeMapp
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ final class TypeWithClassNameTypeMapper implements \Rector\PHPStanStaticTypeMapp
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
|
|
@ -28,11 +28,11 @@ use Rector\Core\ValueObject\PhpVersionFeature;
|
|||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
|
||||
use Rector\PHPStanStaticTypeMapper\TypeAnalyzer\BoolUnionTypeAnalyzer;
|
||||
use Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer;
|
||||
use Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeCommonTypeNarrower;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\UnionTypeAnalysis;
|
||||
use RectorPrefix20211027\Symfony\Contracts\Service\Attribute\Required;
|
||||
/**
|
||||
|
@ -93,7 +93,7 @@ final class UnionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ final class UnionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
|
@ -197,7 +197,7 @@ final class UnionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\
|
|||
/**
|
||||
* @return Name|FullyQualified|PhpParserUnionType|NullableType|null
|
||||
*/
|
||||
private function matchTypeForUnionedObjectTypes(\PHPStan\Type\UnionType $unionType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind) : ?\PhpParser\Node
|
||||
private function matchTypeForUnionedObjectTypes(\PHPStan\Type\UnionType $unionType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
$phpParserUnionType = $this->matchPhpParserUnionType($unionType, $typeKind);
|
||||
if ($phpParserUnionType !== null) {
|
||||
|
@ -233,7 +233,7 @@ final class UnionTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\
|
|||
}
|
||||
return new \PhpParser\Node\Name\FullyQualified($compatibleObjectType->getClassName());
|
||||
}
|
||||
private function matchPhpParserUnionType(\PHPStan\Type\UnionType $unionType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind) : ?\PhpParser\Node\UnionType
|
||||
private function matchPhpParserUnionType(\PHPStan\Type\UnionType $unionType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind) : ?\PhpParser\Node\UnionType
|
||||
{
|
||||
if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::UNION_TYPES)) {
|
||||
return null;
|
||||
|
|
|
@ -12,7 +12,7 @@ use PHPStan\Type\VoidType;
|
|||
use Rector\Core\Php\PhpVersionProvider;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
/**
|
||||
* @implements TypeMapperInterface<VoidType>
|
||||
*/
|
||||
|
@ -39,7 +39,7 @@ final class VoidTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\T
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode($type, $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
|
@ -47,14 +47,14 @@ final class VoidTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\T
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @param \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind
|
||||
* @param \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind
|
||||
*/
|
||||
public function mapToPhpParserNode($type, $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::VOID_TYPE)) {
|
||||
return null;
|
||||
}
|
||||
if (\in_array($typeKind->getValue(), [\Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PARAM(), \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY()], \true)) {
|
||||
if (\in_array($typeKind->getValue(), [\Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM(), \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY()], \true)) {
|
||||
return null;
|
||||
}
|
||||
return new \PhpParser\Node\Name(self::VOID);
|
||||
|
|
|
@ -20,8 +20,8 @@ use PHPStan\Type\MixedType;
|
|||
use PHPStan\Type\Type;
|
||||
use Rector\Core\Exception\NotImplementedYetException;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\StaticTypeMapper\Mapper\PhpParserNodeMapper;
|
||||
use Rector\StaticTypeMapper\Naming\NameScopeFactory;
|
||||
use Rector\StaticTypeMapper\PhpDoc\PhpDocTypeMapper;
|
||||
|
@ -54,14 +54,14 @@ final class StaticTypeMapper
|
|||
$this->phpDocTypeMapper = $phpDocTypeMapper;
|
||||
$this->phpParserNodeMapper = $phpParserNodeMapper;
|
||||
}
|
||||
public function mapPHPStanTypeToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $phpStanType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
public function mapPHPStanTypeToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $phpStanType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
{
|
||||
return $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($phpStanType, $typeKind);
|
||||
}
|
||||
/**
|
||||
* @return Name|NullableType|PhpParserUnionType|null
|
||||
*/
|
||||
public function mapPHPStanTypeToPhpParserNode(\PHPStan\Type\Type $phpStanType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind $typeKind) : ?\PhpParser\Node
|
||||
public function mapPHPStanTypeToPhpParserNode(\PHPStan\Type\Type $phpStanType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind) : ?\PhpParser\Node
|
||||
{
|
||||
return $this->phpStanStaticTypeMapper->mapToPhpParserNode($phpStanType, $typeKind);
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ final class ClassMethodParamVendorLockResolver
|
|||
// is file in vendor?
|
||||
$fileName = $ancestorClassReflection->getFileName();
|
||||
// probably internal class
|
||||
if ($fileName === \false) {
|
||||
if ($fileName === null) {
|
||||
continue;
|
||||
}
|
||||
// not conditions? its a match
|
||||
|
|
|
@ -49,7 +49,7 @@ final class ParentClassMethodTypeOverrideGuard
|
|||
$classReflection = $parentClassMethodReflection->getDeclaringClass();
|
||||
$fileName = $classReflection->getFileName();
|
||||
// probably internal
|
||||
if ($fileName === \false) {
|
||||
if ($fileName === null) {
|
||||
return \false;
|
||||
}
|
||||
$normalizedFileName = $this->pathNormalizer->normalizePath($fileName);
|
||||
|
|
|
@ -141,8 +141,10 @@ final class ArgumentDefaultValueReplacer
|
|||
private function resolveArgumentValuesToBeforeRecipe(array $argumentNodes, \Rector\Arguments\Contract\ReplaceArgumentDefaultValueInterface $replaceArgumentDefaultValue) : array
|
||||
{
|
||||
$argumentValues = [];
|
||||
/** @var mixed[] $valueBefore */
|
||||
$valueBefore = $replaceArgumentDefaultValue->getValueBefore();
|
||||
if (!\is_array($valueBefore)) {
|
||||
return [];
|
||||
}
|
||||
$beforeArgumentCount = \count($valueBefore);
|
||||
for ($i = 0; $i < $beforeArgumentCount; ++$i) {
|
||||
if (!isset($argumentNodes[$replaceArgumentDefaultValue->getPosition() + $i])) {
|
||||
|
|
|
@ -23,7 +23,7 @@ use Rector\Core\Enum\ObjectReference;
|
|||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use RectorPrefix20211027\Webmozart\Assert\Assert;
|
||||
|
@ -210,7 +210,7 @@ CODE_SAMPLE
|
|||
}
|
||||
$param = new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable($argumentName), \PhpParser\BuilderHelpers::normalizeValue($defaultValue));
|
||||
if ($type !== null) {
|
||||
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PARAM());
|
||||
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM());
|
||||
$param->type = $typeNode;
|
||||
}
|
||||
$classMethod->params[$position] = $param;
|
||||
|
|
|
@ -13,7 +13,7 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
|||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
||||
use Rector\Core\Php\PhpVersionProvider;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
final class PropertyTypeDecorator
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ final class PropertyTypeDecorator
|
|||
return;
|
||||
}
|
||||
if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) {
|
||||
$phpParserNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY());
|
||||
$phpParserNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());
|
||||
if (!$phpParserNode instanceof \PhpParser\Node) {
|
||||
// fallback to doc type in PHP 7.4
|
||||
$this->phpDocTypeChanger->changeVarType($phpDocInfo, $propertyType);
|
||||
|
@ -69,7 +69,7 @@ final class PropertyTypeDecorator
|
|||
if (!$this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) {
|
||||
return;
|
||||
}
|
||||
$phpParserNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY());
|
||||
$phpParserNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());
|
||||
if (!$phpParserNode instanceof \PhpParser\Node) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -106,20 +106,20 @@ CODE_SAMPLE
|
|||
if ($stmt instanceof \PhpParser\Node\Stmt\Expression) {
|
||||
$stmt = $stmt->expr;
|
||||
}
|
||||
if (!$this->isAlwaysTruableNode($stmt)) {
|
||||
$ifStmt = $this->matchTruableIf($stmt);
|
||||
if (!$ifStmt instanceof \PhpParser\Node\Stmt\If_) {
|
||||
continue;
|
||||
}
|
||||
/** @var If_ $stmt */
|
||||
if ($stmt->stmts === null) {
|
||||
if ($ifStmt->stmts === null) {
|
||||
continue;
|
||||
}
|
||||
if (\count($stmt->stmts) === 1) {
|
||||
$node->stmts[$key] = $stmt->stmts[0];
|
||||
if (\count($ifStmt->stmts) === 1) {
|
||||
$node->stmts[$key] = $ifStmt->stmts[0];
|
||||
continue;
|
||||
}
|
||||
$haveNodeChanged = \true;
|
||||
// move all nodes one level up
|
||||
\array_splice($node->stmts, $key, \count($stmt->stmts) - 1, $stmt->stmts);
|
||||
\array_splice($node->stmts, $key, \count($ifStmt->stmts) - 1, $ifStmt->stmts);
|
||||
}
|
||||
if ($haveNodeChanged) {
|
||||
return $node;
|
||||
|
@ -128,26 +128,30 @@ CODE_SAMPLE
|
|||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr|\PhpParser\Node\Stmt $node
|
||||
* @return \PhpParser\Node\Stmt\If_|null
|
||||
*/
|
||||
private function isAlwaysTruableNode($node) : bool
|
||||
private function matchTruableIf($node)
|
||||
{
|
||||
if (!$node instanceof \PhpParser\Node\Stmt\If_) {
|
||||
return \false;
|
||||
return null;
|
||||
}
|
||||
// just one if
|
||||
if ($node->elseifs !== []) {
|
||||
return \false;
|
||||
return null;
|
||||
}
|
||||
// there is some else
|
||||
if ($node->else !== null) {
|
||||
return \false;
|
||||
return null;
|
||||
}
|
||||
// only property fetch, because of constructor set
|
||||
if (!$node->cond instanceof \PhpParser\Node\Expr\PropertyFetch) {
|
||||
return \false;
|
||||
return null;
|
||||
}
|
||||
$propertyFetchType = $this->resolvePropertyFetchType($node->cond);
|
||||
return $this->staticTypeAnalyzer->isAlwaysTruableType($propertyFetchType);
|
||||
if (!$this->staticTypeAnalyzer->isAlwaysTruableType($propertyFetchType)) {
|
||||
return null;
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
private function resolvePropertyFetchType(\PhpParser\Node\Expr\PropertyFetch $propertyFetch) : \PHPStan\Type\Type
|
||||
{
|
||||
|
|
|
@ -26,7 +26,7 @@ final class AliasUsesResolver
|
|||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function resolveForNode(\PhpParser\Node $node) : array
|
||||
public function resolveFromNode(\PhpParser\Node $node) : array
|
||||
{
|
||||
if (!$node instanceof \PhpParser\Node\Stmt\Namespace_) {
|
||||
$node = $this->betterNodeFinder->findParentType($node, \PhpParser\Node\Stmt\Namespace_::class);
|
||||
|
|
|
@ -34,7 +34,7 @@ final class AliasClassNameImportSkipVoter implements \Rector\CodingStyle\Contrac
|
|||
*/
|
||||
public function shouldSkip($file, $fullyQualifiedObjectType, $node) : bool
|
||||
{
|
||||
$aliasedUses = $this->aliasUsesResolver->resolveForNode($node);
|
||||
$aliasedUses = $this->aliasUsesResolver->resolveFromNode($node);
|
||||
foreach ($aliasedUses as $aliasedUse) {
|
||||
$aliasedUseLowered = \strtolower($aliasedUse);
|
||||
// its aliased, we cannot just rename it
|
||||
|
|
|
@ -16,7 +16,7 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
|||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
|
@ -87,7 +87,7 @@ CODE_SAMPLE
|
|||
}
|
||||
private function hasTwoAndMoreGenericClassStringTypes(\PHPStan\Type\Constant\ConstantArrayType $constantArrayType) : bool
|
||||
{
|
||||
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($constantArrayType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($constantArrayType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
if (!$typeNode instanceof \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode) {
|
||||
return \false;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ final class VendorLocationDetector
|
|||
{
|
||||
$fileName = $this->resolveReflectionFileName($reflection);
|
||||
// probably internal
|
||||
if ($fileName === \false) {
|
||||
if ($fileName === null) {
|
||||
return \false;
|
||||
}
|
||||
$normalizedFileName = $this->pathNormalizer->normalizePath($fileName);
|
||||
|
@ -33,7 +33,7 @@ final class VendorLocationDetector
|
|||
}
|
||||
/**
|
||||
* @param \PHPStan\Reflection\MethodReflection|\PHPStan\Reflection\ReflectionWithFilename|\PHPStan\Reflection\FunctionReflection $reflection
|
||||
* @return string|bool
|
||||
* @return string|null
|
||||
*/
|
||||
private function resolveReflectionFileName($reflection)
|
||||
{
|
||||
|
@ -47,6 +47,6 @@ final class VendorLocationDetector
|
|||
$declaringClassReflection = $reflection->getDeclaringClass();
|
||||
return $declaringClassReflection->getFileName();
|
||||
}
|
||||
return \false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ final class DowngradePregUnmatchedAsNullConstantRector extends \Rector\Core\Rect
|
|||
/** @var Variable $variable */
|
||||
$variable = $args[2]->value;
|
||||
if ($flags instanceof \PhpParser\Node\Expr\BinaryOp\BitwiseOr) {
|
||||
$this->cleanBitWiseOrFlags($node, $flags);
|
||||
$this->cleanBitwiseOrFlags($node, $flags);
|
||||
if (!$this->nodeComparator->areNodesEqual($flags, $args[3]->value)) {
|
||||
return $this->handleEmptyStringToNullMatch($node, $variable);
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ CODE_SAMPLE
|
|||
}
|
||||
return \in_array($expr->if->value, self::REGEX_FUNCTION_NAMES, \true) && \in_array($expr->else->value, self::REGEX_FUNCTION_NAMES, \true);
|
||||
}
|
||||
private function cleanBitWiseOrFlags(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\BinaryOp\BitwiseOr $bitwiseOr, \PhpParser\Node\Expr $expr = null) : void
|
||||
private function cleanBitwiseOrFlags(\PhpParser\Node\Expr\FuncCall $funcCall, \PhpParser\Node\Expr\BinaryOp\BitwiseOr $bitwiseOr, \PhpParser\Node\Expr $expr = null) : void
|
||||
{
|
||||
if ($bitwiseOr->left instanceof \PhpParser\Node\Expr\BinaryOp\BitwiseOr) {
|
||||
/** @var BitwiseOr $leftLeft */
|
||||
|
@ -177,7 +177,7 @@ CODE_SAMPLE
|
|||
$bitwiseOr = new \PhpParser\Node\Expr\BinaryOp\BitwiseOr($leftRight->left, $bitwiseOr->right);
|
||||
}
|
||||
if ($bitwiseOr->left instanceof \PhpParser\Node\Expr\BinaryOp\BitwiseOr) {
|
||||
$this->cleanBitWiseOrFlags($funcCall, $bitwiseOr->left, $bitwiseOr->right);
|
||||
$this->cleanBitwiseOrFlags($funcCall, $bitwiseOr->left, $bitwiseOr->right);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
|||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\DeadCode\PhpDoc\TagRemover\ReturnTagRemover;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType;
|
||||
use RectorPrefix20211027\Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
|
@ -124,7 +124,7 @@ CODE_SAMPLE
|
|||
// The return type name could either be a classname, without the leading "\",
|
||||
// or one among the reserved identifiers ("static", "self", "iterable", etc)
|
||||
// To find out which is the case, check if this name exists as a class
|
||||
$parentReturnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($parentReturnType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
$parentReturnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($parentReturnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
if (!$parentReturnTypeNode instanceof \PhpParser\Node) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Php53\Rector\AssignRef;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Assign;
|
||||
use PhpParser\Node\Expr\AssignRef;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see https://3v4l.org/UJN6H
|
||||
* @see \Rector\Tests\Php53\Rector\AssignRef\ClearReturnNewByReferenceRector\ClearReturnNewByReferenceRectorTest
|
||||
*/
|
||||
final class ClearReturnNewByReferenceRector extends \Rector\Core\Rector\AbstractRector implements \Rector\VersionBonding\Contract\MinPhpVersionInterface
|
||||
{
|
||||
public function provideMinPhpVersion() : int
|
||||
{
|
||||
return \Rector\Core\ValueObject\PhpVersionFeature::NO_REFERENCE_IN_NEW;
|
||||
}
|
||||
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
|
||||
{
|
||||
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Remove reference from "$assign = &new Value;"', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
|
||||
$assign = &new Value;
|
||||
CODE_SAMPLE
|
||||
, <<<'CODE_SAMPLE'
|
||||
$assign = new Value;
|
||||
CODE_SAMPLE
|
||||
)]);
|
||||
}
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [\PhpParser\Node\Expr\AssignRef::class];
|
||||
}
|
||||
/**
|
||||
* @param AssignRef $node
|
||||
*/
|
||||
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
|
||||
{
|
||||
if (!$node->expr instanceof \PhpParser\Node\Expr\New_) {
|
||||
return null;
|
||||
}
|
||||
return new \PhpParser\Node\Expr\Assign($node->var, $node->expr);
|
||||
}
|
||||
}
|
|
@ -76,8 +76,10 @@ final class UndefinedVariableResolver
|
|||
if ($this->shouldSkipVariable($node)) {
|
||||
return null;
|
||||
}
|
||||
/** @var string $variableName */
|
||||
$variableName = $this->nodeNameResolver->getName($node);
|
||||
if (!\is_string($variableName)) {
|
||||
return null;
|
||||
}
|
||||
// defined 100 %
|
||||
/** @var Scope $scope */
|
||||
$scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
|
|
|
@ -42,7 +42,7 @@ use Rector\Core\PhpParser\Node\NodeFactory;
|
|||
use Rector\Core\PhpParser\Parser\SimplePhpParser;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use RectorPrefix20211027\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser;
|
||||
final class AnonymousFunctionFactory
|
||||
|
@ -125,7 +125,7 @@ final class AnonymousFunctionFactory
|
|||
return null;
|
||||
}
|
||||
if (!$functionVariantWithPhpDoc->getReturnType() instanceof \PHPStan\Type\MixedType) {
|
||||
$returnType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($functionVariantWithPhpDoc->getReturnType(), \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
$returnType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($functionVariantWithPhpDoc->getReturnType(), \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
$anonymousFunction->returnType = $returnType;
|
||||
}
|
||||
// does method return something?
|
||||
|
@ -278,7 +278,7 @@ final class AnonymousFunctionFactory
|
|||
foreach ($parameterReflections as $parameterReflection) {
|
||||
$param = new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable($parameterReflection->getName()));
|
||||
if (!$parameterReflection->getType() instanceof \PHPStan\Type\MixedType) {
|
||||
$param->type = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($parameterReflection->getType(), \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PARAM());
|
||||
$param->type = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($parameterReflection->getType(), \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM());
|
||||
}
|
||||
$params[] = $param;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover;
|
|||
use Rector\FamilyTree\Reflection\FamilyRelationsAnalyzer;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\DoctrineTypeAnalyzer;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType;
|
||||
use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer;
|
||||
|
@ -139,7 +139,7 @@ CODE_SAMPLE
|
|||
if ($varType instanceof \PHPStan\Type\UnionType) {
|
||||
$types = $varType->getTypes();
|
||||
if (\count($types) === 2 && $types[0] instanceof \PHPStan\Type\Generic\TemplateType) {
|
||||
$node->type = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($types[0]->getBound(), \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY());
|
||||
$node->type = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($types[0]->getBound(), \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ CODE_SAMPLE
|
|||
if ($varType instanceof \Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType) {
|
||||
return null;
|
||||
}
|
||||
$propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY());
|
||||
$propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());
|
||||
if ($this->isNullOrNonClassLikeTypeOrMixedOrVendorLockedIn($propertyTypeNode, $node, $varType)) {
|
||||
return null;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ CODE_SAMPLE
|
|||
return \Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Name|\PhpParser\Node\NullableType|PhpParserUnionType|null $node
|
||||
* @param \PhpParser\Node\Name|\PhpParser\Node\NullableType|\PhpParser\Node\UnionType|null $node
|
||||
*/
|
||||
private function isNullOrNonClassLikeTypeOrMixedOrVendorLockedIn($node, \PhpParser\Node\Stmt\Property $property, \PHPStan\Type\Type $type) : bool
|
||||
{
|
||||
|
@ -215,7 +215,7 @@ CODE_SAMPLE
|
|||
return $possibleUnionType;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Name|\PhpParser\Node\NullableType|PhpParserUnionType $node
|
||||
* @param \PhpParser\Node\Name|\PhpParser\Node\NullableType|\PhpParser\Node\UnionType $node
|
||||
*/
|
||||
private function shouldSkipNonClassLikeType($node, \PHPStan\Type\Type $type) : bool
|
||||
{
|
||||
|
|
|
@ -21,7 +21,7 @@ use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover;
|
|||
use Rector\Naming\VariableRenamer;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\Php80\NodeAnalyzer\PromotedPropertyCandidateResolver;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
@ -144,7 +144,7 @@ CODE_SAMPLE
|
|||
{
|
||||
if ($this->nodeTypeResolver->isNullableType($property)) {
|
||||
$objectType = $this->getType($property);
|
||||
$param->type = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($objectType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PARAM());
|
||||
$param->type = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($objectType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM());
|
||||
}
|
||||
}
|
||||
private function decorateParamWithPropertyPhpDocInfo(\PhpParser\Node\Stmt\Property $property, \PhpParser\Node\Param $param) : void
|
||||
|
|
|
@ -20,8 +20,8 @@ use Rector\Core\ValueObject\PhpVersionFeature;
|
|||
use Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover;
|
||||
use Rector\DeadCode\PhpDoc\TagRemover\ReturnTagRemover;
|
||||
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\TypeAnalyzer\UnionTypeAnalyzer;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\VendorLocker\NodeVendorLocker\ClassMethodParamVendorLockResolver;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
|
@ -141,7 +141,7 @@ CODE_SAMPLE
|
|||
if (!$uniqueatedParamType instanceof \PHPStan\Type\UnionType) {
|
||||
continue;
|
||||
}
|
||||
$phpParserUnionType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($uniqueatedParamType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PARAM());
|
||||
$phpParserUnionType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($uniqueatedParamType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM());
|
||||
if (!$phpParserUnionType instanceof \PhpParser\Node\UnionType) {
|
||||
continue;
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ CODE_SAMPLE
|
|||
if (!$uniqueatedReturnType instanceof \PHPStan\Type\UnionType) {
|
||||
return;
|
||||
}
|
||||
$phpParserUnionType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($uniqueatedReturnType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
$phpParserUnionType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($uniqueatedReturnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
if (!$phpParserUnionType instanceof \PhpParser\Node\UnionType) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ use Rector\Core\NodeManipulator\ClassInsertManipulator;
|
|||
use Rector\PhpSpecToPHPUnit\LetManipulator;
|
||||
use Rector\PhpSpecToPHPUnit\Naming\PhpSpecRenaming;
|
||||
use Rector\PhpSpecToPHPUnit\Rector\AbstractPhpSpecToPHPUnitRector;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\PHPUnit\NodeFactory\SetUpClassMethodFactory;
|
||||
/**
|
||||
* @see \Rector\Tests\PhpSpecToPHPUnit\Rector\Variable\PhpSpecToPHPUnitRector\PhpSpecToPHPUnitRectorTest
|
||||
|
@ -97,7 +97,7 @@ final class PhpSpecClassToPHPUnitClassRector extends \Rector\PhpSpecToPHPUnit\Re
|
|||
private function createLetClassMethod(string $propertyName, \PHPStan\Type\ObjectType $testedObjectType) : \PhpParser\Node\Stmt\ClassMethod
|
||||
{
|
||||
$propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), $propertyName);
|
||||
$testedObjectType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($testedObjectType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
$testedObjectType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($testedObjectType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
if (!$testedObjectType instanceof \PhpParser\Node\Name) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use PHPStan\Type\CallableType;
|
|||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use Rector\VendorLocker\NodeVendorLocker\ClassMethodParamVendorLockResolver;
|
||||
final class ClassMethodParamTypeCompleter
|
||||
|
@ -37,7 +37,7 @@ final class ClassMethodParamTypeCompleter
|
|||
if ($this->shouldSkipArgumentStaticType($classMethod, $argumentStaticType, $position)) {
|
||||
continue;
|
||||
}
|
||||
$phpParserTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($argumentStaticType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PARAM());
|
||||
$phpParserTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($argumentStaticType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM());
|
||||
if (!$phpParserTypeNode instanceof \PhpParser\Node) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use PhpParser\Node\NullableType;
|
|||
use PhpParser\Node\Stmt\Return_;
|
||||
use PHPStan\Type\MixedType;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
final class ReturnStrictTypeAnalyzer
|
||||
{
|
||||
|
@ -73,6 +73,6 @@ final class ReturnStrictTypeAnalyzer
|
|||
if ($returnType instanceof \PHPStan\Type\MixedType) {
|
||||
return null;
|
||||
}
|
||||
return $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
return $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
|||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
@ -150,7 +150,7 @@ CODE_SAMPLE
|
|||
$param->type = null;
|
||||
return;
|
||||
}
|
||||
$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($addParamTypeDeclaration->getParamType(), \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PARAM());
|
||||
$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($addParamTypeDeclaration->getParamType(), \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM());
|
||||
$param->type = $returnTypeNode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use PHPStan\Type\Type;
|
|||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
@ -106,7 +106,7 @@ CODE_SAMPLE
|
|||
return;
|
||||
}
|
||||
}
|
||||
$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($newType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
$classMethod->returnType = $returnTypeNode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ use Rector\Core\Rector\AbstractRector;
|
|||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\SelfStaticType;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
|
@ -102,7 +102,7 @@ CODE_SAMPLE
|
|||
$newTypes[] = $this->createObjectTypeFromNew($new);
|
||||
}
|
||||
$returnType = $this->typeFactory->createMixedPassedOrUnionType($newTypes);
|
||||
$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
$node->returnType = $returnTypeNode;
|
||||
return $node;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ use PHPStan\Type\UnionType;
|
|||
use PHPStan\Type\VoidType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\TypeDeclaration\NodeAnalyzer\ReturnStrictTypeAnalyzer;
|
||||
use Rector\TypeDeclaration\NodeAnalyzer\TypeNodeUnwrapper;
|
||||
use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer;
|
||||
|
@ -139,7 +139,7 @@ CODE_SAMPLE
|
|||
if ($resolvedType instanceof \PHPStan\Type\VoidType) {
|
||||
return null;
|
||||
}
|
||||
$returnType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($resolvedType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
$returnType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($resolvedType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
if (!$returnType instanceof \PhpParser\Node) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ use Rector\Core\Rector\AbstractRector;
|
|||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
@ -86,7 +86,7 @@ CODE_SAMPLE
|
|||
if ($propertyType instanceof \PHPStan\Type\MixedType) {
|
||||
return null;
|
||||
}
|
||||
$propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
$propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
if (!$propertyTypeNode instanceof \PhpParser\Node) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use PHPStan\Analyser\Scope;
|
|||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
|
@ -73,7 +73,7 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
$inferedReturnType = $this->returnTypeInferer->inferFunctionLike($node);
|
||||
$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedReturnType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedReturnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
if ($returnTypeNode === null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use Rector\Core\Rector\AbstractRector;
|
|||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\DeadCode\PhpDoc\TagRemover\ParamTagRemover;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType;
|
||||
use Rector\TypeDeclaration\NodeTypeAnalyzer\TraitTypeAnalyzer;
|
||||
use Rector\TypeDeclaration\TypeInferer\ParamTypeInferer;
|
||||
|
@ -169,7 +169,7 @@ CODE_SAMPLE
|
|||
if ($this->traitTypeAnalyzer->isTraitType($inferedType)) {
|
||||
return;
|
||||
}
|
||||
$paramTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PARAM());
|
||||
$paramTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM());
|
||||
if (!$paramTypeNode instanceof \PhpParser\Node) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ use PHPStan\Type\UnionType;
|
|||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\TypeDeclaration\PhpDocParser\NonInformativeReturnTagRemover;
|
||||
use Rector\TypeDeclaration\PhpParserTypeAnalyzer;
|
||||
use Rector\TypeDeclaration\TypeAlreadyAddedChecker\ReturnTypeAlreadyAddedChecker;
|
||||
|
@ -133,7 +133,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
private function processType($node, \PHPStan\Type\Type $inferedType) : ?\PhpParser\Node
|
||||
{
|
||||
$inferredReturnNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
$inferredReturnNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($inferedType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
// nothing to change in PHP code
|
||||
if (!$inferredReturnNode instanceof \PhpParser\Node) {
|
||||
return null;
|
||||
|
|
|
@ -18,7 +18,7 @@ use Rector\Core\Rector\AbstractRector;
|
|||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
@ -130,7 +130,7 @@ CODE_SAMPLE
|
|||
if ($propertyType instanceof \PhpParser\Node\NullableType) {
|
||||
return null;
|
||||
}
|
||||
return $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY());
|
||||
return $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());
|
||||
}
|
||||
private function hasTypeChangedBeforeAssign(\PhpParser\Node\Expr\Assign $assign, string $paramName, \PHPStan\Type\Type $originalType) : bool
|
||||
{
|
||||
|
|
|
@ -10,7 +10,7 @@ use PHPStan\Type\Type;
|
|||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\DeadCode\PhpDoc\TagRemover\VarTagRemover;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\ConstructorPropertyTypeInferer;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
|
@ -81,7 +81,7 @@ CODE_SAMPLE
|
|||
if ($varType instanceof \PHPStan\Type\MixedType) {
|
||||
return null;
|
||||
}
|
||||
$propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY());
|
||||
$propertyTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($varType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());
|
||||
if (!$propertyTypeNode instanceof \PhpParser\Node) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use PHPStan\Type\Type;
|
|||
use PHPStan\Type\TypeCombinator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\TypeDeclaration\TypeInferer\PropertyTypeInferer\GetterTypeDeclarationPropertyTypeInferer;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
|
@ -78,7 +78,7 @@ CODE_SAMPLE
|
|||
if (!$getterReturnType instanceof \PHPStan\Type\Type) {
|
||||
return null;
|
||||
}
|
||||
$propertyType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($getterReturnType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY());
|
||||
$propertyType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($getterReturnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());
|
||||
if ($propertyType === null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ use PHPStan\Type\UnionType;
|
|||
use Rector\Core\PhpParser\Comparing\NodeComparator;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use Traversable;
|
||||
final class ReturnTypeAlreadyAddedChecker
|
||||
|
@ -60,7 +60,7 @@ final class ReturnTypeAlreadyAddedChecker
|
|||
if ($nodeReturnType === null) {
|
||||
return \false;
|
||||
}
|
||||
$returnNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
$returnNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($returnType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
if ($this->nodeComparator->areNodesEqual($nodeReturnType, $returnNode)) {
|
||||
return \true;
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '6bcdc92198efbfbb3990844816f11d18e16833d7';
|
||||
public const PACKAGE_VERSION = '557c3c6071166462274dc9d44c4785e5bbab741b';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-10-27 21:47:04';
|
||||
public const RELEASE_DATE = '2021-10-27 21:07:03';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20211027\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
|
|
@ -105,10 +105,9 @@ final class FilesFinder
|
|||
return;
|
||||
}
|
||||
$finder->filter(function (\RectorPrefix20211027\Symfony\Component\Finder\SplFileInfo $splFileInfo) use($excludePaths) : bool {
|
||||
/** @var string|false $realPath */
|
||||
$realPath = $splFileInfo->getRealPath();
|
||||
if (!$realPath) {
|
||||
//dead symlink
|
||||
if ($realPath === '') {
|
||||
// dead symlink
|
||||
return \false;
|
||||
}
|
||||
// make the path work accross different OSes
|
||||
|
|
|
@ -10,7 +10,7 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
|||
use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger;
|
||||
use Rector\Core\Php\PhpVersionProvider;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
final class PropertyTypeDecorator
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ final class PropertyTypeDecorator
|
|||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
|
||||
if ($this->phpVersionProvider->isAtLeastPhpVersion(\Rector\Core\ValueObject\PhpVersionFeature::TYPED_PROPERTIES)) {
|
||||
$phpParserType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY());
|
||||
$phpParserType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());
|
||||
if ($phpParserType !== null) {
|
||||
$property->type = $phpParserType;
|
||||
if ($type instanceof \PHPStan\Type\Generic\GenericObjectType) {
|
||||
|
|
|
@ -24,6 +24,6 @@ final class ClosureTypeToCallReflectionResolver implements \Rector\Core\Contract
|
|||
*/
|
||||
public function resolve($type, $scope) : \PHPStan\Reflection\Native\NativeFunctionReflection
|
||||
{
|
||||
return new \PHPStan\Reflection\Native\NativeFunctionReflection('{closure}', $type->getCallableParametersAcceptors($scope), null, \PHPStan\TrinaryLogic::createMaybe());
|
||||
return new \PHPStan\Reflection\Native\NativeFunctionReflection('{closure}', $type->getCallableParametersAcceptors($scope), null, \PHPStan\TrinaryLogic::createMaybe(), \false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ final class AstResolver
|
|||
}
|
||||
$fileName = $classReflection->getFileName();
|
||||
// probably native PHP method → un-parseable
|
||||
if ($fileName === \false) {
|
||||
if ($fileName === null) {
|
||||
return null;
|
||||
}
|
||||
$fileContent = $this->smartFileSystem->readFile($fileName);
|
||||
|
@ -173,7 +173,7 @@ final class AstResolver
|
|||
return $this->functionsByName[$phpFunctionReflection->getName()];
|
||||
}
|
||||
$fileName = $phpFunctionReflection->getFileName();
|
||||
if ($fileName === \false) {
|
||||
if ($fileName === null) {
|
||||
return null;
|
||||
}
|
||||
$fileContent = $this->smartFileSystem->readFile($fileName);
|
||||
|
|
|
@ -46,7 +46,7 @@ final class ClassLikeAstResolver
|
|||
}
|
||||
$fileName = $classReflection->getFileName();
|
||||
// probably internal class
|
||||
if ($fileName === \false) {
|
||||
if ($fileName === null) {
|
||||
// avoid parsing falsy-file again
|
||||
$this->classLikesByName[$classReflection->getName()] = null;
|
||||
return null;
|
||||
|
|
|
@ -57,7 +57,7 @@ use Rector\Core\ValueObject\MethodName;
|
|||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
use Rector\PostRector\ValueObject\PropertyMetadata;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use RectorPrefix20211027\Symplify\Astral\ValueObject\NodeBuilder\MethodBuilder;
|
||||
|
@ -205,7 +205,7 @@ final class NodeFactory
|
|||
{
|
||||
$paramBuilder = new \RectorPrefix20211027\Symplify\Astral\ValueObject\NodeBuilder\ParamBuilder($name);
|
||||
if ($type !== null) {
|
||||
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PARAM());
|
||||
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM());
|
||||
if ($typeNode !== null) {
|
||||
$paramBuilder->setType($typeNode);
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ final class NodeFactory
|
|||
$propertyFetch = new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable(self::THIS), $propertyName);
|
||||
$return = new \PhpParser\Node\Stmt\Return_($propertyFetch);
|
||||
$methodBuilder->addStmt($return);
|
||||
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::RETURN());
|
||||
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN());
|
||||
if ($typeNode !== null) {
|
||||
$methodBuilder->setReturnType($typeNode);
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ final class NodeFactory
|
|||
$paramBuilder = new \RectorPrefix20211027\Symplify\Astral\ValueObject\NodeBuilder\ParamBuilder($propertyMetadata->getName());
|
||||
$propertyType = $propertyMetadata->getType();
|
||||
if ($propertyType !== null) {
|
||||
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PROPERTY());
|
||||
$typeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($propertyType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY());
|
||||
if ($typeNode !== null) {
|
||||
$paramBuilder->setType($typeNode);
|
||||
}
|
||||
|
@ -547,7 +547,7 @@ final class NodeFactory
|
|||
private function createParamWithType(\PhpParser\Node\Expr\Variable $variable, \PHPStan\Type\Type $type) : \PhpParser\Node\Param
|
||||
{
|
||||
$param = new \PhpParser\Node\Param($variable);
|
||||
$phpParserTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\ValueObject\TypeKind::PARAM());
|
||||
$phpParserTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM());
|
||||
$param->type = $phpParserTypeNode;
|
||||
return $param;
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\PhpParser\Parser;
|
||||
|
||||
use PhpParser\Lexer\Emulative;
|
||||
/**
|
||||
* This Lexer allows Format-perserving AST Transformations.
|
||||
* @see https://github.com/nikic/PHP-Parser/issues/344#issuecomment-298162516
|
||||
*/
|
||||
final class PhpParserLexerFactory
|
||||
{
|
||||
public function create() : \PhpParser\Lexer\Emulative
|
||||
{
|
||||
return new \PhpParser\Lexer\Emulative(['usedAttributes' => ['comments', 'startLine', 'endLine', 'startTokenPos', 'endTokenPos']]);
|
||||
}
|
||||
}
|
|
@ -5,50 +5,30 @@ namespace Rector\Core\PhpParser\Parser;
|
|||
|
||||
use PhpParser\Lexer;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Parser;
|
||||
use PHPStan\Parser\Parser;
|
||||
use Rector\Core\PhpParser\ValueObject\StmtsAndTokens;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
use RectorPrefix20211027\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
final class RectorParser
|
||||
{
|
||||
/**
|
||||
* @var array<string, Stmt[]>
|
||||
*/
|
||||
private $nodesByFile = [];
|
||||
/**
|
||||
* @var \PhpParser\Parser
|
||||
*/
|
||||
private $parser;
|
||||
/**
|
||||
* @var \Symplify\SmartFileSystem\SmartFileSystem
|
||||
*/
|
||||
private $smartFileSystem;
|
||||
/**
|
||||
* @var \PhpParser\Lexer
|
||||
*/
|
||||
private $lexer;
|
||||
public function __construct(\PhpParser\Parser $parser, \RectorPrefix20211027\Symplify\SmartFileSystem\SmartFileSystem $smartFileSystem, \PhpParser\Lexer $lexer)
|
||||
/**
|
||||
* @var \PHPStan\Parser\Parser
|
||||
*/
|
||||
private $parser;
|
||||
public function __construct(\PhpParser\Lexer $lexer, \PHPStan\Parser\Parser $parser)
|
||||
{
|
||||
$this->parser = $parser;
|
||||
$this->smartFileSystem = $smartFileSystem;
|
||||
$this->lexer = $lexer;
|
||||
$this->parser = $parser;
|
||||
}
|
||||
/**
|
||||
* @return Stmt[]
|
||||
*/
|
||||
public function parseFile(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : array
|
||||
{
|
||||
$fileRealPath = $smartFileInfo->getRealPath();
|
||||
if (isset($this->nodesByFile[$fileRealPath])) {
|
||||
return $this->nodesByFile[$fileRealPath];
|
||||
}
|
||||
$fileContent = $this->smartFileSystem->readFile($fileRealPath);
|
||||
$nodes = $this->parser->parse($fileContent);
|
||||
if ($nodes === null) {
|
||||
$nodes = [];
|
||||
}
|
||||
$this->nodesByFile[$fileRealPath] = $nodes;
|
||||
return $this->nodesByFile[$fileRealPath];
|
||||
return $this->parser->parseFile($smartFileInfo->getRealPath());
|
||||
}
|
||||
public function parseFileToStmtsAndTokens(\Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : \Rector\Core\PhpParser\ValueObject\StmtsAndTokens
|
||||
{
|
||||
|
|
|
@ -4,4 +4,4 @@
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit2b781a5eed2336297eb6a436061150c3::getLoader();
|
||||
return ComposerAutoloaderInitb38166aea24885a8c522e6004a52f5ef::getLoader();
|
||||
|
|
|
@ -1922,7 +1922,6 @@ return array(
|
|||
'Rector\\Core\\PhpParser\\Node\\Value\\ValueResolver' => $baseDir . '/src/PhpParser/Node/Value/ValueResolver.php',
|
||||
'Rector\\Core\\PhpParser\\Parser\\InlineCodeParser' => $baseDir . '/src/PhpParser/Parser/InlineCodeParser.php',
|
||||
'Rector\\Core\\PhpParser\\Parser\\NikicPhpParserFactory' => $baseDir . '/src/PhpParser/Parser/NikicPhpParserFactory.php',
|
||||
'Rector\\Core\\PhpParser\\Parser\\PhpParserLexerFactory' => $baseDir . '/src/PhpParser/Parser/PhpParserLexerFactory.php',
|
||||
'Rector\\Core\\PhpParser\\Parser\\RectorParser' => $baseDir . '/src/PhpParser/Parser/RectorParser.php',
|
||||
'Rector\\Core\\PhpParser\\Parser\\SimplePhpParser' => $baseDir . '/src/PhpParser/Parser/SimplePhpParser.php',
|
||||
'Rector\\Core\\PhpParser\\Printer\\BetterStandardPrinter' => $baseDir . '/src/PhpParser/Printer/BetterStandardPrinter.php',
|
||||
|
@ -2550,6 +2549,7 @@ return array(
|
|||
'Rector\\PHPOffice\\ValueObject\\PHPExcelMethodDefaultValues' => $vendorDir . '/rector/rector-phpoffice/src/ValueObject/PHPExcelMethodDefaultValues.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\Contract\\TypeMapperInterface' => $baseDir . '/packages/PHPStanStaticTypeMapper/Contract/TypeMapperInterface.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\DoctrineTypeAnalyzer' => $baseDir . '/packages/PHPStanStaticTypeMapper/DoctrineTypeAnalyzer.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\Enum\\TypeKind' => $baseDir . '/packages/PHPStanStaticTypeMapper/Enum/TypeKind.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\PHPStanStaticTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/PHPStanStaticTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeAnalyzer\\BoolUnionTypeAnalyzer' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeAnalyzer/BoolUnionTypeAnalyzer.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeAnalyzer\\UnionTypeAnalyzer' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeAnalyzer/UnionTypeAnalyzer.php',
|
||||
|
@ -2582,7 +2582,6 @@ return array(
|
|||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\UnionTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/UnionTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\VoidTypeMapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/TypeMapper/VoidTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\Utils\\TypeUnwrapper' => $baseDir . '/packages/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\ValueObject\\TypeKind' => $baseDir . '/packages/PHPStanStaticTypeMapper/ValueObject/TypeKind.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\ValueObject\\UnionTypeAnalysis' => $baseDir . '/packages/PHPStanStaticTypeMapper/ValueObject/UnionTypeAnalysis.php',
|
||||
'Rector\\PHPUnit\\Naming\\TestClassNameResolver' => $vendorDir . '/rector/rector-phpunit/src/Naming/TestClassNameResolver.php',
|
||||
'Rector\\PHPUnit\\NodeAnalyzer\\ExpectationAnalyzer' => $vendorDir . '/rector/rector-phpunit/src/NodeAnalyzer/ExpectationAnalyzer.php',
|
||||
|
@ -2662,7 +2661,6 @@ return array(
|
|||
'Rector\\PSR4\\Rector\\Namespace_\\MultipleClassFileToPsr4ClassesRector' => $baseDir . '/rules/PSR4/Rector/Namespace_/MultipleClassFileToPsr4ClassesRector.php',
|
||||
'Rector\\Php52\\Rector\\Property\\VarToPublicPropertyRector' => $baseDir . '/rules/Php52/Rector/Property/VarToPublicPropertyRector.php',
|
||||
'Rector\\Php52\\Rector\\Switch_\\ContinueToBreakInSwitchRector' => $baseDir . '/rules/Php52/Rector/Switch_/ContinueToBreakInSwitchRector.php',
|
||||
'Rector\\Php53\\Rector\\AssignRef\\ClearReturnNewByReferenceRector' => $baseDir . '/rules/Php53/Rector/AssignRef/ClearReturnNewByReferenceRector.php',
|
||||
'Rector\\Php53\\Rector\\FuncCall\\DirNameFileConstantToDirConstantRector' => $baseDir . '/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php',
|
||||
'Rector\\Php53\\Rector\\Ternary\\TernaryToElvisRector' => $baseDir . '/rules/Php53/Rector/Ternary/TernaryToElvisRector.php',
|
||||
'Rector\\Php53\\Rector\\Variable\\ReplaceHttpServerVarsByServerRector' => $baseDir . '/rules/Php53/Rector/Variable/ReplaceHttpServerVarsByServerRector.php',
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit2b781a5eed2336297eb6a436061150c3
|
||||
class ComposerAutoloaderInitb38166aea24885a8c522e6004a52f5ef
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,15 +22,15 @@ class ComposerAutoloaderInit2b781a5eed2336297eb6a436061150c3
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit2b781a5eed2336297eb6a436061150c3', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitb38166aea24885a8c522e6004a52f5ef', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit2b781a5eed2336297eb6a436061150c3', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitb38166aea24885a8c522e6004a52f5ef', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit2b781a5eed2336297eb6a436061150c3::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitb38166aea24885a8c522e6004a52f5ef::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
|
@ -42,19 +42,19 @@ class ComposerAutoloaderInit2b781a5eed2336297eb6a436061150c3
|
|||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit2b781a5eed2336297eb6a436061150c3::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInitb38166aea24885a8c522e6004a52f5ef::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire2b781a5eed2336297eb6a436061150c3($fileIdentifier, $file);
|
||||
composerRequireb38166aea24885a8c522e6004a52f5ef($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire2b781a5eed2336297eb6a436061150c3($fileIdentifier, $file)
|
||||
function composerRequireb38166aea24885a8c522e6004a52f5ef($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit2b781a5eed2336297eb6a436061150c3
|
||||
class ComposerStaticInitb38166aea24885a8c522e6004a52f5ef
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
|
@ -2282,7 +2282,6 @@ class ComposerStaticInit2b781a5eed2336297eb6a436061150c3
|
|||
'Rector\\Core\\PhpParser\\Node\\Value\\ValueResolver' => __DIR__ . '/../..' . '/src/PhpParser/Node/Value/ValueResolver.php',
|
||||
'Rector\\Core\\PhpParser\\Parser\\InlineCodeParser' => __DIR__ . '/../..' . '/src/PhpParser/Parser/InlineCodeParser.php',
|
||||
'Rector\\Core\\PhpParser\\Parser\\NikicPhpParserFactory' => __DIR__ . '/../..' . '/src/PhpParser/Parser/NikicPhpParserFactory.php',
|
||||
'Rector\\Core\\PhpParser\\Parser\\PhpParserLexerFactory' => __DIR__ . '/../..' . '/src/PhpParser/Parser/PhpParserLexerFactory.php',
|
||||
'Rector\\Core\\PhpParser\\Parser\\RectorParser' => __DIR__ . '/../..' . '/src/PhpParser/Parser/RectorParser.php',
|
||||
'Rector\\Core\\PhpParser\\Parser\\SimplePhpParser' => __DIR__ . '/../..' . '/src/PhpParser/Parser/SimplePhpParser.php',
|
||||
'Rector\\Core\\PhpParser\\Printer\\BetterStandardPrinter' => __DIR__ . '/../..' . '/src/PhpParser/Printer/BetterStandardPrinter.php',
|
||||
|
@ -2910,6 +2909,7 @@ class ComposerStaticInit2b781a5eed2336297eb6a436061150c3
|
|||
'Rector\\PHPOffice\\ValueObject\\PHPExcelMethodDefaultValues' => __DIR__ . '/..' . '/rector/rector-phpoffice/src/ValueObject/PHPExcelMethodDefaultValues.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\Contract\\TypeMapperInterface' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/Contract/TypeMapperInterface.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\DoctrineTypeAnalyzer' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/DoctrineTypeAnalyzer.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\Enum\\TypeKind' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/Enum/TypeKind.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\PHPStanStaticTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/PHPStanStaticTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeAnalyzer\\BoolUnionTypeAnalyzer' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeAnalyzer/BoolUnionTypeAnalyzer.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeAnalyzer\\UnionTypeAnalyzer' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeAnalyzer/UnionTypeAnalyzer.php',
|
||||
|
@ -2942,7 +2942,6 @@ class ComposerStaticInit2b781a5eed2336297eb6a436061150c3
|
|||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\UnionTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/UnionTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\TypeMapper\\VoidTypeMapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/TypeMapper/VoidTypeMapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\Utils\\TypeUnwrapper' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/Utils/TypeUnwrapper.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\ValueObject\\TypeKind' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/ValueObject/TypeKind.php',
|
||||
'Rector\\PHPStanStaticTypeMapper\\ValueObject\\UnionTypeAnalysis' => __DIR__ . '/../..' . '/packages/PHPStanStaticTypeMapper/ValueObject/UnionTypeAnalysis.php',
|
||||
'Rector\\PHPUnit\\Naming\\TestClassNameResolver' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Naming/TestClassNameResolver.php',
|
||||
'Rector\\PHPUnit\\NodeAnalyzer\\ExpectationAnalyzer' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeAnalyzer/ExpectationAnalyzer.php',
|
||||
|
@ -3022,7 +3021,6 @@ class ComposerStaticInit2b781a5eed2336297eb6a436061150c3
|
|||
'Rector\\PSR4\\Rector\\Namespace_\\MultipleClassFileToPsr4ClassesRector' => __DIR__ . '/../..' . '/rules/PSR4/Rector/Namespace_/MultipleClassFileToPsr4ClassesRector.php',
|
||||
'Rector\\Php52\\Rector\\Property\\VarToPublicPropertyRector' => __DIR__ . '/../..' . '/rules/Php52/Rector/Property/VarToPublicPropertyRector.php',
|
||||
'Rector\\Php52\\Rector\\Switch_\\ContinueToBreakInSwitchRector' => __DIR__ . '/../..' . '/rules/Php52/Rector/Switch_/ContinueToBreakInSwitchRector.php',
|
||||
'Rector\\Php53\\Rector\\AssignRef\\ClearReturnNewByReferenceRector' => __DIR__ . '/../..' . '/rules/Php53/Rector/AssignRef/ClearReturnNewByReferenceRector.php',
|
||||
'Rector\\Php53\\Rector\\FuncCall\\DirNameFileConstantToDirConstantRector' => __DIR__ . '/../..' . '/rules/Php53/Rector/FuncCall/DirNameFileConstantToDirConstantRector.php',
|
||||
'Rector\\Php53\\Rector\\Ternary\\TernaryToElvisRector' => __DIR__ . '/../..' . '/rules/Php53/Rector/Ternary/TernaryToElvisRector.php',
|
||||
'Rector\\Php53\\Rector\\Variable\\ReplaceHttpServerVarsByServerRector' => __DIR__ . '/../..' . '/rules/Php53/Rector/Variable/ReplaceHttpServerVarsByServerRector.php',
|
||||
|
@ -3893,9 +3891,9 @@ class ComposerStaticInit2b781a5eed2336297eb6a436061150c3
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit2b781a5eed2336297eb6a436061150c3::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit2b781a5eed2336297eb6a436061150c3::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit2b781a5eed2336297eb6a436061150c3::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitb38166aea24885a8c522e6004a52f5ef::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitb38166aea24885a8c522e6004a52f5ef::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitb38166aea24885a8c522e6004a52f5ef::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
|
@ -828,17 +828,17 @@
|
|||
},
|
||||
{
|
||||
"name": "phpstan\/phpstan",
|
||||
"version": "0.12.99",
|
||||
"version_normalized": "0.12.99.0",
|
||||
"version": "dev-master",
|
||||
"version_normalized": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/phpstan\/phpstan.git",
|
||||
"reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7"
|
||||
"reference": "57f294a4fbd63ae01b3426741b6c4cfd9538bf48"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan\/zipball\/b4d40f1d759942f523be267a1bab6884f46ca3f7",
|
||||
"reference": "b4d40f1d759942f523be267a1bab6884f46ca3f7",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan\/zipball\/57f294a4fbd63ae01b3426741b6c4cfd9538bf48",
|
||||
"reference": "57f294a4fbd63ae01b3426741b6c4cfd9538bf48",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -847,7 +847,8 @@
|
|||
"conflict": {
|
||||
"phpstan\/phpstan-shim": "*"
|
||||
},
|
||||
"time": "2021-09-12T20:09:55+00:00",
|
||||
"time": "2021-10-27T16:36:44+00:00",
|
||||
"default-branch": true,
|
||||
"bin": [
|
||||
"phpstan",
|
||||
"phpstan.phar"
|
||||
|
@ -855,7 +856,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.12-dev"
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
|
@ -871,7 +872,7 @@
|
|||
"description": "PHPStan - PHP Static Analysis Tool",
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/phpstan\/phpstan\/issues",
|
||||
"source": "https:\/\/github.com\/phpstan\/phpstan\/tree\/0.12.99"
|
||||
"source": "https:\/\/github.com\/phpstan\/phpstan\/tree\/master"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
|
@ -895,36 +896,38 @@
|
|||
},
|
||||
{
|
||||
"name": "phpstan\/phpstan-phpunit",
|
||||
"version": "0.12.22",
|
||||
"version_normalized": "0.12.22.0",
|
||||
"version": "dev-master",
|
||||
"version_normalized": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/phpstan\/phpstan-phpunit.git",
|
||||
"reference": "7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc"
|
||||
"reference": "9eb88c9f689003a8a2a5ae9e010338ee94dc39b3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan-phpunit\/zipball\/7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc",
|
||||
"reference": "7c01ef93bf128b4ac8bdad38c54b2a4fd6b0b3cc",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan-phpunit\/zipball\/9eb88c9f689003a8a2a5ae9e010338ee94dc39b3",
|
||||
"reference": "9eb88c9f689003a8a2a5ae9e010338ee94dc39b3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0",
|
||||
"phpstan\/phpstan": "^0.12.92"
|
||||
"phpstan\/phpstan": "^1.0"
|
||||
},
|
||||
"conflict": {
|
||||
"phpunit\/phpunit": "<7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"nikic\/php-parser": "^4.13.0",
|
||||
"php-parallel-lint\/php-parallel-lint": "^1.2",
|
||||
"phpstan\/phpstan-strict-rules": "^0.12.6",
|
||||
"phpstan\/phpstan-strict-rules": "^1.0",
|
||||
"phpunit\/phpunit": "^9.5"
|
||||
},
|
||||
"time": "2021-08-12T10:53:43+00:00",
|
||||
"time": "2021-10-14T08:03:54+00:00",
|
||||
"default-branch": true,
|
||||
"type": "phpstan-extension",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.12-dev"
|
||||
"dev-master": "1.0-dev"
|
||||
},
|
||||
"phpstan": {
|
||||
"includes": [
|
||||
|
@ -946,7 +949,7 @@
|
|||
"description": "PHPUnit extensions and rules for PHPStan",
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/phpstan\/phpstan-phpunit\/issues",
|
||||
"source": "https:\/\/github.com\/phpstan\/phpstan-phpunit\/tree\/0.12.22"
|
||||
"source": "https:\/\/github.com\/phpstan\/phpstan-phpunit\/tree\/master"
|
||||
},
|
||||
"install-path": "..\/phpstan\/phpstan-phpunit"
|
||||
},
|
||||
|
@ -3806,19 +3809,19 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/symplify\/astral.git",
|
||||
"reference": "e583ee48dbb665d42f93921b496b660758c593a9"
|
||||
"reference": "aba9535e02a5e6a6df96e303665cda29ed3dfbf3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/symplify\/astral\/zipball\/e583ee48dbb665d42f93921b496b660758c593a9",
|
||||
"reference": "e583ee48dbb665d42f93921b496b660758c593a9",
|
||||
"url": "https:\/\/api.github.com\/repos\/symplify\/astral\/zipball\/aba9535e02a5e6a6df96e303665cda29ed3dfbf3",
|
||||
"reference": "aba9535e02a5e6a6df96e303665cda29ed3dfbf3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"nette\/utils": "^3.2",
|
||||
"nikic\/php-parser": "^4.13",
|
||||
"php": ">=8.0",
|
||||
"phpstan\/phpstan": "^0.12.99",
|
||||
"phpstan\/phpstan": "1.0.x-dev as 0.12.99",
|
||||
"symfony\/dependency-injection": "^5.3|^6.0",
|
||||
"symfony\/http-kernel": "^5.3|^6.0",
|
||||
"symplify\/package-builder": "^9.5",
|
||||
|
@ -3858,7 +3861,7 @@
|
|||
"phpunit\/phpunit": "^9.5",
|
||||
"symplify\/easy-testing": "^9.5"
|
||||
},
|
||||
"time": "2021-10-25T13:49:49+00:00",
|
||||
"time": "2021-10-27T18:06:39+00:00",
|
||||
"default-branch": true,
|
||||
"type": "phpstan-extension",
|
||||
"extra": {
|
||||
|
@ -4258,12 +4261,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/symplify\/easy-testing.git",
|
||||
"reference": "4c7c51286fcfaad5e62f9b9fc4de24c12411e78c"
|
||||
"reference": "a340e9c3e85dbdb70919568d2af5629b1dadfa9d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/symplify\/easy-testing\/zipball\/4c7c51286fcfaad5e62f9b9fc4de24c12411e78c",
|
||||
"reference": "4c7c51286fcfaad5e62f9b9fc4de24c12411e78c",
|
||||
"url": "https:\/\/api.github.com\/repos\/symplify\/easy-testing\/zipball\/a340e9c3e85dbdb70919568d2af5629b1dadfa9d",
|
||||
"reference": "a340e9c3e85dbdb70919568d2af5629b1dadfa9d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4309,7 +4312,7 @@
|
|||
"require-dev": {
|
||||
"phpunit\/phpunit": "^9.5"
|
||||
},
|
||||
"time": "2021-10-11T15:00:27+00:00",
|
||||
"time": "2021-10-27T18:06:40+00:00",
|
||||
"default-branch": true,
|
||||
"bin": [
|
||||
"bin\/easy-testing"
|
||||
|
@ -4353,12 +4356,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/symplify\/package-builder.git",
|
||||
"reference": "796fd1587641361ff3774c4d95926d5041202c39"
|
||||
"reference": "a18fc02505ebd83face63b083130acb6aaa63582"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/symplify\/package-builder\/zipball\/796fd1587641361ff3774c4d95926d5041202c39",
|
||||
"reference": "796fd1587641361ff3774c4d95926d5041202c39",
|
||||
"url": "https:\/\/api.github.com\/repos\/symplify\/package-builder\/zipball\/a18fc02505ebd83face63b083130acb6aaa63582",
|
||||
"reference": "a18fc02505ebd83face63b083130acb6aaa63582",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -4406,7 +4409,7 @@
|
|||
"require-dev": {
|
||||
"phpunit\/phpunit": "^9.5"
|
||||
},
|
||||
"time": "2021-10-14T12:38:55+00:00",
|
||||
"time": "2021-10-27T18:06:49+00:00",
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"extra": {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -7,14 +7,15 @@
|
|||
],
|
||||
"require": {
|
||||
"php": "^7.1 || ^8.0",
|
||||
"phpstan\/phpstan": "^0.12.92"
|
||||
"phpstan\/phpstan": "^1.0"
|
||||
},
|
||||
"conflict": {
|
||||
"phpunit\/phpunit": "<7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"nikic\/php-parser": "^4.13.0",
|
||||
"php-parallel-lint\/php-parallel-lint": "^1.2",
|
||||
"phpstan\/phpstan-strict-rules": "^0.12.6",
|
||||
"phpstan\/phpstan-strict-rules": "^1.0",
|
||||
"phpunit\/phpunit": "^9.5"
|
||||
},
|
||||
"config": {
|
||||
|
@ -25,7 +26,7 @@
|
|||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.12-dev"
|
||||
"dev-master": "1.0-dev"
|
||||
},
|
||||
"phpstan": {
|
||||
"includes": [
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
conditionalTags:
|
||||
PHPStan\Rules\PHPUnit\ShouldCallParentMethodsRule:
|
||||
phpstan.rules.rule: %featureToggles.bleedingEdge%
|
||||
|
||||
services:
|
||||
-
|
||||
class: PHPStan\Rules\PHPUnit\ShouldCallParentMethodsRule
|
||||
|
||||
rules:
|
||||
- PHPStan\Rules\PHPUnit\AssertSameBooleanExpectedRule
|
||||
- PHPStan\Rules\PHPUnit\AssertSameNullExpectedRule
|
||||
- PHPStan\Rules\PHPUnit\AssertSameWithCountRule
|
||||
- PHPStan\Rules\PHPUnit\MockMethodCallRule
|
||||
- PHPStan\Rules\PHPUnit\ShouldCallParentMethodsRule
|
||||
|
|
|
@ -22,13 +22,13 @@ class AssertSameBooleanExpectedRule implements \PHPStan\Rules\Rule
|
|||
}
|
||||
/** @var \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */
|
||||
$node = $node;
|
||||
if (\count($node->args) < 2) {
|
||||
if (\count($node->getArgs()) < 2) {
|
||||
return [];
|
||||
}
|
||||
if (!$node->name instanceof \PhpParser\Node\Identifier || \strtolower($node->name->name) !== 'assertsame') {
|
||||
return [];
|
||||
}
|
||||
$leftType = $scope->getType($node->args[0]->value);
|
||||
$leftType = $scope->getType($node->getArgs()[0]->value);
|
||||
if (!$leftType instanceof \PHPStan\Type\Constant\ConstantBooleanType) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -22,13 +22,13 @@ class AssertSameNullExpectedRule implements \PHPStan\Rules\Rule
|
|||
}
|
||||
/** @var \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */
|
||||
$node = $node;
|
||||
if (\count($node->args) < 2) {
|
||||
if (\count($node->getArgs()) < 2) {
|
||||
return [];
|
||||
}
|
||||
if (!$node->name instanceof \PhpParser\Node\Identifier || \strtolower($node->name->name) !== 'assertsame') {
|
||||
return [];
|
||||
}
|
||||
$leftType = $scope->getType($node->args[0]->value);
|
||||
$leftType = $scope->getType($node->getArgs()[0]->value);
|
||||
if ($leftType instanceof \PHPStan\Type\NullType) {
|
||||
return ['You should use assertNull() instead of assertSame(null, $actual).'];
|
||||
}
|
||||
|
|
|
@ -22,17 +22,17 @@ class AssertSameWithCountRule implements \PHPStan\Rules\Rule
|
|||
}
|
||||
/** @var \PhpParser\Node\Expr\MethodCall|\PhpParser\Node\Expr\StaticCall $node */
|
||||
$node = $node;
|
||||
if (\count($node->args) < 2) {
|
||||
if (\count($node->getArgs()) < 2) {
|
||||
return [];
|
||||
}
|
||||
if (!$node->name instanceof \PhpParser\Node\Identifier || \strtolower($node->name->name) !== 'assertsame') {
|
||||
return [];
|
||||
}
|
||||
$right = $node->args[1]->value;
|
||||
$right = $node->getArgs()[1]->value;
|
||||
if ($right instanceof \PhpParser\Node\Expr\FuncCall && $right->name instanceof \PhpParser\Node\Name && \strtolower($right->name->toString()) === 'count') {
|
||||
return ['You should use assertCount($expectedCount, $variable) instead of assertSame($expectedCount, count($variable)).'];
|
||||
}
|
||||
if ($right instanceof \PhpParser\Node\Expr\MethodCall && $right->name instanceof \PhpParser\Node\Identifier && \strtolower($right->name->toString()) === 'count' && \count($right->args) === 0) {
|
||||
if ($right instanceof \PhpParser\Node\Expr\MethodCall && $right->name instanceof \PhpParser\Node\Identifier && \strtolower($right->name->toString()) === 'count' && \count($right->getArgs()) === 0) {
|
||||
$type = $scope->getType($right->var);
|
||||
if ((new \PHPStan\Type\ObjectType(\Countable::class))->isSuperTypeOf($type)->yes()) {
|
||||
return ['You should use assertCount($expectedCount, $variable) instead of assertSame($expectedCount, $variable->count()).'];
|
||||
|
|
|
@ -27,10 +27,10 @@ class MockMethodCallRule implements \PHPStan\Rules\Rule
|
|||
if (!$node->name instanceof \PhpParser\Node\Identifier || $node->name->name !== 'method') {
|
||||
return [];
|
||||
}
|
||||
if (\count($node->args) < 1) {
|
||||
if (\count($node->getArgs()) < 1) {
|
||||
return [];
|
||||
}
|
||||
$argType = $scope->getType($node->args[0]->value);
|
||||
$argType = $scope->getType($node->getArgs()[0]->value);
|
||||
if (!$argType instanceof \PHPStan\Type\Constant\ConstantStringType) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ class ShouldCallParentMethodsRule implements \PHPStan\Rules\Rule
|
|||
return [];
|
||||
}
|
||||
$parentClass = $scope->getClassReflection()->getParentClass();
|
||||
if ($parentClass === \false) {
|
||||
if ($parentClass === null) {
|
||||
return [];
|
||||
}
|
||||
if (!$parentClass->hasNativeMethod($methodName)) {
|
||||
|
|
|
@ -21,11 +21,11 @@ class AssertFunctionTypeSpecifyingExtension implements \PHPStan\Type\FunctionTyp
|
|||
}
|
||||
public function isFunctionSupported(\PHPStan\Reflection\FunctionReflection $functionReflection, \PhpParser\Node\Expr\FuncCall $node, \PHPStan\Analyser\TypeSpecifierContext $context) : bool
|
||||
{
|
||||
return \PHPStan\Type\PHPUnit\Assert\AssertTypeSpecifyingExtensionHelper::isSupported($this->trimName($functionReflection->getName()), $node->args);
|
||||
return \PHPStan\Type\PHPUnit\Assert\AssertTypeSpecifyingExtensionHelper::isSupported($this->trimName($functionReflection->getName()), $node->getArgs());
|
||||
}
|
||||
public function specifyTypes(\PHPStan\Reflection\FunctionReflection $functionReflection, \PhpParser\Node\Expr\FuncCall $node, \PHPStan\Analyser\Scope $scope, \PHPStan\Analyser\TypeSpecifierContext $context) : \PHPStan\Analyser\SpecifiedTypes
|
||||
{
|
||||
return \PHPStan\Type\PHPUnit\Assert\AssertTypeSpecifyingExtensionHelper::specifyTypes($this->typeSpecifier, $scope, $this->trimName($functionReflection->getName()), $node->args);
|
||||
return \PHPStan\Type\PHPUnit\Assert\AssertTypeSpecifyingExtensionHelper::specifyTypes($this->typeSpecifier, $scope, $this->trimName($functionReflection->getName()), $node->getArgs());
|
||||
}
|
||||
private function trimName(string $functionName) : string
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue