Updated Rector to commit f3b3c8727f

f3b3c8727f [docs] example and title for tests (#191)
This commit is contained in:
Tomas Votruba 2021-06-09 15:02:10 +00:00
parent c1bc102f24
commit 06272681a5
7 changed files with 45 additions and 23 deletions

View File

@ -29,7 +29,7 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
final class MyFirstRector extends AbstractRector
{
/**
* @return string[]
* @return array<class-string<Node>>
*/
public function getNodeTypes(): array
{
@ -60,7 +60,7 @@ final class MyFirstRector extends AbstractRector
}
/**
* From this method documentation is generated.
* This method helps other to understand the rule and to generate documentation.
*/
public function getRuleDefinition(): RuleDefinition
{
@ -78,7 +78,24 @@ final class MyFirstRector extends AbstractRector
}
```
This is how the file structure should look like:
## File Structure
This is how the file structure for custom rule in your own project will look like:
```bash
/src/
/YourCode.php
/utils
/rector
/src
/Rector
MyFirstRector.php
rector.php
composer.json
```
Writing test saves you lot of time in future debugging. Here is a file structure with tests:
```bash
/src/
@ -91,11 +108,17 @@ This is how the file structure should look like:
/tests
/Rector
/MyFirstRector
/Fixture
test_fixture.php.inc
/config
config.php
MyFirstRectorTest.php
rector.php
composer.json
```
## Update `composer.json`
We also need to load Rector rules in `composer.json`:
```json

View File

@ -4,7 +4,6 @@ declare (strict_types=1);
namespace Rector\DowngradePhp80\Rector\Expression;
use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Match_;
use PhpParser\Node\MatchArm;

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'e31005a633524405c675d722fdc2675651832d4e';
public const PACKAGE_VERSION = 'f3b3c8727fd25c5c12f0147bb01f20cfe8f3c87a';
/**
* @var string
*/
public const RELEASE_DATE = '2021-06-09 16:33:44';
public const RELEASE_DATE = '2021-06-09 16:45:03';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20210609\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit8084e9b8b0a0704e79064c1ee065a30b
class ComposerAutoloaderInit8a80385fc712197ff8c43f903b312bab
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit8084e9b8b0a0704e79064c1ee065a30b
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit8084e9b8b0a0704e79064c1ee065a30b', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit8a80385fc712197ff8c43f903b312bab', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit8084e9b8b0a0704e79064c1ee065a30b', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit8a80385fc712197ff8c43f903b312bab', '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\ComposerStaticInit8084e9b8b0a0704e79064c1ee065a30b::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit8a80385fc712197ff8c43f903b312bab::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit8084e9b8b0a0704e79064c1ee065a30b
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit8084e9b8b0a0704e79064c1ee065a30b::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit8a80385fc712197ff8c43f903b312bab::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire8084e9b8b0a0704e79064c1ee065a30b($fileIdentifier, $file);
composerRequire8a80385fc712197ff8c43f903b312bab($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire8084e9b8b0a0704e79064c1ee065a30b($fileIdentifier, $file)
function composerRequire8a80385fc712197ff8c43f903b312bab($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit8084e9b8b0a0704e79064c1ee065a30b
class ComposerStaticInit8a80385fc712197ff8c43f903b312bab
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3879,9 +3879,9 @@ class ComposerStaticInit8084e9b8b0a0704e79064c1ee065a30b
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit8084e9b8b0a0704e79064c1ee065a30b::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit8084e9b8b0a0704e79064c1ee065a30b::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit8084e9b8b0a0704e79064c1ee065a30b::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit8a80385fc712197ff8c43f903b312bab::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit8a80385fc712197ff8c43f903b312bab::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit8a80385fc712197ff8c43f903b312bab::$classMap;
}, null, ClassLoader::class);
}

View File

@ -21,8 +21,8 @@ if (!class_exists('SomeTestCase', false) && !interface_exists('SomeTestCase', fa
if (!class_exists('CheckoutEntityFactory', false) && !interface_exists('CheckoutEntityFactory', false) && !trait_exists('CheckoutEntityFactory', false)) {
spl_autoload_call('RectorPrefix20210609\CheckoutEntityFactory');
}
if (!class_exists('ComposerAutoloaderInit8084e9b8b0a0704e79064c1ee065a30b', false) && !interface_exists('ComposerAutoloaderInit8084e9b8b0a0704e79064c1ee065a30b', false) && !trait_exists('ComposerAutoloaderInit8084e9b8b0a0704e79064c1ee065a30b', false)) {
spl_autoload_call('RectorPrefix20210609\ComposerAutoloaderInit8084e9b8b0a0704e79064c1ee065a30b');
if (!class_exists('ComposerAutoloaderInit8a80385fc712197ff8c43f903b312bab', false) && !interface_exists('ComposerAutoloaderInit8a80385fc712197ff8c43f903b312bab', false) && !trait_exists('ComposerAutoloaderInit8a80385fc712197ff8c43f903b312bab', false)) {
spl_autoload_call('RectorPrefix20210609\ComposerAutoloaderInit8a80385fc712197ff8c43f903b312bab');
}
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
spl_autoload_call('RectorPrefix20210609\Doctrine\Inflector\Inflector');
@ -3323,9 +3323,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20210609\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire8084e9b8b0a0704e79064c1ee065a30b')) {
function composerRequire8084e9b8b0a0704e79064c1ee065a30b() {
return \RectorPrefix20210609\composerRequire8084e9b8b0a0704e79064c1ee065a30b(...func_get_args());
if (!function_exists('composerRequire8a80385fc712197ff8c43f903b312bab')) {
function composerRequire8a80385fc712197ff8c43f903b312bab() {
return \RectorPrefix20210609\composerRequire8a80385fc712197ff8c43f903b312bab(...func_get_args());
}
}
if (!function_exists('parseArgs')) {