mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-21 16:02:23 +02:00
use new Symplify 7
This commit is contained in:
parent
a3693df310
commit
53eda0bb8e
@ -2,23 +2,26 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Bootstrap\ConfigResolver;
|
||||
use Rector\Bootstrap\SetOptionResolver;
|
||||
use Rector\Configuration\Configuration;
|
||||
use Rector\DependencyInjection\RectorContainerFactory;
|
||||
use Rector\Exception\Configuration\SetNotFoundException;
|
||||
use Rector\Set\Set;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symplify\PackageBuilder\Configuration\ConfigFileFinder;
|
||||
use Symplify\EasyCodingStandard\Exception\Configuration\SetNotFoundException;
|
||||
use Symplify\PackageBuilder\Console\ShellCode;
|
||||
use Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory;
|
||||
use Symplify\SetConfigResolver\ConfigResolver;
|
||||
|
||||
$configs = [];
|
||||
$configResolver = new ConfigResolver();
|
||||
|
||||
// Detect configuration from --set
|
||||
try {
|
||||
$input = new ArgvInput();
|
||||
$setOptionResolver = new SetOptionResolver();
|
||||
$configs[] = $setOptionResolver->detectFromInputAndDirectory($input, Set::SET_DIRECTORY);
|
||||
|
||||
$setConfig = $configResolver->resolveSetFromInputAndDirectory($input, Set::SET_DIRECTORY);
|
||||
if ($setConfig !== null) {
|
||||
$configs[] = $setConfig;
|
||||
}
|
||||
} catch (SetNotFoundException $setNotFoundException) {
|
||||
$symfonyStyle = (new SymfonyStyleFactory())->create();
|
||||
$symfonyStyle->error($setNotFoundException->getMessage());
|
||||
@ -26,17 +29,23 @@ try {
|
||||
}
|
||||
|
||||
// And from --config or default one
|
||||
ConfigFileFinder::detectFromInput('rector', new ArgvInput());
|
||||
$configs[] = ConfigFileFinder::provide('rector', ['rector.yml', 'rector.yaml']);
|
||||
|
||||
// remove empty values
|
||||
$configs = array_filter($configs);
|
||||
$inputOrFallbackConfig = $configResolver->resolveFromInputWithFallback($input, ['rector.yml', 'rector.yaml']);
|
||||
if ($inputOrFallbackConfig !== null) {
|
||||
$configs[] = $inputOrFallbackConfig;
|
||||
}
|
||||
|
||||
// resolve: parameters > sets
|
||||
$configResolver = new ConfigResolver();
|
||||
$parameterSetsConfigs = $configResolver->resolveFromParameterSetsFromConfigFiles($configs);
|
||||
$configs = array_merge($configs, $parameterSetsConfigs);
|
||||
$parameterSetsConfigs = $configResolver->resolveFromParameterSetsFromConfigFiles($configs, Set::SET_DIRECTORY);
|
||||
if ($parameterSetsConfigs !== []) {
|
||||
$configs = array_merge($configs, $parameterSetsConfigs);
|
||||
}
|
||||
|
||||
// Build DI container
|
||||
$rectorContainerFactory = new RectorContainerFactory();
|
||||
return $rectorContainerFactory->createFromConfigs($configs);
|
||||
$container = $rectorContainerFactory->createFromConfigs($configs);
|
||||
|
||||
/** @var Configuration $configuration */
|
||||
$configuration = $container->get(Configuration::class);
|
||||
$configuration->setFirstResolverConfig($configResolver->getFirstResolvedConfig());
|
||||
|
||||
return $container;
|
||||
|
@ -10,7 +10,7 @@
|
||||
],
|
||||
"bin": ["bin/rector"],
|
||||
"require": {
|
||||
"php": "^7.1",
|
||||
"php": "^7.2",
|
||||
"ext-json": "*",
|
||||
"composer/xdebug-handler": "^1.4",
|
||||
"doctrine/annotations": "^1.8",
|
||||
@ -28,17 +28,18 @@
|
||||
"symfony/dependency-injection": "^4.4|^5.0",
|
||||
"symfony/finder": "^4.4|^5.0",
|
||||
"symfony/process": "^4.4|^5.0",
|
||||
"symplify/package-builder": "^6.1"
|
||||
"symplify/package-builder": "^7.0",
|
||||
"symplify/set-config-resolver": "^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^2.16",
|
||||
"jetbrains/phpstorm-stubs": "^2019.2",
|
||||
"ocramius/package-versions": "^1.4|^1.5",
|
||||
"phpunit/phpunit": "^7.5|^8.4",
|
||||
"symplify/changelog-linker": "^6.1",
|
||||
"symplify/easy-coding-standard": "^6.1",
|
||||
"symplify/monorepo-builder": "^6.1",
|
||||
"symplify/phpstan-extensions": "^6.1",
|
||||
"phpunit/phpunit": "^8.4",
|
||||
"symplify/changelog-linker": "^7.0",
|
||||
"symplify/easy-coding-standard": "^7.0",
|
||||
"symplify/monorepo-builder": "^7.0",
|
||||
"symplify/phpstan-extensions": "^7.0",
|
||||
"thecodingmachine/phpstan-strict-rules": "^0.11.2",
|
||||
"tracy/tracy": "^2.7"
|
||||
},
|
||||
|
@ -37,7 +37,7 @@ services:
|
||||
Symplify\PackageBuilder\Reflection\PrivatesAccessor: ~
|
||||
|
||||
Symplify\PackageBuilder\FileSystem\FileSystem: ~
|
||||
Symplify\PackageBuilder\FileSystem\FinderSanitizer: ~
|
||||
Symplify\SmartFileSystem\Finder\FinderSanitizer: ~
|
||||
|
||||
Symplify\PackageBuilder\Parameter\ParameterProvider: ~
|
||||
Symplify\PackageBuilder\Reflection\PrivatesCaller: ~
|
||||
|
1
ecs.yaml
1
ecs.yaml
@ -51,6 +51,7 @@ parameters:
|
||||
skip:
|
||||
# rather useless
|
||||
Symplify\CodingStandard\Sniffs\DependencyInjection\NoClassInstantiationSniff: ~
|
||||
PhpCsFixer\Fixer\Import\GlobalNamespaceImportFixer: ~
|
||||
|
||||
PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\MethodDeclarationSniff.Underscore: ~
|
||||
Symplify\CodingStandard\Sniffs\Architecture\DuplicatedClassShortNameSniff: ~
|
||||
|
@ -263,7 +263,6 @@ PHP
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node $node
|
||||
* @return string[]|null
|
||||
*/
|
||||
private function resolveAssignPropertyToVariableOrNull(Node $node): ?array
|
||||
|
@ -12,7 +12,7 @@ use Rector\Autodiscovery\ValueObject\NodesWithFileDestinationValueObject;
|
||||
use Rector\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\PSR4\Collector\RenamedClassesCollector;
|
||||
use Rector\PSR4\FileRelocationResolver;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class FileMover
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ use Rector\BetterPhpDocParser\PhpDocNode\Doctrine\Class_\EntityTagValueNode;
|
||||
use Rector\FileSystemRector\Rector\AbstractFileSystemRector;
|
||||
use Rector\RectorDefinition\CodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
/**
|
||||
* @sponsor Thanks https://spaceflow.io/ for sponsoring this rule - visit them on https://github.com/SpaceFlow-app
|
||||
|
@ -10,7 +10,7 @@ use Rector\Autodiscovery\FileMover\FileMover;
|
||||
use Rector\FileSystemRector\Rector\AbstractFileSystemRector;
|
||||
use Rector\RectorDefinition\CodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
/**
|
||||
* @sponsor Thanks https://spaceflow.io/ for sponsoring this rule - visit them on https://github.com/SpaceFlow-app
|
||||
@ -39,7 +39,7 @@ namespace App\Exception;
|
||||
|
||||
interface Rule
|
||||
{
|
||||
}
|
||||
}
|
||||
PHP
|
||||
,
|
||||
<<<'PHP'
|
||||
|
@ -10,7 +10,7 @@ use Rector\Autodiscovery\FileMover\FileMover;
|
||||
use Rector\FileSystemRector\Rector\AbstractFileSystemRector;
|
||||
use Rector\RectorDefinition\ConfiguredCodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
/**
|
||||
* @sponsor Thanks https://spaceflow.io/ for sponsoring this rule - visit them on https://github.com/SpaceFlow-app
|
||||
@ -49,7 +49,7 @@ final class MoveServicesBySuffixToDirectoryRector extends AbstractFileSystemRect
|
||||
{
|
||||
return new RectorDefinition('Move classes by their suffix to their own group/directory', [new ConfiguredCodeSample(
|
||||
<<<'PHP'
|
||||
// file: app/Entity/ProductRepository.php
|
||||
// file: app/Entity/ProductRepository.php
|
||||
|
||||
namespace App/Entity;
|
||||
|
||||
@ -59,7 +59,7 @@ class ProductRepository
|
||||
PHP
|
||||
,
|
||||
<<<'PHP'
|
||||
// file: app/Repository/ProductRepository.php
|
||||
// file: app/Repository/ProductRepository.php
|
||||
|
||||
namespace App/Repository;
|
||||
|
||||
|
@ -11,17 +11,11 @@ trait AttributeTrait
|
||||
*/
|
||||
private $attributes = [];
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAttribute(string $name)
|
||||
{
|
||||
return $this->attributes[$name] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setAttribute(string $name, $value): void
|
||||
{
|
||||
$this->attributes[$name] = $value;
|
||||
|
@ -8,13 +8,7 @@ use PHPStan\PhpDocParser\Ast\Node;
|
||||
|
||||
interface AttributeAwareNodeInterface extends Node
|
||||
{
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setAttribute(string $name, $value): void;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAttribute(string $name);
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ use Rector\BetterPhpDocParser\Printer\PhpDocInfoPrinter;
|
||||
use Rector\FileSystemRector\Parser\FileInfoParser;
|
||||
use Rector\HttpKernel\RectorKernel;
|
||||
use Rector\PhpParser\Node\BetterNodeFinder;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\PackageBuilder\Tests\AbstractKernelTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
abstract class AbstractPhpDocInfoTest extends AbstractKernelTestCase
|
||||
{
|
||||
|
@ -44,9 +44,6 @@ PHP
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getNodeTypes(): array
|
||||
{
|
||||
return [Property::class];
|
||||
@ -54,7 +51,6 @@ PHP
|
||||
|
||||
/**
|
||||
* @param Property $node
|
||||
* @return Node|null
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
@ -78,10 +74,6 @@ PHP
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param String_ $name
|
||||
* @return String_
|
||||
*/
|
||||
private function renameFixtureName(String_ $name): String_
|
||||
{
|
||||
[$prefix, $table] = explode('.', $name->value);
|
||||
|
@ -15,7 +15,7 @@ use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
|
||||
use Rector\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\PHPStan\Type\FullyQualifiedObjectType;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class UseAddingCommander implements CommanderInterface
|
||||
{
|
||||
|
@ -24,7 +24,6 @@ final class ClassNaming
|
||||
|
||||
/**
|
||||
* @param string|Name|Identifier $name
|
||||
* @return string
|
||||
*/
|
||||
public function getShortName($name): string
|
||||
{
|
||||
|
@ -101,9 +101,6 @@ PHP
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $preference
|
||||
*/
|
||||
private function ensurePreferenceIsValid($preference): void
|
||||
{
|
||||
$allowedPreferences = [self::PREFER_THIS, self::PREFER_SELF];
|
||||
|
@ -154,8 +154,6 @@ PHP
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClassMethod $classMethod
|
||||
* @param string $methodName
|
||||
* @param Class_[] $childrenOfClass
|
||||
* @return Param[]
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace Rector\DeadCode\Tests\Rector\ClassMethod\RemoveOverriddenValuesRector\Fixture;
|
||||
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class Keep
|
||||
{
|
||||
|
@ -220,9 +220,6 @@ PHP
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Class_ $class
|
||||
*/
|
||||
private function removeAssignGetRepositoryCalls(Class_ $class): void
|
||||
{
|
||||
$this->traverseNodesWithCallable($class->stmts, function (Node $node) {
|
||||
|
@ -16,9 +16,6 @@ final class TypeStaticProbe
|
||||
*/
|
||||
private static $itemDataByMethodReferenceAndPosition = [];
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public static function recordArgumentType($value, string $method, int $argumentPosition): void
|
||||
{
|
||||
$probeItem = self::createProbeItem($value, $method, $argumentPosition);
|
||||
@ -26,9 +23,6 @@ final class TypeStaticProbe
|
||||
self::recordProbeItem($probeItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public static function createProbeItem($value, string $method, int $argumentPosition): string
|
||||
{
|
||||
$type = self::resolveValueTypeToString($value);
|
||||
@ -37,9 +31,6 @@ final class TypeStaticProbe
|
||||
return implode(';', $data) . PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public static function resolveValueTypeToString($value): string
|
||||
{
|
||||
if (is_object($value)) {
|
||||
|
@ -12,7 +12,6 @@ use stdClass;
|
||||
final class TypeStaticProbeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @dataProvider provideDataForTest()
|
||||
*/
|
||||
public function test($value, string $methodName, int $argumentPosition, string $expectedProbeItem): void
|
||||
@ -27,7 +26,6 @@ final class TypeStaticProbeTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
* @dataProvider provideDataForTestResolveValueTypeToString()
|
||||
*/
|
||||
public function testResolveValueTypeToString($value, string $expectedValueTypeString): void
|
||||
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace Rector\FileSystemRector\Contract;
|
||||
|
||||
use Rector\Contract\Rector\RectorInterface;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
interface FileSystemRectorInterface extends RectorInterface
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace Rector\FileSystemRector;
|
||||
|
||||
use Rector\FileSystemRector\Contract\FileSystemRectorInterface;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class FileSystemFileProcessor
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ namespace Rector\FileSystemRector\Parser;
|
||||
use PhpParser\Node;
|
||||
use Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator;
|
||||
use Rector\PhpParser\Parser\Parser;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class FileInfoParser
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ use Rector\PhpParser\Parser\Parser;
|
||||
use Rector\PhpParser\Printer\BetterStandardPrinter;
|
||||
use Rector\PhpParser\Printer\FormatPerservingPrinter;
|
||||
use Rector\Rector\AbstractRector\AbstractRectorTrait;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
use TypeError;
|
||||
|
||||
abstract class AbstractFileSystemRector implements FileSystemRectorInterface
|
||||
|
@ -93,7 +93,6 @@ PHP
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Class_ $class
|
||||
* @return string[]|null
|
||||
*/
|
||||
private function matchStaticPropertyFetchAndGetSingletonMethodName(Class_ $class): ?array
|
||||
|
@ -8,7 +8,7 @@ use Nette\Utils\FileSystem;
|
||||
use Nette\Utils\Strings;
|
||||
use Rector\FileSystemRector\Rector\AbstractFileSystemRector;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class RenameTesterTestToPHPUnitToTestFileRector extends AbstractFileSystemRector
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Rector\NodeTypeResolver\FileSystem;
|
||||
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class CurrentFileInfoProvider
|
||||
{
|
||||
|
@ -429,9 +429,6 @@ final class NodeTypeResolver
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $requiredType
|
||||
*/
|
||||
private function ensureRequiredTypeIsStringOrObjectType($requiredType, string $location): void
|
||||
{
|
||||
if (is_string($requiredType)) {
|
||||
|
@ -11,9 +11,9 @@ use Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
use Rector\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\PhpParser\Parser\Parser;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use Symplify\PackageBuilder\Tests\AbstractKernelTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
abstract class AbstractNodeTypeResolverTest extends AbstractKernelTestCase
|
||||
{
|
||||
|
@ -65,9 +65,6 @@ PHP
|
||||
return [Node::class];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node $node
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
if ($this->shouldSkip($node)) {
|
||||
|
@ -20,7 +20,7 @@ use Rector\Rector\AbstractPHPUnitRector;
|
||||
use Rector\RectorDefinition\CodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
use Rector\Reflection\ClassMethodReflectionFactory;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
/**
|
||||
* @see https://phpunit.readthedocs.io/en/7.3/annotations.html#doesnotperformassertions
|
||||
|
@ -8,7 +8,7 @@ use Nette\Utils\Strings;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use Rector\ValueObject\RenamedNamespaceValueObject;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class FileRelocationResolver
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ use Rector\PSR4\Collector\RenamedClassesCollector;
|
||||
use Rector\PSR4\Composer\PSR4AutoloadPathsProvider;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
/**
|
||||
* @sponsor Thanks https://spaceflow.io/ for sponsoring this rule - visit them on https://github.com/SpaceFlow-app
|
||||
|
@ -8,8 +8,8 @@ use Iterator;
|
||||
use Rector\HttpKernel\RectorKernel;
|
||||
use Rector\PSR4\FileRelocationResolver;
|
||||
use Rector\PSR4\Tests\Source\SomeFile;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\PackageBuilder\Tests\AbstractKernelTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class FileRelocationResolverTest extends AbstractKernelTestCase
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ use Nette\Utils\FileSystem;
|
||||
use Nette\Utils\Strings;
|
||||
use Rector\FileSystemRector\Rector\AbstractFileSystemRector;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
/**
|
||||
* @see https://gnugat.github.io/2015/09/23/phpunit-with-phpspec.html
|
||||
|
@ -8,7 +8,7 @@ use Rector\FileSystemRector\Rector\AbstractFileSystemRector;
|
||||
use Rector\PSR4\Collector\RenamedClassesCollector;
|
||||
use Rector\PSR4\FileRelocationResolver;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class MoveAndRenameClassRector extends AbstractFileSystemRector
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ use Rector\FileSystemRector\Rector\AbstractFileSystemRector;
|
||||
use Rector\Naming\NamespaceMatcher;
|
||||
use Rector\PSR4\FileRelocationResolver;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class MoveAndRenameNamespaceRector extends AbstractFileSystemRector
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PhpParser\Node\Resolver\NameResolver;
|
||||
use Rector\PhpParser\Printer\BetterStandardPrinter;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class FactoryClassPrinter
|
||||
{
|
||||
|
@ -226,3 +226,7 @@ parameters:
|
||||
- '#Parameter \#1 \$name of method Rector\\CodingStyle\\Naming\\ClassNaming\:\:getShortName\(\) expects PhpParser\\Node\\Identifier\|PhpParser\\Node\\Name\|string, PhpParser\\Node\\Identifier\|null given#'
|
||||
|
||||
- '#Parameter \#1 \$type of method PhpParser\\Builder\\Param\:\:setType\(\) expects PhpParser\\Node\\Name\|PhpParser\\Node\\NullableType\|string, PhpParser\\Node\\Identifier\|PhpParser\\Node\\Name\|PhpParser\\Node\\NullableType\|PhpParser\\Node\\UnionType given#'
|
||||
|
||||
# mixed removed
|
||||
- '#In method "(.*?)", parameter (.*?) has no type\-hint and no @param annotation\. More info\: http\://bit\.ly/usetypehint#'
|
||||
- '#In method "(.*?)", there is no return type and no @return annotation\. More info\: http\://bit\.ly/usetypehint#'
|
||||
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Rector\Application;
|
||||
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class AppliedRectorCollector
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Rector\Application;
|
||||
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class Error
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ use Rector\ConsoleDiffer\DifferAndFormatter;
|
||||
use Rector\Error\ExceptionCorrector;
|
||||
use Rector\PhpParser\Node\Commander\NodeRemovingCommander;
|
||||
use Rector\Reporting\FileDiff;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
use Throwable;
|
||||
|
||||
final class ErrorAndDiffCollector
|
||||
|
@ -14,7 +14,7 @@ use Rector\PhpParser\Parser\Parser;
|
||||
use Rector\PhpParser\Printer\FormatPerservingPrinter;
|
||||
use Rector\Rector\AffectedFilesCollector;
|
||||
use Rector\Stubs\StubLoader;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class FileProcessor
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace Rector\Application\FileSystem;
|
||||
|
||||
use Rector\ValueObject\MovedClassValueObject;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class RemovedAndAddedFilesCollector
|
||||
{
|
||||
|
@ -15,8 +15,8 @@ use Rector\FileSystemRector\FileSystemFileProcessor;
|
||||
use Rector\Testing\Application\EnabledRectorsProvider;
|
||||
use Symfony\Component\Console\Helper\ProgressBar;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Bootstrap;
|
||||
|
||||
use Rector\Set\Set;
|
||||
|
||||
final class ConfigResolver
|
||||
{
|
||||
/**
|
||||
* @var SetOptionResolver
|
||||
*/
|
||||
private $setOptionResolver;
|
||||
|
||||
/**
|
||||
* @var SetsResolver
|
||||
*/
|
||||
private $setsResolver;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setOptionResolver = new SetOptionResolver();
|
||||
$this->setsResolver = new SetsResolver();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $configFiles
|
||||
* @return string[]
|
||||
*/
|
||||
public function resolveFromParameterSetsFromConfigFiles(array $configFiles): array
|
||||
{
|
||||
$configs = [];
|
||||
|
||||
$sets = $this->setsResolver->resolveFromConfigFiles($configFiles);
|
||||
return array_merge($configs, $this->resolveFromSets($sets));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $sets
|
||||
* @return string[]
|
||||
*/
|
||||
private function resolveFromSets(array $sets): array
|
||||
{
|
||||
$configs = [];
|
||||
foreach ($sets as $set) {
|
||||
$configs[] = $this->setOptionResolver->detectFromNameAndDirectory($set, Set::SET_DIRECTORY);
|
||||
}
|
||||
|
||||
return $configs;
|
||||
}
|
||||
}
|
@ -1,202 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Bootstrap;
|
||||
|
||||
use Nette\Utils\ObjectHelpers;
|
||||
use Nette\Utils\Strings;
|
||||
use Rector\Exception\Configuration\SetNotFoundException;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\Finder\SplFileInfo;
|
||||
use Symplify\PackageBuilder\Configuration\ConfigFileFinder;
|
||||
|
||||
final class SetOptionResolver
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $keyName;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $optionNames = [];
|
||||
|
||||
/**
|
||||
* @param string[] $optionNames
|
||||
*/
|
||||
public function __construct(array $optionNames = ['--set', '-s'], string $keyName = 'set')
|
||||
{
|
||||
$this->optionNames = $optionNames;
|
||||
$this->keyName = $keyName;
|
||||
}
|
||||
|
||||
public function detectFromInputAndDirectory(InputInterface $input, string $configDirectory): ?string
|
||||
{
|
||||
$setName = ConfigFileFinder::getOptionValue($input, $this->optionNames);
|
||||
if ($setName === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->detectFromNameAndDirectory($setName, $configDirectory);
|
||||
}
|
||||
|
||||
public function detectFromNameAndDirectory(string $setName, string $configDirectory): string
|
||||
{
|
||||
$nearestMatches = $this->findNearestMatchingFiles($configDirectory, $setName);
|
||||
if (count($nearestMatches) === 0) {
|
||||
$this->reportSetNotFound($configDirectory, $setName);
|
||||
}
|
||||
|
||||
/** @var SplFileInfo $nearestMatch */
|
||||
$nearestMatch = array_shift($nearestMatches);
|
||||
|
||||
return $nearestMatch->getRealPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SplFileInfo[]
|
||||
*/
|
||||
private function findNearestMatchingFiles(string $configDirectory, string $setName): array
|
||||
{
|
||||
$configFiles = Finder::create()
|
||||
->files()
|
||||
->in($configDirectory)
|
||||
->getIterator();
|
||||
|
||||
$nearestMatches = [];
|
||||
|
||||
$setName = Strings::lower($setName);
|
||||
|
||||
// the version must match, so 401 is not compatible with 40
|
||||
$setVersion = $this->matchVersionInTheEnd($setName);
|
||||
|
||||
foreach ($configFiles as $configFile) {
|
||||
// only similar configs, not too far
|
||||
// this allows to match "Symfony.40" to "symfony40" config
|
||||
$fileNameWithoutExtension = pathinfo($configFile->getFilename(), PATHINFO_FILENAME);
|
||||
$distance = levenshtein($fileNameWithoutExtension, $setName);
|
||||
if ($distance > 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($setVersion) {
|
||||
$fileVersion = $this->matchVersionInTheEnd($fileNameWithoutExtension);
|
||||
if ($setVersion !== $fileVersion) {
|
||||
// not a version match
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$nearestMatches[$distance] = $configFile;
|
||||
}
|
||||
|
||||
ksort($nearestMatches);
|
||||
|
||||
return $nearestMatches;
|
||||
}
|
||||
|
||||
private function reportSetNotFound(string $configDirectory, string $setName): void
|
||||
{
|
||||
$allSets = $this->findAllSetsInDirectory($configDirectory);
|
||||
|
||||
$suggestedSet = ObjectHelpers::getSuggestion($allSets, $setName);
|
||||
|
||||
[$versionedSets, $unversionedSets] = $this->separateVersionedAndUnversionedSets($allSets);
|
||||
|
||||
/** @var string[] $unversionedSets */
|
||||
/** @var string[][] $versionedSets */
|
||||
$setsListInString = $this->createSetListInString($unversionedSets, $versionedSets);
|
||||
|
||||
$setNotFoundMessage = sprintf(
|
||||
'%s "%s" was not found.%s%s',
|
||||
ucfirst($this->keyName),
|
||||
$setName,
|
||||
PHP_EOL,
|
||||
$suggestedSet ? sprintf('Did you mean "%s"?', $suggestedSet) . PHP_EOL : ''
|
||||
);
|
||||
|
||||
$pickOneOfMessage = sprintf('Pick "--%s" of:%s%s', $this->keyName, PHP_EOL . PHP_EOL, $setsListInString);
|
||||
|
||||
throw new SetNotFoundException($setNotFoundMessage . PHP_EOL . $pickOneOfMessage);
|
||||
}
|
||||
|
||||
private function matchVersionInTheEnd(string $setName): ?string
|
||||
{
|
||||
$match = Strings::match($setName, '#(?<version>[\d\.]+$)#');
|
||||
if (! $match) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$version = $match['version'];
|
||||
return Strings::replace($version, '#\.#');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function findAllSetsInDirectory(string $configDirectory): array
|
||||
{
|
||||
$finder = Finder::create()
|
||||
->files()
|
||||
->in($configDirectory);
|
||||
|
||||
$sets = [];
|
||||
foreach ($finder->getIterator() as $fileInfo) {
|
||||
$sets[] = $fileInfo->getBasename('.' . $fileInfo->getExtension());
|
||||
}
|
||||
|
||||
sort($sets);
|
||||
|
||||
return array_unique($sets);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $allSets
|
||||
* @return string[][]|string[][][]
|
||||
*/
|
||||
private function separateVersionedAndUnversionedSets(array $allSets): array
|
||||
{
|
||||
$versionedSets = [];
|
||||
$unversionedSets = [];
|
||||
|
||||
foreach ($allSets as $set) {
|
||||
$hasVersion = (bool) Strings::match($set, '#\d#');
|
||||
|
||||
if (! $hasVersion) {
|
||||
$unversionedSets[] = $set;
|
||||
continue;
|
||||
}
|
||||
|
||||
$match = Strings::match($set, '#^(?<set>[A-Za-z\-]+)#');
|
||||
$setWithoutVersion = $match['set'];
|
||||
|
||||
if ($setWithoutVersion !== $set) {
|
||||
$versionedSets[$setWithoutVersion][] = $set;
|
||||
}
|
||||
}
|
||||
|
||||
return [$versionedSets, $unversionedSets];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $unversionedSets
|
||||
* @param string[][] $versionedSets
|
||||
*/
|
||||
private function createSetListInString(array $unversionedSets, array $versionedSets): string
|
||||
{
|
||||
$setsListInString = '';
|
||||
|
||||
foreach ($unversionedSets as $unversionedSet) {
|
||||
$setsListInString .= ' * ' . $unversionedSet . PHP_EOL;
|
||||
}
|
||||
|
||||
foreach ($versionedSets as $groupName => $configNames) {
|
||||
$setsListInString .= ' * ' . $groupName . ': ' . implode(', ', $configNames) . PHP_EOL;
|
||||
}
|
||||
|
||||
return $setsListInString;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Bootstrap;
|
||||
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
final class SetsResolver
|
||||
{
|
||||
/**
|
||||
* @param string[] $configFiles
|
||||
* @return string[]
|
||||
*/
|
||||
public function resolveFromConfigFiles(array $configFiles): array
|
||||
{
|
||||
$sets = [];
|
||||
|
||||
foreach ($configFiles as $configFile) {
|
||||
$configContent = Yaml::parseFile($configFile);
|
||||
$sets += $configContent['parameters']['sets'] ?? [];
|
||||
}
|
||||
|
||||
return $sets;
|
||||
}
|
||||
}
|
@ -11,7 +11,6 @@ use Rector\Exception\Rector\RectorNotFoundOrNotValidRectorClassException;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\Testing\PHPUnit\PHPUnitEnvironment;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symplify\PackageBuilder\Configuration\ConfigFileFinder;
|
||||
|
||||
final class Configuration
|
||||
{
|
||||
@ -57,19 +56,9 @@ final class Configuration
|
||||
$this->setRule($input->getOption(Option::OPTION_RULE));
|
||||
}
|
||||
|
||||
public function setConfigFilePathFromInput(InputInterface $input): void
|
||||
public function setFirstResolverConfig(?string $firstResolvedConfig): void
|
||||
{
|
||||
if ($input->getParameterOption('--config')) {
|
||||
$this->configFilePath = $input->getParameterOption('--config');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($input->getParameterOption('-c')) {
|
||||
$this->configFilePath = $input->getParameterOption('-c');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->configFilePath = ConfigFileFinder::provide('rector');
|
||||
$this->configFilePath = $firstResolvedConfig;
|
||||
}
|
||||
|
||||
public function getConfigFilePath(): ?string
|
||||
|
@ -20,7 +20,7 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symplify\PackageBuilder\Console\Command\CommandNaming;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class Application extends SymfonyApplication
|
||||
{
|
||||
@ -64,8 +64,6 @@ final class Application extends SymfonyApplication
|
||||
unset($xdebug);
|
||||
}
|
||||
|
||||
$this->configuration->setConfigFilePathFromInput($input);
|
||||
|
||||
$shouldFollowByNewline = false;
|
||||
|
||||
// switch working dir
|
||||
|
@ -31,7 +31,7 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symplify\PackageBuilder\Console\Command\CommandNaming;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class ScreenFileCommand extends AbstractCommand
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PhpParser\Printer\BetterStandardPrinter;
|
||||
use Rector\Reporting\FileDiff;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class ConsoleOutputFormatter implements OutputFormatterInterface
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ namespace Rector\DependencyInjection\Loader;
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use Rector\Exception\DependencyInjection\ClassNotFoundException;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class ClassExistenceValidator
|
||||
{
|
||||
|
@ -5,30 +5,36 @@ declare(strict_types=1);
|
||||
namespace Rector\DependencyInjection;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Rector\Bootstrap\SetOptionResolver;
|
||||
use Rector\Exception\ShouldNotHappenException;
|
||||
use Rector\HttpKernel\RectorKernel;
|
||||
use Rector\Set\Set;
|
||||
use Symplify\PackageBuilder\Configuration\ConfigFileFinder;
|
||||
use Symplify\PackageBuilder\Console\Input\InputDetector;
|
||||
use Symplify\SetConfigResolver\SetResolver;
|
||||
|
||||
final class RectorContainerFactory
|
||||
{
|
||||
/**
|
||||
* @var SetOptionResolver
|
||||
* @var SetResolver
|
||||
*/
|
||||
private $setOptionResolver;
|
||||
private $setResolver;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->setOptionResolver = new SetOptionResolver();
|
||||
$this->setResolver = new SetResolver();
|
||||
}
|
||||
|
||||
public function createFromSet(string $set): ContainerInterface
|
||||
{
|
||||
$configFiles = $this->resolveConfigs($set);
|
||||
$configs = [];
|
||||
$configs[] = $this->resolveConfigFromSet($set);
|
||||
|
||||
return $this->createFromConfigs($configFiles);
|
||||
$localConfigs = $this->resolveLocalConfigs();
|
||||
if ($localConfigs !== []) {
|
||||
// local config has priority, so it's first here
|
||||
$configs = array_merge($localConfigs, $configs);
|
||||
}
|
||||
|
||||
return $this->createFromConfigs($configs);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -53,20 +59,31 @@ final class RectorContainerFactory
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function resolveConfigs(string $set): array
|
||||
private function resolveLocalConfigs(): array
|
||||
{
|
||||
$config = $this->setOptionResolver->detectFromNameAndDirectory($set, Set::SET_DIRECTORY);
|
||||
$configs = [];
|
||||
|
||||
// local config has priority
|
||||
$localConfigs = ['rector.yml', 'rector.yaml'];
|
||||
foreach ($localConfigs as $localConfig) {
|
||||
$configRealPath = getcwd() . DIRECTORY_SEPARATOR . $localConfig;
|
||||
if (! file_exists($configRealPath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$configs[] = $configRealPath;
|
||||
}
|
||||
|
||||
return $configs;
|
||||
}
|
||||
|
||||
private function resolveConfigFromSet(string $set): string
|
||||
{
|
||||
$config = $this->setResolver->detectFromNameAndDirectory($set, Set::SET_DIRECTORY);
|
||||
if ($config === null) {
|
||||
throw new ShouldNotHappenException(sprintf('Config file for "%s" set was not found', $set));
|
||||
}
|
||||
|
||||
// copied mostly from https://github.com/rectorphp/rector/blob/master/bin/container.php
|
||||
$configFiles = [];
|
||||
$configFiles[] = $config;
|
||||
// local config has priority
|
||||
$configFiles[] = ConfigFileFinder::provide('rector', ['rector.yml', 'rector.yaml']);
|
||||
|
||||
// remove empty values
|
||||
return array_filter($configFiles);
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace Rector\Exception\Application;
|
||||
|
||||
use Exception;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
use Throwable;
|
||||
|
||||
final class FileProcessingException extends Exception
|
||||
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Exception\Configuration;
|
||||
|
||||
use Exception;
|
||||
|
||||
final class SetNotFoundException extends Exception
|
||||
{
|
||||
}
|
@ -8,8 +8,8 @@ use Nette\Utils\Strings;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\Finder\SplFileInfo;
|
||||
use Symplify\PackageBuilder\FileSystem\FileSystem;
|
||||
use Symplify\PackageBuilder\FileSystem\FinderSanitizer;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\Finder\FinderSanitizer;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
/**
|
||||
* @see \Rector\Tests\FileSystem\FilesFinder\FilesFinderTest
|
||||
|
@ -11,7 +11,6 @@ final class PropertyNaming
|
||||
{
|
||||
/**
|
||||
* @param ObjectType|string $objectType
|
||||
* @return string
|
||||
*/
|
||||
public function fqnToVariableName($objectType): string
|
||||
{
|
||||
|
@ -71,7 +71,6 @@ final class BetterNodeFinder
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node $node
|
||||
* @param string[] $types
|
||||
*/
|
||||
public function findFirstAncestorInstancesOf(Node $node, array $types): ?Node
|
||||
|
@ -14,7 +14,7 @@ use Rector\Exception\ShouldNotHappenException;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PhpParser\Node\NodeVisitorFactory\NodeRemovingNodeVisitorFactory;
|
||||
use Rector\Rector\AffectedFilesCollector;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class NodeRemovingCommander implements CommanderInterface
|
||||
{
|
||||
|
@ -40,9 +40,6 @@ final class BinaryOpManipulator
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $firstCondition
|
||||
*/
|
||||
private function validateCondition($firstCondition): void
|
||||
{
|
||||
if (is_callable($firstCondition)) {
|
||||
|
@ -304,7 +304,6 @@ final class PropertyFetchManipulator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node $node
|
||||
* @return PropertyFetch|StaticPropertyFetch|null
|
||||
*/
|
||||
public function matchPropertyFetch(Node $node): ?Node
|
||||
|
@ -162,7 +162,6 @@ final class PropertyManipulator
|
||||
|
||||
/**
|
||||
* @param PropertyFetch|Expr\StaticPropertyFetch $node
|
||||
* @return bool
|
||||
*/
|
||||
private function isReadContext(Node $node): bool
|
||||
{
|
||||
|
@ -129,8 +129,6 @@ final class NodeFactory
|
||||
|
||||
/**
|
||||
* Creates "($arg)"
|
||||
*
|
||||
* @param mixed $argument
|
||||
*/
|
||||
public function createArg($argument): Arg
|
||||
{
|
||||
@ -226,7 +224,6 @@ final class NodeFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $item
|
||||
* @param string|int|null $key
|
||||
*/
|
||||
private function createArrayItem($item, $key = null): ArrayItem
|
||||
|
@ -25,7 +25,7 @@ use PhpParser\Node\Stmt\Trait_;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use Rector\Exception\ShouldNotHappenException;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class NameResolver
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ use Rector\NodeContainer\ParsedNodesByType;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
use Rector\PhpParser\Node\Resolver\NameResolver;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
/**
|
||||
* @see \Rector\Tests\PhpParser\Node\Value\ValueResolverTest
|
||||
@ -166,9 +166,6 @@ final class ValueResolver
|
||||
return $fileInfo->getPathname();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
private function resolveClassConstFetch(ClassConstFetch $classConstFetch)
|
||||
{
|
||||
$class = $this->nameResolver->getName($classConstFetch->class);
|
||||
|
@ -91,7 +91,6 @@ final class RectorNodeTraverser extends NodeTraverser
|
||||
|
||||
/**
|
||||
* @param mixed[] $configuration
|
||||
* @param PhpRectorInterface $phpRector
|
||||
*/
|
||||
private function addRectorConfiguration(array $configuration, PhpRectorInterface $phpRector): void
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ use PhpParser\Node\Stmt\Nop;
|
||||
use PhpParser\Node\Stmt\TraitUse;
|
||||
use PhpParser\PrettyPrinter\Standard;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
/**
|
||||
* @see \Rector\Tests\PhpParser\Printer\BetterStandardPrinterTest
|
||||
|
@ -6,7 +6,7 @@ namespace Rector\PhpParser\Printer;
|
||||
|
||||
use Nette\Utils\FileSystem;
|
||||
use PhpParser\Node;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
/**
|
||||
* @see \Rector\Tests\PhpParser\Printer\FormatPerservingPrinterTest
|
||||
|
@ -23,7 +23,7 @@ use Rector\Php\PhpVersionProvider;
|
||||
use Rector\Rector\AbstractRector\AbstractRectorTrait;
|
||||
use Rector\Rector\AbstractRector\NodeCommandersTrait;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
abstract class AbstractRector extends NodeVisitorAbstract implements PhpRectorInterface
|
||||
{
|
||||
|
@ -73,9 +73,6 @@ trait ComplexRemovalTrait
|
||||
|
||||
abstract protected function removeNode(Node $node): void;
|
||||
|
||||
/**
|
||||
* @param ClassMethod $classMethod
|
||||
*/
|
||||
protected function removeClassMethodAndUsages(ClassMethod $classMethod): void
|
||||
{
|
||||
$this->removeNode($classMethod);
|
||||
|
@ -74,9 +74,6 @@ trait NodeFactoryTrait
|
||||
return new ConstFetch(new Name('true'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $argument
|
||||
*/
|
||||
protected function createArg($argument): Arg
|
||||
{
|
||||
return $this->nodeFactory->createArg($argument);
|
||||
|
@ -26,17 +26,11 @@ trait ValueResolverTrait
|
||||
$this->valueResolver = $valueResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
protected function getValue(Expr $expr)
|
||||
{
|
||||
return $this->valueResolver->getValue($expr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $expectedValue
|
||||
*/
|
||||
protected function isValue(Expr $expr, $expectedValue): bool
|
||||
{
|
||||
return $this->getValue($expr) === $expectedValue;
|
||||
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Rector\Rector;
|
||||
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class AffectedFilesCollector
|
||||
{
|
||||
|
@ -222,9 +222,6 @@ PHP
|
||||
return in_array('method_call', $scope, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $defaultValue
|
||||
*/
|
||||
private function addClassMethodParam(
|
||||
ClassMethod $classMethod,
|
||||
string $name,
|
||||
|
@ -143,9 +143,6 @@ PHP
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
private function resolveArgumentValue(Arg $arg)
|
||||
{
|
||||
$resolvedValue = $this->getValue($arg->value);
|
||||
@ -161,9 +158,6 @@ PHP
|
||||
return $resolvedValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
private function normalizeValueToArgument($value): Arg
|
||||
{
|
||||
// class constants → turn string to composite
|
||||
@ -206,7 +200,6 @@ PHP
|
||||
/**
|
||||
* @param Arg[] $argumentNodes
|
||||
* @param mixed[] $before
|
||||
* @return mixed
|
||||
*/
|
||||
private function resolveArgumentValuesToBeforeRecipe(array $argumentNodes, int $position, array $before)
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\Rector\AbstractRector;
|
||||
use Rector\RectorDefinition\ConfiguredCodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
@ -95,7 +95,7 @@ class SomeController
|
||||
* @var EntityManager
|
||||
*/
|
||||
private $entityManager;
|
||||
|
||||
|
||||
public function __construct(EntityManager $entityManager)
|
||||
{
|
||||
$this->entityManager = entityManager;
|
||||
|
@ -14,7 +14,7 @@ use Rector\CodingStyle\Naming\ClassNaming;
|
||||
use Rector\FileSystemRector\Rector\AbstractFileSystemRector;
|
||||
use Rector\RectorDefinition\CodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
/**
|
||||
* @see \Rector\Tests\Rector\Psr4\MultipleClassFileToPsr4ClassesRector\MultipleClassFileToPsr4ClassesRectorTest
|
||||
@ -42,14 +42,14 @@ namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
final class FirstException extends Exception
|
||||
final class FirstException extends Exception
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
final class SecondException extends Exception
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
PHP
|
||||
,
|
||||
@ -59,9 +59,9 @@ namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
final class FirstException extends Exception
|
||||
final class FirstException extends Exception
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// new file: "app/Exceptions/SecondException.php"
|
||||
@ -71,7 +71,7 @@ use Exception;
|
||||
|
||||
final class SecondException extends Exception
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
PHP
|
||||
),
|
||||
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Rector\Reporting;
|
||||
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class FileDiff
|
||||
{
|
||||
|
@ -23,7 +23,7 @@ use Rector\Stubs\StubLoader;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
/**
|
||||
* This class is needed over process/cli run to get console output in sane way;
|
||||
|
@ -13,7 +13,7 @@ use Rector\FileSystemRector\FileSystemFileProcessor;
|
||||
use Rector\HttpKernel\RectorKernel;
|
||||
use ReflectionClass;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
abstract class AbstractFileSystemRectorTestCase extends AbstractGenericRectorTestCase
|
||||
{
|
||||
|
@ -12,8 +12,8 @@ use Rector\HttpKernel\RectorKernel;
|
||||
use Rector\PhpParser\BetterNodeDumper;
|
||||
use Rector\PhpParser\Parser\Parser;
|
||||
use Rector\Testing\StaticFixtureProvider;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\PackageBuilder\Tests\AbstractKernelTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
/**
|
||||
* Class can be used to test node visitors
|
||||
|
@ -20,8 +20,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
abstract class AbstractRectorTestCase extends AbstractGenericRectorTestCase
|
||||
{
|
||||
@ -160,9 +160,6 @@ abstract class AbstractRectorTestCase extends AbstractGenericRectorTestCase
|
||||
return PhpRectorInterface::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
protected function setParameter(string $name, $value): void
|
||||
{
|
||||
$parameterProvider = self::$container->get(ParameterProvider::class);
|
||||
|
@ -6,7 +6,7 @@ namespace Rector\Testing\PHPUnit;
|
||||
|
||||
use Nette\Utils\FileSystem;
|
||||
use Nette\Utils\Strings;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class FixtureSplitter
|
||||
{
|
||||
|
@ -6,8 +6,8 @@ namespace Rector\Tests\DependencyInjection;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Rector\DependencyInjection\RectorContainerFactory;
|
||||
use Rector\Exception\Configuration\SetNotFoundException;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symplify\EasyCodingStandard\Exception\Configuration\SetNotFoundException;
|
||||
|
||||
final class RectorContainerFactoryTest extends TestCase
|
||||
{
|
||||
|
@ -7,8 +7,8 @@ namespace Rector\Tests\FileSystem\FilesFinder;
|
||||
use Iterator;
|
||||
use Rector\FileSystem\FilesFinder;
|
||||
use Rector\HttpKernel\RectorKernel;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\PackageBuilder\Tests\AbstractKernelTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class FilesFinderTest extends AbstractKernelTestCase
|
||||
{
|
||||
|
@ -29,7 +29,6 @@ final class ValueResolverTest extends AbstractKernelTestCase
|
||||
|
||||
/**
|
||||
* @dataProvider dataProvider
|
||||
* @param mixed $expected
|
||||
*/
|
||||
public function test($expected, Expr $expr): void
|
||||
{
|
||||
|
@ -7,8 +7,8 @@ namespace Rector\Tests\PhpParser\Printer;
|
||||
use Nette\Utils\FileSystem;
|
||||
use Rector\HttpKernel\RectorKernel;
|
||||
use Rector\PhpParser\Printer\FormatPerservingPrinter;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\PackageBuilder\Tests\AbstractKernelTestCase;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class FormatPerservingPrinterTest extends AbstractKernelTestCase
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ use PHPStan\Type\Type;
|
||||
use PHPStan\Type\UnionType;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\PHPStanExtensions\Utils\PHPStanValueResolver;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class GetAttributeReturnTypeExtension implements DynamicMethodReturnTypeExtension
|
||||
{
|
||||
|
@ -19,8 +19,8 @@ use Symfony\Component\Finder\Finder;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Symplify\PackageBuilder\Console\Command\CommandNaming;
|
||||
use Symplify\PackageBuilder\Console\ShellCode;
|
||||
use Symplify\PackageBuilder\FileSystem\FinderSanitizer;
|
||||
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
||||
use Symplify\SmartFileSystem\Finder\FinderSanitizer;
|
||||
use Symplify\SmartFileSystem\SmartFileInfo;
|
||||
|
||||
final class CreateRectorCommand extends Command implements ContributorCommandInterface
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user