Updated Rector to commit 58c8a93698

58c8a93698 [DX] Make use of configure() method (#1344)
This commit is contained in:
Tomas Votruba 2021-11-30 13:55:08 +00:00
parent 18932aa182
commit ccce5491a7
38 changed files with 126 additions and 140 deletions

View File

@ -139,7 +139,7 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
$services->set(\Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector::class);
$services->set(\Rector\CodeQuality\Rector\Array_\ArrayThisCallToThisMethodCallRector::class);
$services->set(\Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class);
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->configure([
'split' => 'explode',
'join' => 'implode',
'sizeof' => 'count',
@ -163,7 +163,7 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
'mbstrpos' => 'mb_strpos',
'mbstrrpos' => 'mb_strrpos',
'mbsubstr' => 'mb_substr',
]]]);
]);
$services->set(\Rector\CodeQuality\Rector\FuncCall\SetTypeToCastRector::class);
$services->set(\Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector::class);
$services->set(\Rector\Php52\Rector\Property\VarToPublicPropertyRector::class);

View File

@ -62,7 +62,7 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
$services->set(\Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector::class);
$services->set(\Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector::class);
$services->set(\Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector::class);
$services->set(\Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector::class)->call('configure', [[\Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector::FUNCTIONS_TO_CONSTANTS => ['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']]]);
$services->set(\Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector::class)->configure(['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']);
$services->set(\Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector::class);
$services->set(\Rector\CodingStyle\Rector\ClassMethod\RemoveDoubleUnderscoreInMethodNameRector::class);
$services->set(\Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector::class);

View File

@ -28,22 +28,21 @@ use Rector\DowngradePhp80\Rector\StaticCall\DowngradePhpTokenRector;
use Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation;
use Rector\Removing\Rector\Class_\RemoveInterfacesRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$parameters = $containerConfigurator->parameters();
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_74);
$services = $containerConfigurator->services();
$services->set(\Rector\Removing\Rector\Class_\RemoveInterfacesRector::class)->call('configure', [[\Rector\Removing\Rector\Class_\RemoveInterfacesRector::INTERFACES_TO_REMOVE => [
$services->set(\Rector\Removing\Rector\Class_\RemoveInterfacesRector::class)->configure([
// @see https://wiki.php.net/rfc/stringable
'Stringable',
]]]);
]);
$services->set(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector::class);
$services->set(\Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector::class)->call('configure', [[\Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector::ATTRIBUTE_TO_ANNOTATION => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([
$services->set(\Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector::class)->configure([
// Symfony
new \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation('Symfony\\Contracts\\Service\\Attribute\\Required', 'required'),
// Nette
new \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation('Nette\\DI\\Attributes\\Inject', 'inject'),
])]]);
]);
$services->set(\Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector::class);
$services->set(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector::class);
$services->set(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector::class);

View File

@ -6,10 +6,9 @@ namespace RectorPrefix20211130;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->configure([
// Rename is now move, specific for files.
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'rename', 'move'),
// No arbitrary abbreviations
@ -25,5 +24,5 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getMimetype', 'mimeType'),
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getSize', 'fileSize'),
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getVisibility', 'visibility'),
])]]);
]);
};

File diff suppressed because one or more lines are too long

View File

@ -10,11 +10,10 @@ use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
use Rector\Transform\ValueObject\FuncCallToMethodCall;
use Rector\Transform\ValueObject\StaticCallToFuncCall;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$configuration = [new \Rector\Transform\ValueObject\FuncCallToMethodCall('GuzzleHttp\\json_decode', 'GuzzleHttp\\Utils', 'jsonDecode'), new \Rector\Transform\ValueObject\FuncCallToMethodCall('GuzzleHttp\\get_path', 'GuzzleHttp\\Utils', 'getPath')];
$services->set(\Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector::class)->call('configure', [[\Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector::FUNC_CALL_TO_CLASS_METHOD_CALL => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline($configuration)]]);
$services->set(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class)->call('configure', [[\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Transform\ValueObject\StaticCallToFuncCall('GuzzleHttp\\Utils', 'setPath', 'GuzzleHttp\\set_path'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('GuzzleHttp\\Pool', 'batch', 'GuzzleHttp\\Pool\\batch')])]]);
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Renaming\ValueObject\MethodCallRename('GuzzleHttp\\Message\\MessageInterface', 'getHeaderLines', 'getHeaderAsArray')])]]);
$services->set(\Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector::class)->configure($configuration);
$services->set(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class)->configure([new \Rector\Transform\ValueObject\StaticCallToFuncCall('GuzzleHttp\\Utils', 'setPath', 'GuzzleHttp\\set_path'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('GuzzleHttp\\Pool', 'batch', 'GuzzleHttp\\Pool\\batch')]);
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->configure([new \Rector\Renaming\ValueObject\MethodCallRename('GuzzleHttp\\Message\\MessageInterface', 'getHeaderLines', 'getHeaderAsArray')]);
};

View File

@ -6,9 +6,8 @@ namespace RectorPrefix20211130;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
# https://github.com/Seldaek/monolog/commit/39f8a20e6dadc0194e846b254c5f23d1c732290b#diff-dce565f403e044caa5e6a0d988339430
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addDebug', 'debug'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addInfo', 'info'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addNotice', 'notice'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addWarning', 'warning'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addError', 'error'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addCritical', 'critical'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addAlert', 'alert'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addEmergency', 'emergency'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'warn', 'warning'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'err', 'error'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'crit', 'critical'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'emerg', 'emergency')])]]);
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->configure([new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addDebug', 'debug'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addInfo', 'info'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addNotice', 'notice'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addWarning', 'warning'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addError', 'error'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addCritical', 'critical'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addAlert', 'alert'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addEmergency', 'emergency'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'warn', 'warning'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'err', 'error'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'crit', 'critical'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'emerg', 'emergency')]);
};

View File

@ -14,7 +14,6 @@ use Rector\Removing\ValueObject\RemoveFuncCallArg;
use Rector\Renaming\Rector\ConstFetch\RenameConstantRector;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
# https://stackoverflow.com/a/1390625/1348344
@ -22,12 +21,12 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
# https://www.phpclasses.org/blog/package/9199/post/3-Smoothly-Migrate-your-PHP-Code-using-the-Old-MySQL-extension-to-MySQLi.html
$services->set(\Rector\MysqlToMysqli\Rector\Assign\MysqlAssignToMysqliRector::class);
$services->set(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlFuncCallToMysqliRector::class);
$services->set(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class)->call('configure', [[\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_pconnect', 3), new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_connect', 3), new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_connect', 4)])]]);
$services->set(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class)->configure([new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_pconnect', 3), new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_connect', 3), new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_connect', 4)]);
$services->set(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlPConnectToMysqliConnectRector::class);
# first swap arguments, then rename
$services->set(\Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector::class)->call('configure', [[\Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector::FUNCTION_ARGUMENT_SWAPS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_query', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_real_escape_string', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_select_db', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_set_charset', [1, 0])])]]);
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['mysql_connect' => 'mysqli_connect', 'mysql_data_seek' => 'mysqli_data_seek', 'mysql_fetch_array' => 'mysqli_fetch_array', 'mysql_fetch_assoc' => 'mysqli_fetch_assoc', 'mysql_fetch_lengths' => 'mysqli_fetch_lengths', 'mysql_fetch_object' => 'mysqli_fetch_object', 'mysql_fetch_row' => 'mysqli_fetch_row', 'mysql_field_seek' => 'mysqli_field_seek', 'mysql_free_result' => 'mysqli_free_result', 'mysql_get_client_info' => 'mysqli_get_client_info', 'mysql_num_fields' => 'mysqli_num_fields', 'mysql_numfields' => 'mysqli_num_fields', 'mysql_num_rows' => 'mysqli_num_rows', 'mysql_numrows' => 'mysqli_num_rows']]]);
$services->set(\Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector::class)->configure([new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_query', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_real_escape_string', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_select_db', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_set_charset', [1, 0])]);
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->configure(['mysql_connect' => 'mysqli_connect', 'mysql_data_seek' => 'mysqli_data_seek', 'mysql_fetch_array' => 'mysqli_fetch_array', 'mysql_fetch_assoc' => 'mysqli_fetch_assoc', 'mysql_fetch_lengths' => 'mysqli_fetch_lengths', 'mysql_fetch_object' => 'mysqli_fetch_object', 'mysql_fetch_row' => 'mysqli_fetch_row', 'mysql_field_seek' => 'mysqli_field_seek', 'mysql_free_result' => 'mysqli_free_result', 'mysql_get_client_info' => 'mysqli_get_client_info', 'mysql_num_fields' => 'mysqli_num_fields', 'mysql_numfields' => 'mysqli_num_fields', 'mysql_num_rows' => 'mysqli_num_rows', 'mysql_numrows' => 'mysqli_num_rows']);
# http://php.net/manual/en/mysql.constants.php → http://php.net/manual/en/mysqli.constants.php
$services->set(\Rector\Renaming\Rector\ConstFetch\RenameConstantRector::class)->call('configure', [[\Rector\Renaming\Rector\ConstFetch\RenameConstantRector::OLD_TO_NEW_CONSTANTS => ['MYSQL_ASSOC' => 'MYSQLI_ASSOC', 'MYSQL_BOTH' => 'MYSQLI_BOTH', 'MYSQL_CLIENT_COMPRESS' => 'MYSQLI_CLIENT_COMPRESS', 'MYSQL_CLIENT_IGNORE_SPACE' => 'MYSQLI_CLIENT_IGNORE_SPACE', 'MYSQL_CLIENT_INTERACTIVE' => 'MYSQLI_CLIENT_INTERACTIVE', 'MYSQL_CLIENT_SSL' => 'MYSQLI_CLIENT_SSL', 'MYSQL_NUM' => 'MYSQLI_NUM', 'MYSQL_PRIMARY_KEY_FLAG' => 'MYSQLI_PRI_KEY_FLAG']]]);
$services->set(\Rector\Renaming\Rector\ConstFetch\RenameConstantRector::class)->configure(['MYSQL_ASSOC' => 'MYSQLI_ASSOC', 'MYSQL_BOTH' => 'MYSQLI_BOTH', 'MYSQL_CLIENT_COMPRESS' => 'MYSQLI_CLIENT_COMPRESS', 'MYSQL_CLIENT_IGNORE_SPACE' => 'MYSQLI_CLIENT_IGNORE_SPACE', 'MYSQL_CLIENT_INTERACTIVE' => 'MYSQLI_CLIENT_INTERACTIVE', 'MYSQL_CLIENT_SSL' => 'MYSQLI_CLIENT_SSL', 'MYSQL_NUM' => 'MYSQLI_NUM', 'MYSQL_PRIMARY_KEY_FLAG' => 'MYSQLI_PRI_KEY_FLAG']);
$services->set(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlQueryMysqlErrorWithLinkRector::class);
};

File diff suppressed because one or more lines are too long

View File

@ -8,13 +8,12 @@ use Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector;
use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector;
use Rector\Removing\ValueObject\RemoveFuncCallArg;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(\Rector\Php52\Rector\Property\VarToPublicPropertyRector::class);
$services->set(\Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector::class);
$services->set(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class)->call('configure', [[\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([
$services->set(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class)->configure([
// see https://www.php.net/manual/en/function.ldap-first-attribute.php
new \Rector\Removing\ValueObject\RemoveFuncCallArg('ldap_first_attribute', 2),
])]]);
]);
};

View File

@ -9,7 +9,7 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['mysqli_param_count' => 'mysqli_stmt_param_count']]]);
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->configure(['mysqli_param_count' => 'mysqli_stmt_param_count']);
$services->set(\Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector::class);
$services->set(\Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector::class);
};

View File

@ -10,7 +10,7 @@ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigura
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(\Rector\Php56\Rector\FuncCall\PowToExpRector::class);
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['mcrypt_generic_end' => 'mcrypt_generic_deinit', 'set_socket_blocking' => 'stream_set_blocking', 'ocibindbyname' => 'oci_bind_by_name', 'ocicancel' => 'oci_cancel', 'ocicolumnisnull' => 'oci_field_is_null', 'ocicolumnname' => 'oci_field_name', 'ocicolumnprecision' => 'oci_field_precision', 'ocicolumnscale' => 'oci_field_scale', 'ocicolumnsize' => 'oci_field_size', 'ocicolumntype' => 'oci_field_type', 'ocicolumntyperaw' => 'oci_field_type_raw', 'ocicommit' => 'oci_commit', 'ocidefinebyname' => 'oci_define_by_name', 'ocierror' => 'oci_error', 'ociexecute' => 'oci_execute', 'ocifetch' => 'oci_fetch', 'ocifetchstatement' => 'oci_fetch_all', 'ocifreecursor' => 'oci_free_statement', 'ocifreestatement' => 'oci_free_statement', 'ociinternaldebug' => 'oci_internal_debug', 'ocilogoff' => 'oci_close', 'ocilogon' => 'oci_connect', 'ocinewcollection' => 'oci_new_collection', 'ocinewcursor' => 'oci_new_cursor', 'ocinewdescriptor' => 'oci_new_descriptor', 'ocinlogon' => 'oci_new_connect', 'ocinumcols' => 'oci_num_fields', 'ociparse' => 'oci_parse', 'ociplogon' => 'oci_pconnect', 'ociresult' => 'oci_result', 'ocirollback' => 'oci_rollback', 'ocirowcount' => 'oci_num_rows', 'ociserverversion' => 'oci_server_version', 'ocisetprefetch' => 'oci_set_prefetch', 'ocistatementtype' => 'oci_statement_type']]]);
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->configure(['mcrypt_generic_end' => 'mcrypt_generic_deinit', 'set_socket_blocking' => 'stream_set_blocking', 'ocibindbyname' => 'oci_bind_by_name', 'ocicancel' => 'oci_cancel', 'ocicolumnisnull' => 'oci_field_is_null', 'ocicolumnname' => 'oci_field_name', 'ocicolumnprecision' => 'oci_field_precision', 'ocicolumnscale' => 'oci_field_scale', 'ocicolumnsize' => 'oci_field_size', 'ocicolumntype' => 'oci_field_type', 'ocicolumntyperaw' => 'oci_field_type_raw', 'ocicommit' => 'oci_commit', 'ocidefinebyname' => 'oci_define_by_name', 'ocierror' => 'oci_error', 'ociexecute' => 'oci_execute', 'ocifetch' => 'oci_fetch', 'ocifetchstatement' => 'oci_fetch_all', 'ocifreecursor' => 'oci_free_statement', 'ocifreestatement' => 'oci_free_statement', 'ociinternaldebug' => 'oci_internal_debug', 'ocilogoff' => 'oci_close', 'ocilogon' => 'oci_connect', 'ocinewcollection' => 'oci_new_collection', 'ocinewcursor' => 'oci_new_cursor', 'ocinewdescriptor' => 'oci_new_descriptor', 'ocinlogon' => 'oci_new_connect', 'ocinumcols' => 'oci_num_fields', 'ociparse' => 'oci_parse', 'ociplogon' => 'oci_pconnect', 'ociresult' => 'oci_result', 'ocirollback' => 'oci_rollback', 'ocirowcount' => 'oci_num_rows', 'ociserverversion' => 'oci_server_version', 'ocisetprefetch' => 'oci_set_prefetch', 'ocistatementtype' => 'oci_statement_type']);
# inspired by level in psalm - https://github.com/vimeo/psalm/blob/82e0bcafac723fdf5007a31a7ae74af1736c9f6f/tests/FileManipulationTest.php#L1063
$services->set(\Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector::class);
};

View File

@ -21,7 +21,7 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
$services->set(\Rector\Php72\Rector\Assign\ListEachRector::class);
$services->set(\Rector\Php72\Rector\Assign\ReplaceEachAssignmentWithKeyCurrentRector::class);
$services->set(\Rector\Php72\Rector\Unset_\UnsetCastRector::class);
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->configure([
# and imagewbmp
'jpeg2wbmp' => 'imagecreatefromjpeg',
# or imagewbmp
@ -31,7 +31,7 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
# or gmp_random_range
'gmp_random' => 'gmp_random_bits',
'read_exif_data' => 'exif_read_data',
]]]);
]);
$services->set(\Rector\Php72\Rector\FuncCall\GetClassOnNullRector::class);
$services->set(\Rector\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector::class);
$services->set(\Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector::class);

View File

@ -22,7 +22,7 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
$services->set(\Rector\Php73\Rector\FuncCall\SensitiveDefineRector::class);
$services->set(\Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector::class);
$services->set(\Rector\Php73\Rector\String_\SensitiveHereNowDocRector::class);
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->configure([
# https://wiki.php.net/rfc/deprecations_php_7_3
'image2wbmp' => 'imagewbmp',
'mbregex_encoding' => 'mb_regex_encoding',
@ -38,7 +38,7 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
'mbereg_search_init' => 'mb_ereg_search_init',
'mbereg_search_getregs' => 'mb_ereg_search_getregs',
'mbereg_search_getpos' => 'mb_ereg_search_getpos',
]]]);
]);
$services->set(\Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector::class);
$services->set(\Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector::class);
$services->set(\Rector\Php73\Rector\FuncCall\RegexDashEscapeRector::class);

View File

@ -23,14 +23,14 @@ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigura
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(\Rector\Php74\Rector\Property\TypedPropertyRector::class);
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->configure([
#the_real_type
# https://wiki.php.net/rfc/deprecations_php_7_4
'is_real' => 'is_float',
#apache_request_headers_function
# https://wiki.php.net/rfc/deprecations_php_7_4
'apache_request_headers' => 'getallheaders',
]]]);
]);
$services->set(\Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector::class);
$services->set(\Rector\Php74\Rector\FuncCall\FilterVarToAddSlashesRector::class);
$services->set(\Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector::class);

View File

@ -27,14 +27,13 @@ use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
use Rector\Transform\ValueObject\StaticCallToFuncCall;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(\Rector\Php80\Rector\FunctionLike\UnionTypesRector::class);
$services->set(\Rector\Php80\Rector\NotIdentical\StrContainsRector::class);
$services->set(\Rector\Php80\Rector\Identical\StrStartsWithRector::class);
$services->set(\Rector\Php80\Rector\Identical\StrEndsWithRector::class);
$services->set(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class)->call('configure', [[\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'startsWith', 'str_starts_with'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'endsWith', 'str_ends_with'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'contains', 'str_contains')])]]);
$services->set(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class)->configure([new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'startsWith', 'str_starts_with'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'endsWith', 'str_ends_with'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'contains', 'str_contains')]);
$services->set(\Rector\Php80\Rector\Class_\StringableForToStringRector::class);
$services->set(\Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class);
$services->set(\Rector\Php80\Rector\Ternary\GetDebugTypeRector::class);
@ -43,13 +42,13 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
$services->set(\Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class);
$services->set(\Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class);
// nette\utils and Strings::replace()
$services->set(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class)->call('configure', [[\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::ADDED_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Arguments\ValueObject\ArgumentAdder('Nette\\Utils\\Strings', 'replace', 2, 'replacement', '')])]]);
$services->set(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class)->configure([new \Rector\Arguments\ValueObject\ArgumentAdder('Nette\\Utils\\Strings', 'replace', 2, 'replacement', '')]);
$services->set(\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class);
$services->set(\Rector\Php80\Rector\ClassMethod\SetStateToStaticRector::class);
$services->set(\Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class);
// @see https://php.watch/versions/8.0/pgsql-aliases-deprecated
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['pg_clientencoding' => 'pg_client_encoding', 'pg_cmdtuples' => 'pg_affected_rows', 'pg_errormessage' => 'pg_last_error', 'pg_fieldisnull' => 'pg_field_is_null', 'pg_fieldname' => 'pg_field_name', 'pg_fieldnum' => 'pg_field_num', 'pg_fieldprtlen' => 'pg_field_prtlen', 'pg_fieldsize' => 'pg_field_size', 'pg_fieldtype' => 'pg_field_type', 'pg_freeresult' => 'pg_free_result', 'pg_getlastoid' => 'pg_last_oid', 'pg_loclose' => 'pg_lo_close', 'pg_locreate' => 'pg_lo_create', 'pg_loexport' => 'pg_lo_export', 'pg_loimport' => 'pg_lo_import', 'pg_loopen' => 'pg_lo_open', 'pg_loread' => 'pg_lo_read', 'pg_loreadall' => 'pg_lo_read_all', 'pg_lounlink' => 'pg_lo_unlink', 'pg_lowrite' => 'pg_lo_write', 'pg_numfields' => 'pg_num_fields', 'pg_numrows' => 'pg_num_rows', 'pg_result' => 'pg_fetch_result', 'pg_setclientencoding' => 'pg_set_client_encoding']]]);
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->configure(['pg_clientencoding' => 'pg_client_encoding', 'pg_cmdtuples' => 'pg_affected_rows', 'pg_errormessage' => 'pg_last_error', 'pg_fieldisnull' => 'pg_field_is_null', 'pg_fieldname' => 'pg_field_name', 'pg_fieldnum' => 'pg_field_num', 'pg_fieldprtlen' => 'pg_field_prtlen', 'pg_fieldsize' => 'pg_field_size', 'pg_fieldtype' => 'pg_field_type', 'pg_freeresult' => 'pg_free_result', 'pg_getlastoid' => 'pg_last_oid', 'pg_loclose' => 'pg_lo_close', 'pg_locreate' => 'pg_lo_create', 'pg_loexport' => 'pg_lo_export', 'pg_loimport' => 'pg_lo_import', 'pg_loopen' => 'pg_lo_open', 'pg_loread' => 'pg_lo_read', 'pg_loreadall' => 'pg_lo_read_all', 'pg_lounlink' => 'pg_lo_unlink', 'pg_lowrite' => 'pg_lo_write', 'pg_numfields' => 'pg_num_fields', 'pg_numrows' => 'pg_num_rows', 'pg_result' => 'pg_fetch_result', 'pg_setclientencoding' => 'pg_set_client_encoding']);
$services->set(\Rector\Php80\Rector\ClassMethod\OptionalParametersAfterRequiredRector::class);
$services->set(\Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector::class)->call('configure', [[\Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector::REPLACED_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'lte', 'le'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, '', '!='), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, '!', '!='), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'g', 'gt'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'l', 'lt'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'lte', 'le'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'n', 'ne')])]]);
$services->set(\Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector::class)->configure([new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'lte', 'le'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, '', '!='), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, '!', '!='), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'g', 'gt'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'l', 'lt'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'lte', 'le'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'n', 'ne')]);
$services->set(\Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector::class);
};

View File

@ -7,13 +7,12 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->configure([
// @see http://www.phpspec.net/en/stable/manual/upgrading-to-phpspec-3.html
new \Rector\Renaming\ValueObject\MethodCallRename('PhpSpec\\ServiceContainer', 'set', 'define'),
new \Rector\Renaming\ValueObject\MethodCallRename('PhpSpec\\ServiceContainer', 'setShared', 'define'),
])]]);
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->call('configure', [[\Rector\Renaming\Rector\Name\RenameClassRector::OLD_TO_NEW_CLASSES => ['PhpSpec\\Console\\IO' => 'PhpSpec\\Console\\ConsoleIO', 'PhpSpec\\IO\\IOInterface' => 'PhpSpec\\IO\\IO', 'PhpSpec\\Locator\\ResourceInterface' => 'PhpSpec\\Locator\\Resource', 'PhpSpec\\Locator\\ResourceLocatorInterface' => 'PhpSpec\\Locator\\ResourceLocator', 'PhpSpec\\Formatter\\Presenter\\PresenterInterface' => 'PhpSpec\\Formatter\\Presenter\\Presenter', 'PhpSpec\\CodeGenerator\\Generator\\GeneratorInterface' => 'PhpSpec\\CodeGenerator\\Generator\\Generator', 'PhpSpec\\Extension\\ExtensionInterface' => 'PhpSpec\\Extension', 'Phpspec\\CodeAnalysis\\AccessInspectorInterface' => 'Phpspec\\CodeAnalysis\\AccessInspector', 'Phpspec\\Event\\EventInterface' => 'Phpspec\\Event\\PhpSpecEvent', 'PhpSpec\\Formatter\\Presenter\\Differ\\EngineInterface' => 'PhpSpec\\Formatter\\Presenter\\Differ\\DifferEngine', 'PhpSpec\\Matcher\\MatcherInterface' => 'PhpSpec\\Matcher\\Matcher', 'PhpSpec\\Matcher\\MatchersProviderInterface' => 'PhpSpec\\Matcher\\MatchersProvider', 'PhpSpec\\SpecificationInterface' => 'PhpSpec\\Specification', 'PhpSpec\\Runner\\Maintainer\\MaintainerInterface' => 'PhpSpec\\Runner\\Maintainer\\Maintainer']]]);
]);
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->configure(['PhpSpec\\Console\\IO' => 'PhpSpec\\Console\\ConsoleIO', 'PhpSpec\\IO\\IOInterface' => 'PhpSpec\\IO\\IO', 'PhpSpec\\Locator\\ResourceInterface' => 'PhpSpec\\Locator\\Resource', 'PhpSpec\\Locator\\ResourceLocatorInterface' => 'PhpSpec\\Locator\\ResourceLocator', 'PhpSpec\\Formatter\\Presenter\\PresenterInterface' => 'PhpSpec\\Formatter\\Presenter\\Presenter', 'PhpSpec\\CodeGenerator\\Generator\\GeneratorInterface' => 'PhpSpec\\CodeGenerator\\Generator\\Generator', 'PhpSpec\\Extension\\ExtensionInterface' => 'PhpSpec\\Extension', 'Phpspec\\CodeAnalysis\\AccessInspectorInterface' => 'Phpspec\\CodeAnalysis\\AccessInspector', 'Phpspec\\Event\\EventInterface' => 'Phpspec\\Event\\PhpSpecEvent', 'PhpSpec\\Formatter\\Presenter\\Differ\\EngineInterface' => 'PhpSpec\\Formatter\\Presenter\\Differ\\DifferEngine', 'PhpSpec\\Matcher\\MatcherInterface' => 'PhpSpec\\Matcher\\Matcher', 'PhpSpec\\Matcher\\MatchersProviderInterface' => 'PhpSpec\\Matcher\\MatchersProvider', 'PhpSpec\\SpecificationInterface' => 'PhpSpec\\Specification', 'PhpSpec\\Runner\\Maintainer\\MaintainerInterface' => 'PhpSpec\\Runner\\Maintainer\\Maintainer']);
};

View File

@ -8,9 +8,8 @@ use PHPStan\Type\MixedType;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
$arrayType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType());
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class)->call('configure', [[\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('PhpSpec\\ObjectBehavior', 'getMatchers', $arrayType)])]]);
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class)->configure([new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('PhpSpec\\ObjectBehavior', 'getMatchers', $arrayType)]);
};

File diff suppressed because one or more lines are too long

View File

@ -17,9 +17,7 @@ Let´s say you want to define a custom configuration where you want to update th
All you have to do is using the ChangePackageVersionComposerRector:
```php
<?php
// rector.php
declare(strict_types=1);
use Rector\Composer\Rector\ChangePackageVersionComposerRector;
use Rector\Composer\ValueObject\PackageAndVersion;
@ -29,21 +27,16 @@ use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ChangePackageVersionComposerRector::class)
->call('configure', [[
// we use constant for keys to save you from typos
ChangePackageVersionComposerRector::PACKAGES_AND_VERSIONS => ValueObjectInliner::inline([
new PackageAndVersion('symfony/yaml', '^5.0'),
]),
]]);
->configure([
new PackageAndVersion('symfony/yaml', '^5.0'),
]);
};
```
There are some more rules related to manipulate your composer.json files. Let´s see them in action:
```php
<?php
// rector.php
declare(strict_types=1);
use Rector\Composer\Rector\AddPackageToRequireComposerRector;
use Rector\Composer\Rector\AddPackageToRequireDevComposerRector;
@ -59,37 +52,27 @@ return static function (ContainerConfigurator $containerConfigurator): void {
// Add a package to the require section of your composer.json
$services->set(AddPackageToRequireComposerRector::class)
->call('configure', [[
// we use constant for keys to save you from typos
AddPackageToRequireComposerRector::PACKAGES_AND_VERSIONS => ValueObjectInliner::inline([
new PackageAndVersion('symfony/yaml', '^5.0'),
]),
]]);
->configure([
new PackageAndVersion('symfony/yaml', '^5.0'),
]);
// Add a package to the require dev section of your composer.json
$services->set(AddPackageToRequireDevComposerRector::class)
->call('configure', [[
// we use constant for keys to save you from typos
AddPackageToRequireDevComposerRector::PACKAGES_AND_VERSIONS => ValueObjectInliner::inline([
new PackageAndVersion('phpunit/phpunit', '^9.0'),
]),
]]);
->configure([
new PackageAndVersion('phpunit/phpunit', '^9.0'),
]);
// Remove a package from composer.json
$services->set(RemovePackageComposerRector::class)
->call('configure', [[
// we use constant for keys to save you from typos
RemovePackageComposerRector::PACKAGE_NAMES => ['symfony/console']
]]);
->configure([
'symfony/console'
]);
// Replace a package in the composer.json
$services->set(ReplacePackageAndVersionComposerRector::class)
->call('configure', [[
// we use constant for keys to save you from typos
ReplacePackageAndVersionComposerRector::REPLACE_PACKAGES_AND_VERSIONS => ValueObjectInliner::inline([
new ReplacePackageAndVersion('vendor1/package2', 'vendor2/package1', '^3.0'),
]),
]]);
->configure([
new ReplacePackageAndVersion('vendor1/package2', 'vendor2/package1', '^3.0'),
]);
};
```

View File

@ -17,11 +17,8 @@ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigura
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(RenameClassRector::class)
->call('configure', [[
// we use constant for keys to save you from typos
RenameClassRector::OLD_TO_NEW_CLASSES => [
'App\SomeOldClass' => 'App\SomeNewClass',
],
]]);
->configure([
'App\SomeOldClass' => 'App\SomeNewClass',
]);
};
```

View File

@ -127,11 +127,9 @@ return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(ArgumentAdderRector::class)
->call('configure', [[
ArgumentAdderRector::ADDED_ARGUMENTS => ValueObjectInliner::inline([
new ArgumentAdder('SomeExampleClass', 'someMethod', 0, 'someArgument', true, new ObjectType('SomeType')),
]),
]]);
->configure([
new ArgumentAdder('SomeExampleClass', 'someMethod', 0, 'someArgument', true, new ObjectType('SomeType')),
]);
};
```

View File

@ -90,6 +90,8 @@ CODE_SAMPLE
public function configure(array $configuration) : void
{
$typeToPreference = $configuration[self::TYPE_TO_PREFERENCE] ?? $configuration;
\RectorPrefix20211130\Webmozart\Assert\Assert::isArray($typeToPreference);
\RectorPrefix20211130\Webmozart\Assert\Assert::allString(\array_keys($typeToPreference));
\RectorPrefix20211130\Webmozart\Assert\Assert::allIsAOf($typeToPreference, \Rector\CodingStyle\Enum\PreferenceSelfThis::class);
$this->typeToPreference = $typeToPreference;
}

View File

@ -141,11 +141,11 @@ CODE_SAMPLE
*/
public function configure(array $configuration) : void
{
$safeTypes = $configuration[self::SAFE_TYPES] ?? $configuration;
$safeTypes = $configuration[self::SAFE_TYPES] ?? [];
\RectorPrefix20211130\Webmozart\Assert\Assert::isArray($safeTypes);
\RectorPrefix20211130\Webmozart\Assert\Assert::allString($safeTypes);
$this->safeTypes = $safeTypes;
$safeTypesToMethods = $configuration[self::SAFE_TYPES_TO_METHODS] ?? $configuration;
$safeTypesToMethods = $configuration[self::SAFE_TYPES_TO_METHODS] ?? [];
\RectorPrefix20211130\Webmozart\Assert\Assert::isArray($safeTypesToMethods);
foreach ($safeTypesToMethods as $key => $value) {
\RectorPrefix20211130\Webmozart\Assert\Assert::string($key);

View File

@ -60,7 +60,7 @@ CODE_SAMPLE
*/
private function shouldSkip($node) : bool
{
if (\count($node->args) !== 1) {
if (\count($node->getRawArgs()) !== 1) {
return \true;
}
return !$node->args[0] instanceof \PhpParser\Node\VariadicPlaceholder;

View File

@ -79,7 +79,7 @@ final class RemoveExtraParametersRector extends \Rector\Core\Rector\AbstractRect
}
}
$maximumAllowedParameterCount = $this->resolveMaximumAllowedParameterCount($functionLikeReflection);
$numberOfArguments = \count($node->args);
$numberOfArguments = \count($node->getRawArgs());
if ($numberOfArguments <= $maximumAllowedParameterCount) {
return null;
}

View File

@ -64,7 +64,7 @@ final class RenameStaticMethodRector extends \Rector\Core\Rector\AbstractRector
*/
public function configure(array $configuration) : void
{
$oldToNewMethodsByClasses = $configuration[self::OLD_TO_NEW_METHODS_BY_CLASSES];
$oldToNewMethodsByClasses = $configuration[self::OLD_TO_NEW_METHODS_BY_CLASSES] ?? $configuration;
\RectorPrefix20211130\Webmozart\Assert\Assert::allIsAOf($oldToNewMethodsByClasses, \Rector\Renaming\ValueObject\RenameStaticMethod::class);
$this->staticMethodRenames = $oldToNewMethodsByClasses;
}

View File

@ -0,0 +1,9 @@
<?php
declare (strict_types=1);
namespace Rector\Transform\Contract\ValueObject;
interface ArgumentFuncCallToMethodCallInterface
{
public function getFunction() : string;
}

View File

@ -19,6 +19,7 @@ use Rector\NodeTypeResolver\TypeAnalyzer\ArrayTypeAnalyzer;
use Rector\PostRector\Collector\PropertyToAddCollector;
use Rector\PostRector\ValueObject\PropertyMetadata;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
use Rector\Transform\Contract\ValueObject\ArgumentFuncCallToMethodCallInterface;
use Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall;
use Rector\Transform\ValueObject\ArrayFuncCallToMethodCall;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
@ -34,17 +35,9 @@ final class ArgumentFuncCallToMethodCallRector extends \Rector\Core\Rector\Abstr
*/
public const FUNCTIONS_TO_METHOD_CALLS = 'functions_to_method_calls';
/**
* @var string
*/
public const ARRAY_FUNCTIONS_TO_METHOD_CALLS = 'array_functions_to_method_calls';
/**
* @var ArgumentFuncCallToMethodCall[]
* @var ArgumentFuncCallToMethodCallInterface[]
*/
private $argumentFuncCallToMethodCalls = [];
/**
* @var ArrayFuncCallToMethodCall[]
*/
private $arrayFunctionsToMethodCalls = [];
/**
* @var \Rector\NodeTypeResolver\TypeAnalyzer\ArrayTypeAnalyzer
*/
@ -118,13 +111,11 @@ CODE_SAMPLE
if (!$this->isName($node, $argumentFuncCallToMethodCall->getFunction())) {
continue;
}
return $this->refactorFuncCallToMethodCall($argumentFuncCallToMethodCall, $classLike, $node);
}
foreach ($this->arrayFunctionsToMethodCalls as $arrayFunctionToMethodCall) {
if (!$this->isName($node, $arrayFunctionToMethodCall->getFunction())) {
continue;
if ($argumentFuncCallToMethodCall instanceof \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall) {
return $this->refactorFuncCallToMethodCall($argumentFuncCallToMethodCall, $classLike, $node);
} elseif ($argumentFuncCallToMethodCall instanceof \Rector\Transform\ValueObject\ArrayFuncCallToMethodCall) {
return $this->refactorArrayFunctionToMethodCall($argumentFuncCallToMethodCall, $node, $classLike);
}
return $this->refactorArrayFunctionToMethodCall($arrayFunctionToMethodCall, $node, $classLike);
}
return null;
}
@ -134,11 +125,9 @@ CODE_SAMPLE
public function configure(array $configuration) : void
{
$functionToMethodCalls = $configuration[self::FUNCTIONS_TO_METHOD_CALLS] ?? $configuration;
\RectorPrefix20211130\Webmozart\Assert\Assert::allIsAOf($functionToMethodCalls, \Rector\Transform\ValueObject\ArgumentFuncCallToMethodCall::class);
\RectorPrefix20211130\Webmozart\Assert\Assert::isArray($functionToMethodCalls);
\RectorPrefix20211130\Webmozart\Assert\Assert::allIsAOf($functionToMethodCalls, \Rector\Transform\Contract\ValueObject\ArgumentFuncCallToMethodCallInterface::class);
$this->argumentFuncCallToMethodCalls = $functionToMethodCalls;
$arrayFunctionsToMethodCalls = $configuration[self::ARRAY_FUNCTIONS_TO_METHOD_CALLS] ?? $configuration;
\RectorPrefix20211130\Webmozart\Assert\Assert::allIsAOf($arrayFunctionsToMethodCalls, \Rector\Transform\ValueObject\ArrayFuncCallToMethodCall::class);
$this->arrayFunctionsToMethodCalls = $arrayFunctionsToMethodCalls;
}
private function shouldSkipFuncCall(\PhpParser\Node\Expr\FuncCall $funcCall) : bool
{

View File

@ -3,7 +3,8 @@
declare (strict_types=1);
namespace Rector\Transform\ValueObject;
final class ArgumentFuncCallToMethodCall
use Rector\Transform\Contract\ValueObject\ArgumentFuncCallToMethodCallInterface;
final class ArgumentFuncCallToMethodCall implements \Rector\Transform\Contract\ValueObject\ArgumentFuncCallToMethodCallInterface
{
/**
* @var string

View File

@ -3,7 +3,9 @@
declare (strict_types=1);
namespace Rector\Transform\ValueObject;
final class ArrayFuncCallToMethodCall
use Rector\Core\Validation\RectorAssert;
use Rector\Transform\Contract\ValueObject\ArgumentFuncCallToMethodCallInterface;
final class ArrayFuncCallToMethodCall implements \Rector\Transform\Contract\ValueObject\ArgumentFuncCallToMethodCallInterface
{
/**
* @var \non-empty-string
@ -33,6 +35,7 @@ final class ArrayFuncCallToMethodCall
$this->class = $class;
$this->arrayMethod = $arrayMethod;
$this->nonArrayMethod = $nonArrayMethod;
\Rector\Core\Validation\RectorAssert::className($class);
}
public function getFunction() : string
{

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'd1fd98466e833573825fd0f35bd32b7dbe02264d';
public const PACKAGE_VERSION = '58c8a93698dd3087905c1aa4233ca61c447c16d3';
/**
* @var string
*/
public const RELEASE_DATE = '2021-11-30 10:17:31';
public const RELEASE_DATE = '2021-11-30 14:39:01';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211130\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

View File

@ -3,6 +3,7 @@
declare (strict_types=1);
namespace Rector\Core\DependencyInjection\Collector;
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
use RectorPrefix20211130\Symfony\Component\DependencyInjection\Definition;
use RectorPrefix20211130\Symplify\PackageBuilder\Yaml\ParametersMerger;
final class ConfigureCallValuesCollector
@ -26,6 +27,9 @@ final class ConfigureCallValuesCollector
{
return $this->configureCallValuesByRectorClass[$rectorClass] ?? [];
}
/**
* @param class-string<ConfigurableRectorInterface> $className
*/
public function collectFromServiceAndClassName(string $className, \RectorPrefix20211130\Symfony\Component\DependencyInjection\Definition $definition) : void
{
foreach ($definition->getMethodCalls() as $methodCall) {
@ -36,11 +40,20 @@ final class ConfigureCallValuesCollector
}
}
/**
* @param class-string<ConfigurableRectorInterface> $rectorClass
* @param mixed[] $configureValues
*/
private function addConfigureCallValues(string $rectorClass, array $configureValues) : void
{
foreach ($configureValues as $configureValue) {
// is nested or unnested value?
if (\is_array($configureValue) && \count($configureValue) === 1) {
\reset($configureValue);
$firstKey = \key($configureValue);
if (\is_array($configureValue[$firstKey])) {
$configureValue = $configureValue[$firstKey];
}
}
if (!isset($this->configureCallValuesByRectorClass[$rectorClass])) {
$this->configureCallValuesByRectorClass[$rectorClass] = $configureValue;
} else {

2
vendor/autoload.php vendored
View File

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

View File

@ -2922,6 +2922,7 @@ return array(
'Rector\\Testing\\PHPUnit\\Behavior\\MultipleFilesChangedTrait' => $baseDir . '/packages/Testing/PHPUnit/Behavior/MultipleFilesChangedTrait.php',
'Rector\\Testing\\PHPUnit\\StaticPHPUnitEnvironment' => $baseDir . '/packages/Testing/PHPUnit/StaticPHPUnitEnvironment.php',
'Rector\\Testing\\TestingParser\\TestingParser' => $baseDir . '/packages/Testing/TestingParser/TestingParser.php',
'Rector\\Transform\\Contract\\ValueObject\\ArgumentFuncCallToMethodCallInterface' => $baseDir . '/rules/Transform/Contract/ValueObject/ArgumentFuncCallToMethodCallInterface.php',
'Rector\\Transform\\NodeAnalyzer\\FuncCallStaticCallToMethodCallAnalyzer' => $baseDir . '/rules/Transform/NodeAnalyzer/FuncCallStaticCallToMethodCallAnalyzer.php',
'Rector\\Transform\\NodeAnalyzer\\SingletonClassMethodAnalyzer' => $baseDir . '/rules/Transform/NodeAnalyzer/SingletonClassMethodAnalyzer.php',
'Rector\\Transform\\NodeFactory\\PropertyFetchFactory' => $baseDir . '/rules/Transform/NodeFactory/PropertyFetchFactory.php',

View File

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

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit158aaae07c465694457e97031fc40e54
class ComposerStaticInitf5555a90cdff5c8f1bd0718519c94348
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3319,6 +3319,7 @@ class ComposerStaticInit158aaae07c465694457e97031fc40e54
'Rector\\Testing\\PHPUnit\\Behavior\\MultipleFilesChangedTrait' => __DIR__ . '/../..' . '/packages/Testing/PHPUnit/Behavior/MultipleFilesChangedTrait.php',
'Rector\\Testing\\PHPUnit\\StaticPHPUnitEnvironment' => __DIR__ . '/../..' . '/packages/Testing/PHPUnit/StaticPHPUnitEnvironment.php',
'Rector\\Testing\\TestingParser\\TestingParser' => __DIR__ . '/../..' . '/packages/Testing/TestingParser/TestingParser.php',
'Rector\\Transform\\Contract\\ValueObject\\ArgumentFuncCallToMethodCallInterface' => __DIR__ . '/../..' . '/rules/Transform/Contract/ValueObject/ArgumentFuncCallToMethodCallInterface.php',
'Rector\\Transform\\NodeAnalyzer\\FuncCallStaticCallToMethodCallAnalyzer' => __DIR__ . '/../..' . '/rules/Transform/NodeAnalyzer/FuncCallStaticCallToMethodCallAnalyzer.php',
'Rector\\Transform\\NodeAnalyzer\\SingletonClassMethodAnalyzer' => __DIR__ . '/../..' . '/rules/Transform/NodeAnalyzer/SingletonClassMethodAnalyzer.php',
'Rector\\Transform\\NodeFactory\\PropertyFetchFactory' => __DIR__ . '/../..' . '/rules/Transform/NodeFactory/PropertyFetchFactory.php',
@ -3789,9 +3790,9 @@ class ComposerStaticInit158aaae07c465694457e97031fc40e54
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit158aaae07c465694457e97031fc40e54::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit158aaae07c465694457e97031fc40e54::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit158aaae07c465694457e97031fc40e54::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitf5555a90cdff5c8f1bd0718519c94348::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf5555a90cdff5c8f1bd0718519c94348::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitf5555a90cdff5c8f1bd0718519c94348::$classMap;
}, null, ClassLoader::class);
}

View File

@ -12,8 +12,8 @@ if (!class_exists('GenerateChangelogCommand', false) && !interface_exists('Gener
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20211130\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit158aaae07c465694457e97031fc40e54', false) && !interface_exists('ComposerAutoloaderInit158aaae07c465694457e97031fc40e54', false) && !trait_exists('ComposerAutoloaderInit158aaae07c465694457e97031fc40e54', false)) {
spl_autoload_call('RectorPrefix20211130\ComposerAutoloaderInit158aaae07c465694457e97031fc40e54');
if (!class_exists('ComposerAutoloaderInitf5555a90cdff5c8f1bd0718519c94348', false) && !interface_exists('ComposerAutoloaderInitf5555a90cdff5c8f1bd0718519c94348', false) && !trait_exists('ComposerAutoloaderInitf5555a90cdff5c8f1bd0718519c94348', false)) {
spl_autoload_call('RectorPrefix20211130\ComposerAutoloaderInitf5555a90cdff5c8f1bd0718519c94348');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20211130\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -81,9 +81,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20211130\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire158aaae07c465694457e97031fc40e54')) {
function composerRequire158aaae07c465694457e97031fc40e54() {
return \RectorPrefix20211130\composerRequire158aaae07c465694457e97031fc40e54(...func_get_args());
if (!function_exists('composerRequiref5555a90cdff5c8f1bd0718519c94348')) {
function composerRequiref5555a90cdff5c8f1bd0718519c94348() {
return \RectorPrefix20211130\composerRequiref5555a90cdff5c8f1bd0718519c94348(...func_get_args());
}
}
if (!function_exists('scanPath')) {