mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 05:48:21 +01:00
Updated Rector to commit 640a49bb8dded439c57723ea4d047f1c9782b78f
640a49bb8d
move collectors to src/Collector namespace for easy discovery, add MockedClassCollector (#5055)
This commit is contained in:
parent
d7242c6a67
commit
95d1af621f
@ -8,13 +8,13 @@ use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PHPStan\Node\CollectedDataNode;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use Rector\Core\Collector\ParentClassCollector;
|
||||
use Rector\Core\NodeAnalyzer\ClassAnalyzer;
|
||||
use Rector\Core\NodeAnalyzer\DoctrineEntityAnalyzer;
|
||||
use Rector\Core\Rector\AbstractCollectorRector;
|
||||
use Rector\Core\Reflection\ReflectionResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\Privatization\NodeManipulator\VisibilityManipulator;
|
||||
use Rector\TypeDeclaration\Collector\ParentClassCollector;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
* @see \Rector\Tests\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenCollectorRector\FinalizeClassesWithoutChildrenCollectorRectorTest
|
||||
|
@ -288,11 +288,11 @@ CODE_SAMPLE
|
||||
/**
|
||||
* @return array<array-key, Attribute>
|
||||
*/
|
||||
private function getPhpDataProviderAttributes(ClassMethod $node) : array
|
||||
private function getPhpDataProviderAttributes(ClassMethod $classMethod) : array
|
||||
{
|
||||
$attributeName = 'PHPUnit\\Framework\\Attributes\\DataProvider';
|
||||
/** @var AttributeGroup[] $attrGroups */
|
||||
$attrGroups = $node->attrGroups;
|
||||
$attrGroups = $classMethod->attrGroups;
|
||||
$dataProviders = [];
|
||||
foreach ($attrGroups as $attrGroup) {
|
||||
foreach ($attrGroup->attrs as $attribute) {
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '0c0e5eeb4fd337d98f27224d0b46bfd310405dfd';
|
||||
public const PACKAGE_VERSION = '640a49bb8dded439c57723ea4d047f1c9782b78f';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-09-30 10:58:42';
|
||||
public const RELEASE_DATE = '2023-09-30 09:16:21';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
45
src/Collector/MockedClassCollector.php
Normal file
45
src/Collector/MockedClassCollector.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\Collector;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Collectors\Collector;
|
||||
use PHPStan\Type\Constant\ConstantStringType;
|
||||
/**
|
||||
* @implements Collector<MethodCall, string[]|null>
|
||||
*/
|
||||
final class MockedClassCollector implements Collector
|
||||
{
|
||||
public function getNodeType() : string
|
||||
{
|
||||
return MethodCall::class;
|
||||
}
|
||||
/**
|
||||
* @param MethodCall $node
|
||||
* @return string[]|null
|
||||
*/
|
||||
public function processNode(Node $node, Scope $scope) : ?array
|
||||
{
|
||||
if (!$node->name instanceof Identifier) {
|
||||
return null;
|
||||
}
|
||||
$methodName = $node->name->toString();
|
||||
if (!\in_array($methodName, ['createMock', 'buildMock'], \true)) {
|
||||
return null;
|
||||
}
|
||||
$firstArg = $node->getArgs()[0] ?? null;
|
||||
if (!$firstArg instanceof Arg) {
|
||||
return null;
|
||||
}
|
||||
$mockedClassType = $scope->getType($firstArg->value);
|
||||
if (!$mockedClassType instanceof ConstantStringType) {
|
||||
return null;
|
||||
}
|
||||
return [$mockedClassType->getValue()];
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\TypeDeclaration\Collector;
|
||||
namespace Rector\Core\Collector;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
@ -48,6 +48,7 @@ use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterfac
|
||||
use Rector\Config\RectorConfig;
|
||||
use Rector\Core\Application\ChangedNodeScopeRefresher;
|
||||
use Rector\Core\Application\FileProcessor;
|
||||
use Rector\Core\Collector\ParentClassCollector;
|
||||
use Rector\Core\Configuration\ConfigInitializer;
|
||||
use Rector\Core\Configuration\RenamedClassesDataCollector;
|
||||
use Rector\Core\Console\Command\ListRulesCommand;
|
||||
@ -178,7 +179,6 @@ use Rector\StaticTypeMapper\PhpParser\NullableTypeNodeMapper;
|
||||
use Rector\StaticTypeMapper\PhpParser\StringNodeMapper;
|
||||
use Rector\StaticTypeMapper\PhpParser\UnionTypeNodeMapper;
|
||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||
use Rector\TypeDeclaration\Collector\ParentClassCollector;
|
||||
use Rector\Utils\Command\MissingInSetCommand;
|
||||
use Rector\Utils\Command\OutsideAnySetCommand;
|
||||
use RectorPrefix202309\Symfony\Component\Console\Application;
|
||||
|
3
vendor/composer/autoload_classmap.php
vendored
3
vendor/composer/autoload_classmap.php
vendored
@ -1155,6 +1155,8 @@ return array(
|
||||
'Rector\\Core\\Autoloading\\BootstrapFilesIncluder' => $baseDir . '/src/Autoloading/BootstrapFilesIncluder.php',
|
||||
'Rector\\Core\\Bootstrap\\ExtensionConfigResolver' => $baseDir . '/src/Bootstrap/ExtensionConfigResolver.php',
|
||||
'Rector\\Core\\Bootstrap\\RectorConfigsResolver' => $baseDir . '/src/Bootstrap/RectorConfigsResolver.php',
|
||||
'Rector\\Core\\Collector\\MockedClassCollector' => $baseDir . '/src/Collector/MockedClassCollector.php',
|
||||
'Rector\\Core\\Collector\\ParentClassCollector' => $baseDir . '/src/Collector/ParentClassCollector.php',
|
||||
'Rector\\Core\\Configuration\\ConfigInitializer' => $baseDir . '/src/Configuration/ConfigInitializer.php',
|
||||
'Rector\\Core\\Configuration\\ConfigurationFactory' => $baseDir . '/src/Configuration/ConfigurationFactory.php',
|
||||
'Rector\\Core\\Configuration\\Option' => $baseDir . '/src/Configuration/Option.php',
|
||||
@ -2259,7 +2261,6 @@ return array(
|
||||
'Rector\\TypeDeclaration\\AlreadyAssignDetector\\ConstructorAssignDetector' => $baseDir . '/rules/TypeDeclaration/AlreadyAssignDetector/ConstructorAssignDetector.php',
|
||||
'Rector\\TypeDeclaration\\AlreadyAssignDetector\\NullTypeAssignDetector' => $baseDir . '/rules/TypeDeclaration/AlreadyAssignDetector/NullTypeAssignDetector.php',
|
||||
'Rector\\TypeDeclaration\\AlreadyAssignDetector\\PropertyDefaultAssignDetector' => $baseDir . '/rules/TypeDeclaration/AlreadyAssignDetector/PropertyDefaultAssignDetector.php',
|
||||
'Rector\\TypeDeclaration\\Collector\\ParentClassCollector' => $baseDir . '/rules/TypeDeclaration/Collector/ParentClassCollector.php',
|
||||
'Rector\\TypeDeclaration\\Contract\\PHPStan\\TypeWithClassTypeSpecifierInterface' => $baseDir . '/rules/TypeDeclaration/Contract/PHPStan/TypeWithClassTypeSpecifierInterface.php',
|
||||
'Rector\\TypeDeclaration\\FunctionLikeReturnTypeResolver' => $baseDir . '/rules/TypeDeclaration/FunctionLikeReturnTypeResolver.php',
|
||||
'Rector\\TypeDeclaration\\Guard\\ParamTypeAddGuard' => $baseDir . '/rules/TypeDeclaration/Guard/ParamTypeAddGuard.php',
|
||||
|
3
vendor/composer/autoload_static.php
vendored
3
vendor/composer/autoload_static.php
vendored
@ -1374,6 +1374,8 @@ class ComposerStaticInit46a0b0ac2ea1371bb06be09a20f71c2b
|
||||
'Rector\\Core\\Autoloading\\BootstrapFilesIncluder' => __DIR__ . '/../..' . '/src/Autoloading/BootstrapFilesIncluder.php',
|
||||
'Rector\\Core\\Bootstrap\\ExtensionConfigResolver' => __DIR__ . '/../..' . '/src/Bootstrap/ExtensionConfigResolver.php',
|
||||
'Rector\\Core\\Bootstrap\\RectorConfigsResolver' => __DIR__ . '/../..' . '/src/Bootstrap/RectorConfigsResolver.php',
|
||||
'Rector\\Core\\Collector\\MockedClassCollector' => __DIR__ . '/../..' . '/src/Collector/MockedClassCollector.php',
|
||||
'Rector\\Core\\Collector\\ParentClassCollector' => __DIR__ . '/../..' . '/src/Collector/ParentClassCollector.php',
|
||||
'Rector\\Core\\Configuration\\ConfigInitializer' => __DIR__ . '/../..' . '/src/Configuration/ConfigInitializer.php',
|
||||
'Rector\\Core\\Configuration\\ConfigurationFactory' => __DIR__ . '/../..' . '/src/Configuration/ConfigurationFactory.php',
|
||||
'Rector\\Core\\Configuration\\Option' => __DIR__ . '/../..' . '/src/Configuration/Option.php',
|
||||
@ -2478,7 +2480,6 @@ class ComposerStaticInit46a0b0ac2ea1371bb06be09a20f71c2b
|
||||
'Rector\\TypeDeclaration\\AlreadyAssignDetector\\ConstructorAssignDetector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/AlreadyAssignDetector/ConstructorAssignDetector.php',
|
||||
'Rector\\TypeDeclaration\\AlreadyAssignDetector\\NullTypeAssignDetector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/AlreadyAssignDetector/NullTypeAssignDetector.php',
|
||||
'Rector\\TypeDeclaration\\AlreadyAssignDetector\\PropertyDefaultAssignDetector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/AlreadyAssignDetector/PropertyDefaultAssignDetector.php',
|
||||
'Rector\\TypeDeclaration\\Collector\\ParentClassCollector' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Collector/ParentClassCollector.php',
|
||||
'Rector\\TypeDeclaration\\Contract\\PHPStan\\TypeWithClassTypeSpecifierInterface' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Contract/PHPStan/TypeWithClassTypeSpecifierInterface.php',
|
||||
'Rector\\TypeDeclaration\\FunctionLikeReturnTypeResolver' => __DIR__ . '/../..' . '/rules/TypeDeclaration/FunctionLikeReturnTypeResolver.php',
|
||||
'Rector\\TypeDeclaration\\Guard\\ParamTypeAddGuard' => __DIR__ . '/../..' . '/rules/TypeDeclaration/Guard/ParamTypeAddGuard.php',
|
||||
|
Loading…
x
Reference in New Issue
Block a user