mirror of
https://github.com/rectorphp/rector.git
synced 2025-03-14 12:29:43 +01:00
Updated Rector to commit c240c69f45c29685eeace5ad0737ef049dff5211
c240c69f45
[PostRector] Allow unused alias removal from Use_ on UnusedImportRemovingPostRector (#3477)
This commit is contained in:
parent
30f75fc21f
commit
bee2d189ab
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit634c3a30f651b87bed8edf65fe363205::getLoader();
|
||||
return ComposerAutoloaderInitabddcf2c38c6b8af19139a50b22312e7::getLoader();
|
||||
|
3
vendor/composer/autoload_classmap.php
vendored
3
vendor/composer/autoload_classmap.php
vendored
@ -1122,8 +1122,6 @@ return array(
|
||||
'RectorPrefix202303\\Tracy\\Logger' => $vendorDir . '/tracy/tracy/src/Tracy/Logger/Logger.php',
|
||||
'RectorPrefix202303\\Tracy\\OutputDebugger' => $vendorDir . '/tracy/tracy/src/Tracy/OutputDebugger/OutputDebugger.php',
|
||||
'RectorPrefix202303\\Tracy\\ProductionStrategy' => $vendorDir . '/tracy/tracy/src/Tracy/Debugger/ProductionStrategy.php',
|
||||
'RectorPrefix202303\\Triun\\LongestCommonSubstring\\Solver' => $vendorDir . '/triun/longest-common-substring/src/Solver.php',
|
||||
'RectorPrefix202303\\Triun\\LongestCommonSubstring\\SolverInterface' => $vendorDir . '/triun/longest-common-substring/src/SolverInterface.php',
|
||||
'RectorPrefix202303\\Webmozart\\Assert\\Assert' => $vendorDir . '/webmozart/assert/src/Assert.php',
|
||||
'RectorPrefix202303\\Webmozart\\Assert\\InvalidArgumentException' => $vendorDir . '/webmozart/assert/src/InvalidArgumentException.php',
|
||||
'RectorPrefix202303\\Webmozart\\Assert\\Mixin' => $vendorDir . '/webmozart/assert/src/Mixin.php',
|
||||
@ -2608,6 +2606,7 @@ return array(
|
||||
'Rector\\Symfony\\Rector\\Class_\\MakeCommandLazyRector' => $vendorDir . '/rector/rector-symfony/src/Rector/Class_/MakeCommandLazyRector.php',
|
||||
'Rector\\Symfony\\Rector\\Class_\\MessageHandlerInterfaceToAttributeRector' => $vendorDir . '/rector/rector-symfony/src/Rector/Class_/MessageHandlerInterfaceToAttributeRector.php',
|
||||
'Rector\\Symfony\\Rector\\Closure\\ContainerGetNameToTypeInTestsRector' => $vendorDir . '/rector/rector-symfony/src/Rector/Closure/ContainerGetNameToTypeInTestsRector.php',
|
||||
'Rector\\Symfony\\Rector\\Closure\\MinimalSharedStringSolver' => $vendorDir . '/rector/rector-symfony/src/Rector/Closure/MinimalSharedStringSolver.php',
|
||||
'Rector\\Symfony\\Rector\\Closure\\ServiceArgsToServiceNamedArgRector' => $vendorDir . '/rector/rector-symfony/src/Rector/Closure/ServiceArgsToServiceNamedArgRector.php',
|
||||
'Rector\\Symfony\\Rector\\Closure\\ServiceSetStringNameToClassNameRector' => $vendorDir . '/rector/rector-symfony/src/Rector/Closure/ServiceSetStringNameToClassNameRector.php',
|
||||
'Rector\\Symfony\\Rector\\Closure\\ServiceSettersToSettersAutodiscoveryRector' => $vendorDir . '/rector/rector-symfony/src/Rector/Closure/ServiceSettersToSettersAutodiscoveryRector.php',
|
||||
|
1
vendor/composer/autoload_psr4.php
vendored
1
vendor/composer/autoload_psr4.php
vendored
@ -17,7 +17,6 @@ return array(
|
||||
'Rector\\Core\\' => array($baseDir . '/src'),
|
||||
'Rector\\' => array($baseDir . '/packages', $baseDir . '/rules', $vendorDir . '/rector/rector-downgrade-php/src', $vendorDir . '/rector/rector-downgrade-php/rules'),
|
||||
'RectorPrefix202303\\Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'),
|
||||
'RectorPrefix202303\\Triun\\LongestCommonSubstring\\' => array($vendorDir . '/triun/longest-common-substring/src'),
|
||||
'RectorPrefix202303\\Symplify\\EasyParallel\\' => array($vendorDir . '/symplify/easy-parallel/src'),
|
||||
'RectorPrefix202303\\Symfony\\Contracts\\' => array($vendorDir . '/symfony/contracts'),
|
||||
'RectorPrefix202303\\Symfony\\Component\\String\\' => array($vendorDir . '/symfony/string'),
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit634c3a30f651b87bed8edf65fe363205
|
||||
class ComposerAutoloaderInitabddcf2c38c6b8af19139a50b22312e7
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit634c3a30f651b87bed8edf65fe363205
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit634c3a30f651b87bed8edf65fe363205', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitabddcf2c38c6b8af19139a50b22312e7', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit634c3a30f651b87bed8edf65fe363205', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitabddcf2c38c6b8af19139a50b22312e7', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit634c3a30f651b87bed8edf65fe363205::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitabddcf2c38c6b8af19139a50b22312e7::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit634c3a30f651b87bed8edf65fe363205::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInitabddcf2c38c6b8af19139a50b22312e7::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
16
vendor/composer/autoload_static.php
vendored
16
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit634c3a30f651b87bed8edf65fe363205
|
||||
class ComposerStaticInitabddcf2c38c6b8af19139a50b22312e7
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -36,7 +36,6 @@ class ComposerStaticInit634c3a30f651b87bed8edf65fe363205
|
||||
'Rector\\Core\\' => 12,
|
||||
'Rector\\' => 7,
|
||||
'RectorPrefix202303\\Webmozart\\Assert\\' => 36,
|
||||
'RectorPrefix202303\\Triun\\LongestCommonSubstring\\' => 48,
|
||||
'RectorPrefix202303\\Symplify\\EasyParallel\\' => 41,
|
||||
'RectorPrefix202303\\Symfony\\Contracts\\' => 37,
|
||||
'RectorPrefix202303\\Symfony\\Component\\String\\' => 44,
|
||||
@ -123,10 +122,6 @@ class ComposerStaticInit634c3a30f651b87bed8edf65fe363205
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/webmozart/assert/src',
|
||||
),
|
||||
'RectorPrefix202303\\Triun\\LongestCommonSubstring\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/triun/longest-common-substring/src',
|
||||
),
|
||||
'RectorPrefix202303\\Symplify\\EasyParallel\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symplify/easy-parallel/src',
|
||||
@ -1374,8 +1369,6 @@ class ComposerStaticInit634c3a30f651b87bed8edf65fe363205
|
||||
'RectorPrefix202303\\Tracy\\Logger' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Logger/Logger.php',
|
||||
'RectorPrefix202303\\Tracy\\OutputDebugger' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/OutputDebugger/OutputDebugger.php',
|
||||
'RectorPrefix202303\\Tracy\\ProductionStrategy' => __DIR__ . '/..' . '/tracy/tracy/src/Tracy/Debugger/ProductionStrategy.php',
|
||||
'RectorPrefix202303\\Triun\\LongestCommonSubstring\\Solver' => __DIR__ . '/..' . '/triun/longest-common-substring/src/Solver.php',
|
||||
'RectorPrefix202303\\Triun\\LongestCommonSubstring\\SolverInterface' => __DIR__ . '/..' . '/triun/longest-common-substring/src/SolverInterface.php',
|
||||
'RectorPrefix202303\\Webmozart\\Assert\\Assert' => __DIR__ . '/..' . '/webmozart/assert/src/Assert.php',
|
||||
'RectorPrefix202303\\Webmozart\\Assert\\InvalidArgumentException' => __DIR__ . '/..' . '/webmozart/assert/src/InvalidArgumentException.php',
|
||||
'RectorPrefix202303\\Webmozart\\Assert\\Mixin' => __DIR__ . '/..' . '/webmozart/assert/src/Mixin.php',
|
||||
@ -2860,6 +2853,7 @@ class ComposerStaticInit634c3a30f651b87bed8edf65fe363205
|
||||
'Rector\\Symfony\\Rector\\Class_\\MakeCommandLazyRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/Class_/MakeCommandLazyRector.php',
|
||||
'Rector\\Symfony\\Rector\\Class_\\MessageHandlerInterfaceToAttributeRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/Class_/MessageHandlerInterfaceToAttributeRector.php',
|
||||
'Rector\\Symfony\\Rector\\Closure\\ContainerGetNameToTypeInTestsRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/Closure/ContainerGetNameToTypeInTestsRector.php',
|
||||
'Rector\\Symfony\\Rector\\Closure\\MinimalSharedStringSolver' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/Closure/MinimalSharedStringSolver.php',
|
||||
'Rector\\Symfony\\Rector\\Closure\\ServiceArgsToServiceNamedArgRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/Closure/ServiceArgsToServiceNamedArgRector.php',
|
||||
'Rector\\Symfony\\Rector\\Closure\\ServiceSetStringNameToClassNameRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/Closure/ServiceSetStringNameToClassNameRector.php',
|
||||
'Rector\\Symfony\\Rector\\Closure\\ServiceSettersToSettersAutodiscoveryRector' => __DIR__ . '/..' . '/rector/rector-symfony/src/Rector/Closure/ServiceSettersToSettersAutodiscoveryRector.php',
|
||||
@ -3133,9 +3127,9 @@ class ComposerStaticInit634c3a30f651b87bed8edf65fe363205
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit634c3a30f651b87bed8edf65fe363205::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit634c3a30f651b87bed8edf65fe363205::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit634c3a30f651b87bed8edf65fe363205::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitabddcf2c38c6b8af19139a50b22312e7::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitabddcf2c38c6b8af19139a50b22312e7::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitabddcf2c38c6b8af19139a50b22312e7::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
60
vendor/composer/installed.json
vendored
60
vendor/composer/installed.json
vendored
@ -2125,19 +2125,18 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
||||
"reference": "ee203c96f524f2e1630d1bc45afe5f4bfb176011"
|
||||
"reference": "6a67780b138e10d3ab7939c9e68d964f66650d36"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/ee203c96f524f2e1630d1bc45afe5f4bfb176011",
|
||||
"reference": "ee203c96f524f2e1630d1bc45afe5f4bfb176011",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/6a67780b138e10d3ab7939c9e68d964f66650d36",
|
||||
"reference": "6a67780b138e10d3ab7939c9e68d964f66650d36",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-xml": "*",
|
||||
"php": ">=8.1",
|
||||
"symfony\/string": "^6.1",
|
||||
"triun\/longest-common-substring": "^1.0"
|
||||
"symfony\/string": "^6.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan\/extension-installer": "^1.2",
|
||||
@ -2160,7 +2159,7 @@
|
||||
"tomasvotruba\/type-coverage": "^0.0.9",
|
||||
"tomasvotruba\/unused-public": "^0.0.34"
|
||||
},
|
||||
"time": "2023-03-06T13:47:33+00:00",
|
||||
"time": "2023-03-14T10:14:09+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
@ -3304,55 +3303,6 @@
|
||||
},
|
||||
"install-path": "..\/tracy\/tracy"
|
||||
},
|
||||
{
|
||||
"name": "triun\/longest-common-substring",
|
||||
"version": "1.0.0",
|
||||
"version_normalized": "1.0.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/Triun\/PHP-Longest-Common-Substring.git",
|
||||
"reference": "eb353758f4b2ec8c874ad36c2acd35d38cf436d4"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/Triun\/PHP-Longest-Common-Substring\/zipball\/eb353758f4b2ec8c874ad36c2acd35d38cf436d4",
|
||||
"reference": "eb353758f4b2ec8c874ad36c2acd35d38cf436d4",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit\/phpunit": "^6.5",
|
||||
"squizlabs\/php_codesniffer": "^3.2",
|
||||
"symfony\/var-dumper": "^3.4"
|
||||
},
|
||||
"time": "2018-04-08T13:56:01+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"RectorPrefix202303\\Triun\\LongestCommonSubstring\\": "src\/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https:\/\/packagist.org\/downloads\/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Gonzalo Moreno",
|
||||
"homepage": "https:\/\/github.com\/gonzalom"
|
||||
}
|
||||
],
|
||||
"description": "PHP implementation of an algorithm to solve the `longest common substring` problem.",
|
||||
"homepage": "https:\/\/github.com\/Triun",
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/Triun\/PHP-Longest-Common-Substring\/issues",
|
||||
"source": "https:\/\/github.com\/Triun\/PHP-Longest-Common-Substring"
|
||||
},
|
||||
"install-path": "..\/triun\/longest-common-substring"
|
||||
},
|
||||
{
|
||||
"name": "webmozart\/assert",
|
||||
"version": "1.11.0",
|
||||
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
||||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5fe59e9'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b7d8492'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main dfeb67c'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main ee203c9'));
|
||||
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5fe59e9'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b7d8492'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main dfeb67c'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 6a67780'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
3
vendor/rector/rector-symfony/composer.json
vendored
3
vendor/rector/rector-symfony/composer.json
vendored
@ -6,8 +6,7 @@
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"ext-xml": "*",
|
||||
"symfony\/string": "^6.1",
|
||||
"triun\/longest-common-substring": "^1.0"
|
||||
"symfony\/string": "^6.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan\/extension-installer": "^1.2",
|
||||
|
57
vendor/rector/rector-symfony/src/Rector/Closure/MinimalSharedStringSolver.php
vendored
Normal file
57
vendor/rector/rector-symfony/src/Rector/Closure/MinimalSharedStringSolver.php
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\Rector\Closure;
|
||||
|
||||
/**
|
||||
* Class Solver copied from https://github.com/Triun/PHP-Longest-Common-Substring
|
||||
*/
|
||||
final class MinimalSharedStringSolver
|
||||
{
|
||||
public function solve(string $stringA, string $stringB) : string
|
||||
{
|
||||
if (\func_num_args() > 2) {
|
||||
$arguments = \func_get_args();
|
||||
\array_splice($arguments, 0, 2, [$this->solve($stringA, $stringB)]);
|
||||
return $this->solve(...$arguments);
|
||||
}
|
||||
$charsA = \str_split($stringA);
|
||||
$charsB = \str_split($stringB);
|
||||
$matrix = \array_fill_keys(\array_keys($charsA), \array_fill_keys(\array_keys($charsB), 0));
|
||||
$longestLength = 0;
|
||||
$longestIndexes = [];
|
||||
foreach ($charsA as $i => $charA) {
|
||||
foreach ($charsB as $j => $charB) {
|
||||
if ($charA === $charB) {
|
||||
$matrix[$i][$j] = $i === 0 || $j === 0 ? 1 : $matrix[$i - 1][$j - 1] + 1;
|
||||
$newIndex = $this->newIndex($matrix, $i, $j);
|
||||
if ($matrix[$i][$j] > $longestLength) {
|
||||
$longestLength = $matrix[$i][$j];
|
||||
$longestIndexes = [$newIndex];
|
||||
} elseif ($matrix[$i][$j] === $longestLength) {
|
||||
$longestIndexes[] = $newIndex;
|
||||
}
|
||||
} else {
|
||||
$matrix[$i][$j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->result($longestIndexes, $longestLength, $stringA);
|
||||
}
|
||||
/**
|
||||
* @param array<int, array<int, int>> $matrix
|
||||
*/
|
||||
private function newIndex(array $matrix, int $i, int $j) : int
|
||||
{
|
||||
return $i - $matrix[$i][$j] + 1;
|
||||
}
|
||||
/**
|
||||
* @param list<int> $longestIndexes
|
||||
*
|
||||
* @return string the extracted part of string or false on failure.
|
||||
*/
|
||||
private function result(array $longestIndexes, int $longestLength, string $stringA) : string
|
||||
{
|
||||
return $longestIndexes === [] ? '' : \substr($stringA, $longestIndexes[0], $longestLength);
|
||||
}
|
||||
}
|
@ -23,7 +23,6 @@ use Rector\Symfony\ValueObject\ClassNameAndFilePath;
|
||||
use RectorPrefix202303\Symfony\Component\Filesystem\Filesystem;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use RectorPrefix202303\Triun\LongestCommonSubstring\Solver;
|
||||
/**
|
||||
* @see \Rector\Symfony\Tests\Rector\Closure\ServiceSettersToSettersAutodiscoveryRector\ServiceSettersToSettersAutodiscoveryRectorTest
|
||||
*/
|
||||
@ -31,7 +30,7 @@ final class ServiceSettersToSettersAutodiscoveryRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Triun\LongestCommonSubstring\Solver
|
||||
* @var \Rector\Symfony\Rector\Closure\MinimalSharedStringSolver
|
||||
*/
|
||||
private $minimalSharedStringSolver;
|
||||
/**
|
||||
@ -54,7 +53,7 @@ final class ServiceSettersToSettersAutodiscoveryRector extends AbstractRector
|
||||
$this->symfonyPhpClosureDetector = $symfonyPhpClosureDetector;
|
||||
$this->reflectionProvider = $reflectionProvider;
|
||||
$this->filesystem = $filesystem;
|
||||
$this->minimalSharedStringSolver = new Solver();
|
||||
$this->minimalSharedStringSolver = new \Rector\Symfony\Rector\Closure\MinimalSharedStringSolver();
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
@ -110,9 +109,6 @@ CODE_SAMPLE
|
||||
return $classNameAndFilePath->getClassName();
|
||||
}, $classNamesAndFilesPaths);
|
||||
$sharedNamespace = $this->minimalSharedStringSolver->solve(...$classNames);
|
||||
if (!\is_string($sharedNamespace)) {
|
||||
return null;
|
||||
}
|
||||
$firstClassNameAndFilePath = $classNamesAndFilesPaths[0];
|
||||
$classFilePath = $firstClassNameAndFilePath->getFilePath();
|
||||
$directoryConcat = $this->createAbsolutePathConcat($classFilePath);
|
||||
|
21
vendor/triun/longest-common-substring/LICENSE
vendored
21
vendor/triun/longest-common-substring/LICENSE
vendored
@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Triun
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -1,56 +0,0 @@
|
||||
{
|
||||
"name": "triun\/longest-common-substring",
|
||||
"version": "1.0.0",
|
||||
"description": "PHP implementation of an algorithm to solve the `longest common substring` problem.",
|
||||
"license": "MIT",
|
||||
"type": "library",
|
||||
"homepage": "https:\/\/github.com\/Triun",
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/Triun\/PHP-Longest-Common-Substring\/issues",
|
||||
"source": "https:\/\/github.com\/Triun\/PHP-Longest-Common-Substring"
|
||||
},
|
||||
"keywords": [],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Gonzalo Moreno",
|
||||
"homepage": "https:\/\/github.com\/gonzalom"
|
||||
}
|
||||
],
|
||||
"archive": {
|
||||
"exclude": [
|
||||
"\/.git",
|
||||
"\/.gitattributes",
|
||||
"\/.travis.*",
|
||||
"\/.archer.*",
|
||||
"\/test",
|
||||
"\/build",
|
||||
"\/*.md",
|
||||
"\/LICENCE",
|
||||
"\/phpcs.xml",
|
||||
"\/phpunit.xml"
|
||||
]
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit\/phpunit": "^6.5",
|
||||
"squizlabs\/php_codesniffer": "^3.2",
|
||||
"symfony\/var-dumper": "^3.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"RectorPrefix202303\\Triun\\LongestCommonSubstring\\": "src\/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [
|
||||
"test\/suite"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vendor\/bin\/phpunit --configuration phpunit.xml",
|
||||
"test-ci": "vendor\/bin\/phpunit --configuration phpunit.xml --coverage-clover build\/coverage.xml",
|
||||
"standards": "vendor\/bin\/phpcs --standard=phpcs.xml"
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace RectorPrefix202303;
|
||||
|
||||
require \dirname(__DIR__) . '/vendor/autoload.php';
|
||||
use RectorPrefix202303\Triun\LongestCommonSubstring\Solver;
|
||||
use RectorPrefix202303\Triun\LongestCommonSubstring\MatchesSolver;
|
||||
use RectorPrefix202303\Symfony\Component\VarDumper\Cloner\VarCloner;
|
||||
use RectorPrefix202303\Symfony\Component\VarDumper\Dumper\CliDumper;
|
||||
use RectorPrefix202303\Symfony\Component\VarDumper\Dumper\HtmlDumper;
|
||||
function dump($value)
|
||||
{
|
||||
if (\class_exists(CliDumper::class)) {
|
||||
$dumper = 'cli' === \PHP_SAPI ? new CliDumper() : new HtmlDumper();
|
||||
$dumper->dump((new VarCloner())->cloneVar($value));
|
||||
} else {
|
||||
\var_dump($value);
|
||||
}
|
||||
}
|
||||
$solver = new Solver();
|
||||
$matchSolver = new MatchesSolver();
|
||||
$stringA = '0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF';
|
||||
$stringB = '56789AB56789ABCDE56789ABCDE56789AB56789A123456789A';
|
||||
$matches = $matchSolver->solve($stringA, $stringB);
|
||||
$result = $solver->solve($stringA, $stringB);
|
||||
dump($stringA);
|
||||
dump($stringB);
|
||||
dump($matches);
|
||||
dump($matches->toArray());
|
||||
dump($matches->toJson());
|
||||
dump($matches->values());
|
||||
dump($matches->unique());
|
||||
dump((string) $matches[0]);
|
||||
dump("{$matches[0]}");
|
||||
dump('' . $matches[0]);
|
||||
dump($matches->firstValue());
|
||||
dump((string) $matches->first());
|
||||
dump((string) $matches);
|
||||
dump($result);
|
114
vendor/triun/longest-common-substring/src/Match.php
vendored
114
vendor/triun/longest-common-substring/src/Match.php
vendored
@ -1,114 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Triun\LongestCommonSubstring;
|
||||
|
||||
use Serializable;
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* Class Match
|
||||
*
|
||||
* @package Triun\LongestCommonSubstring
|
||||
*/
|
||||
class Match implements JsonSerializable, Serializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $value;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $length;
|
||||
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
public $indexes = [];
|
||||
|
||||
/**
|
||||
* Match constructor.
|
||||
*
|
||||
* @param int|null $length
|
||||
* @param array|null $indexes
|
||||
*/
|
||||
public function __construct(array $indexes = null, int $length = null)
|
||||
{
|
||||
$this->length = $length;
|
||||
$this->indexes = $indexes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
*
|
||||
* @return Match
|
||||
*/
|
||||
public function setValue(string $value): Match
|
||||
{
|
||||
$this->value = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return (array)$this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the object into something JSON serializable.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize(): array
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function serialize(): string
|
||||
{
|
||||
return serialize([
|
||||
$this->value,
|
||||
$this->length,
|
||||
$this->indexes,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $data
|
||||
*/
|
||||
public function unserialize($data)
|
||||
{
|
||||
list(
|
||||
$this->value,
|
||||
$this->length,
|
||||
$this->indexes
|
||||
) = unserialize($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $key
|
||||
* @param int|null $default
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function index(int $key = 0, int $default = null)
|
||||
{
|
||||
return array_key_exists($key, $this->indexes) ? $this->indexes[$key] : $default;
|
||||
}
|
||||
}
|
@ -1,247 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Triun\LongestCommonSubstring;
|
||||
|
||||
use Iterator;
|
||||
use Countable;
|
||||
use ArrayAccess;
|
||||
use JsonSerializable;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Class Matches
|
||||
*
|
||||
* @package Triun\LongestCommonSubstring
|
||||
*/
|
||||
class Matches implements ArrayAccess, Iterator, JsonSerializable, Countable
|
||||
{
|
||||
/**
|
||||
* @var \Triun\LongestCommonSubstring\Match[]
|
||||
*/
|
||||
protected $items;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $position = 0;
|
||||
|
||||
/**
|
||||
* Matches constructor.
|
||||
*
|
||||
* @param \Triun\LongestCommonSubstring\Match[] $items
|
||||
*/
|
||||
public function __construct(array $items)
|
||||
{
|
||||
$this->items = array_values($items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Has any match.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has()
|
||||
{
|
||||
return count($this->items) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return count($this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get first match object.
|
||||
*
|
||||
* @return \Triun\LongestCommonSubstring\Match
|
||||
*/
|
||||
public function first()
|
||||
{
|
||||
return array_key_exists(0, $this->items) ? $this->items[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all matches objects.
|
||||
*
|
||||
* @return \Triun\LongestCommonSubstring\Match[]
|
||||
*/
|
||||
public function all()
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get first value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function firstValue()
|
||||
{
|
||||
if (!$this->has()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->items[0]->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all matches values.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function values()
|
||||
{
|
||||
return array_map(function (Match $item) {
|
||||
return $item->value;
|
||||
}, $this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function unique()
|
||||
{
|
||||
return array_values(array_unique($this->values()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->firstValue()?: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert instance to an array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return array_map(function (Match $item) {
|
||||
return $item->toArray();
|
||||
}, $this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the object into something JSON serializable.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert instance to JSON.
|
||||
*
|
||||
* @param int $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toJson($options = 0)
|
||||
{
|
||||
return json_encode($this->jsonSerialize(), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the given offset exists.
|
||||
*
|
||||
* @param string $offset
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return array_key_exists($offset, $this->items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value for a given offset.
|
||||
*
|
||||
* @param string $offset
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return $this->items[$offset];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value at the given offset.
|
||||
*
|
||||
* @param string $offset
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
throw new RuntimeException('Read only');
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the value at the given offset.
|
||||
*
|
||||
* @param string $offset
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
throw new RuntimeException('Read only');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current element
|
||||
*
|
||||
* @return mixed|\Triun\LongestCommonSubstring\Match
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return $this->items[$this->position];
|
||||
}
|
||||
|
||||
/**
|
||||
* Move forward to next element
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
$this->position++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the key of the current element
|
||||
*
|
||||
* @return mixed|int
|
||||
*/
|
||||
public function key()
|
||||
{
|
||||
return $this->position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if current position is valid
|
||||
*
|
||||
* @return boolean The return value will be casted to boolean and then evaluated.
|
||||
* Returns true on success or false on failure.
|
||||
*/
|
||||
public function valid()
|
||||
{
|
||||
return $this->position < $this->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Rewind the Iterator to the first element
|
||||
*/
|
||||
public function rewind()
|
||||
{
|
||||
$this->position = 0;
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Triun\LongestCommonSubstring;
|
||||
|
||||
/**
|
||||
* Return an array with all longest common strings.
|
||||
*
|
||||
* Class MatchesSolver
|
||||
*
|
||||
* @package Triun\LongestCommonSubstring
|
||||
*/
|
||||
class MatchesSolver extends Solver
|
||||
{
|
||||
/**
|
||||
* @param array $matrix
|
||||
* @param int $i
|
||||
* @param int $j
|
||||
*
|
||||
* @return Match
|
||||
*/
|
||||
protected function newIndex(array $matrix, int $i, int $j)
|
||||
{
|
||||
return new Match(
|
||||
[
|
||||
$i - $matrix[$i][$j] + 1,
|
||||
$j - $matrix[$i][$j] + 1,
|
||||
],
|
||||
$matrix[$i][$j]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Match[] $longestIndexes
|
||||
* @param int $longestLength
|
||||
* @param string $stringA
|
||||
* @param string $stringB
|
||||
* @param array $matrix
|
||||
*
|
||||
* @return object[] the extracted part of string or false on failure.
|
||||
*/
|
||||
protected function result(
|
||||
array $longestIndexes,
|
||||
int $longestLength,
|
||||
string $stringA,
|
||||
string $stringB,
|
||||
array $matrix
|
||||
) {
|
||||
return array_map(function (Match $result) use ($stringA) {
|
||||
$result->value = substr($stringA, $result->index(), $result->length);
|
||||
|
||||
return $result;
|
||||
}, $longestIndexes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $stringA
|
||||
* @param string $stringB
|
||||
*
|
||||
* @return Matches
|
||||
*/
|
||||
public function solve(string $stringA, string $stringB)
|
||||
{
|
||||
if (func_num_args() > 2) {
|
||||
// TODO: Get the best combination, not just the first one.
|
||||
$arguments = func_get_args();
|
||||
array_splice($arguments, 0, 2, [$this->solve($stringA, $stringB)]);
|
||||
|
||||
return call_user_func_array([$this, 'solve'], $arguments);
|
||||
}
|
||||
|
||||
return new Matches(parent::solve($stringA, $stringB));
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace RectorPrefix202303\Triun\LongestCommonSubstring;
|
||||
|
||||
/**
|
||||
* Class Solver
|
||||
*
|
||||
* @package Triun\LongestCommonSubstring
|
||||
*/
|
||||
class Solver implements SolverInterface
|
||||
{
|
||||
/**
|
||||
* @param array $matrix
|
||||
* @param int $i
|
||||
* @param int $j
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function newIndex(array $matrix, int $i, int $j)
|
||||
{
|
||||
return $i - $matrix[$i][$j] + 1;
|
||||
}
|
||||
/**
|
||||
* @param array $longestIndexes
|
||||
* @param int $longestLength
|
||||
* @param string $stringA
|
||||
* @param string $stringB
|
||||
* @param array $matrix
|
||||
*
|
||||
* @return bool|string the extracted part of string or false on failure.
|
||||
*/
|
||||
protected function result(array $longestIndexes, int $longestLength, string $stringA, string $stringB, array $matrix)
|
||||
{
|
||||
return \count($longestIndexes) === 0 ? '' : \substr($stringA, $longestIndexes[0], $longestLength);
|
||||
}
|
||||
/**
|
||||
* @param string $stringA
|
||||
* @param string $stringB
|
||||
*
|
||||
* @return array|mixed
|
||||
*/
|
||||
public function solve(string $stringA, string $stringB)
|
||||
{
|
||||
if (\func_num_args() > 2) {
|
||||
$arguments = \func_get_args();
|
||||
\array_splice($arguments, 0, 2, [$this->solve($stringA, $stringB)]);
|
||||
return \call_user_func_array([$this, 'solve'], $arguments);
|
||||
}
|
||||
$charsA = \str_split($stringA);
|
||||
$charsB = \str_split($stringB);
|
||||
$matrix = \array_fill_keys(\array_keys($charsA), \array_fill_keys(\array_keys($charsB), 0));
|
||||
$longestLength = 0;
|
||||
$longestIndexes = [];
|
||||
foreach ($charsA as $i => $charA) {
|
||||
foreach ($charsB as $j => $charB) {
|
||||
if ($charA === $charB) {
|
||||
if (0 === $i || 0 === $j) {
|
||||
$matrix[$i][$j] = 1;
|
||||
} else {
|
||||
$matrix[$i][$j] = $matrix[$i - 1][$j - 1] + 1;
|
||||
}
|
||||
$newIndex = $this->newIndex($matrix, $i, $j);
|
||||
if ($matrix[$i][$j] > $longestLength) {
|
||||
$longestLength = $matrix[$i][$j];
|
||||
$longestIndexes = [$newIndex];
|
||||
} elseif ($matrix[$i][$j] === $longestLength) {
|
||||
$longestIndexes[] = $newIndex;
|
||||
}
|
||||
} else {
|
||||
$matrix[$i][$j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->result($longestIndexes, $longestLength, $stringA, $stringB, $matrix);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace RectorPrefix202303\Triun\LongestCommonSubstring;
|
||||
|
||||
/**
|
||||
* Interface SolverInterface
|
||||
*
|
||||
* @package Triun\LongestCommonSubstring
|
||||
*/
|
||||
interface SolverInterface
|
||||
{
|
||||
/**
|
||||
* @param string $stringA
|
||||
* @param string $stringB
|
||||
*
|
||||
* @return string|mixed
|
||||
*/
|
||||
public function solve(string $stringA, string $stringB);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user