Updated Rector to commit dd96863b8ef3b8a86d9268e9e2f7bb5632dfb375

dd96863b8e [ci] separate e2e test with changed attributes (#2066)
This commit is contained in:
Tomas Votruba 2022-04-12 15:58:47 +00:00
parent 071d7cb788
commit b1c2035103
63 changed files with 255 additions and 213 deletions

View File

@ -17,7 +17,6 @@ jobs:
matrix:
php_version: ['7.2', '7.3', '7.4', '8.0', '8.1']
directory:
- 'e2e/attributes'
- 'e2e/define-constant'
- 'e2e/dont-execute-code'
- 'e2e/finalize'

38
.github/workflows/e2e_diff.yaml vendored Normal file
View File

@ -0,0 +1,38 @@
# This workflow runs system tests: Use the Rector application from the source
# checkout to process "fixture" projects in tests/system-tests
# to see if those can be processed successfully
name: End to End tests that expect diff
on:
pull_request: null
push:
branches:
- main
jobs:
end_to_end_with_diff:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php_version: ['7.2', '7.3', '7.4', '8.0', '8.1']
directory:
- 'e2e/attributes'
name: End to end test with diff - ${{ matrix.directory }}
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_version }}
coverage: none
-
run: composer install --ansi
working-directory: ${{ matrix.directory }}
-
run: ../../bin/rector --ansi
working-directory: ${{ matrix.directory }}

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = 'c35cc97d381f97c602cccb86ccf1d688a869cbdd';
public const PACKAGE_VERSION = 'dd96863b8ef3b8a86d9268e9e2f7bb5632dfb375';
/**
* @var string
*/
public const RELEASE_DATE = '2022-04-12 16:33:33';
public const RELEASE_DATE = '2022-04-12 17:52:46';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20220412\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit13e807cd3be494fed4e52d5cff90940f::getLoader();
return ComposerAutoloaderInit78c49bb15bb72f975752ce11f96a623b::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit13e807cd3be494fed4e52d5cff90940f
class ComposerAutoloaderInit78c49bb15bb72f975752ce11f96a623b
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit13e807cd3be494fed4e52d5cff90940f
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit13e807cd3be494fed4e52d5cff90940f', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit78c49bb15bb72f975752ce11f96a623b', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit13e807cd3be494fed4e52d5cff90940f', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit78c49bb15bb72f975752ce11f96a623b', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit13e807cd3be494fed4e52d5cff90940f::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit78c49bb15bb72f975752ce11f96a623b::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit13e807cd3be494fed4e52d5cff90940f::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit78c49bb15bb72f975752ce11f96a623b::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire13e807cd3be494fed4e52d5cff90940f($fileIdentifier, $file);
composerRequire78c49bb15bb72f975752ce11f96a623b($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit13e807cd3be494fed4e52d5cff90940f
* @param string $file
* @return void
*/
function composerRequire13e807cd3be494fed4e52d5cff90940f($fileIdentifier, $file)
function composerRequire78c49bb15bb72f975752ce11f96a623b($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

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

View File

@ -2203,12 +2203,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "21431cc9e81990191be9c235e67c631ed518d0a3"
"reference": "ae06e92e71b741f43906374a699eb041882259c3"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/21431cc9e81990191be9c235e67c631ed518d0a3",
"reference": "21431cc9e81990191be9c235e67c631ed518d0a3",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/ae06e92e71b741f43906374a699eb041882259c3",
"reference": "ae06e92e71b741f43906374a699eb041882259c3",
"shasum": ""
},
"require": {
@ -2225,7 +2225,7 @@
"phpstan\/phpstan-webmozart-assert": "^1.0",
"phpunit\/phpunit": "^9.5",
"rector\/phpstan-rules": "^0.4.8",
"rector\/rector-src": "dev-main#c6a8c6b",
"rector\/rector-src": "dev-main",
"symplify\/easy-coding-standard": "^10.1",
"symplify\/monorepo-builder": "^10.1",
"symplify\/phpstan-extensions": "^10.1",
@ -2233,7 +2233,7 @@
"symplify\/rule-doc-generator": "^10.1",
"symplify\/vendor-patches": "^10.1"
},
"time": "2022-04-09T23:17:54+00:00",
"time": "2022-04-12T15:21:35+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
@ -2559,12 +2559,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "baf6f9eaa1eadc03d61ac6f414077d85b0540dfa"
"reference": "41775450593f1a94c30a562865c5340f4118880c"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/baf6f9eaa1eadc03d61ac6f414077d85b0540dfa",
"reference": "baf6f9eaa1eadc03d61ac6f414077d85b0540dfa",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/41775450593f1a94c30a562865c5340f4118880c",
"reference": "41775450593f1a94c30a562865c5340f4118880c",
"shasum": ""
},
"require": {
@ -2589,7 +2589,7 @@
"symplify\/rule-doc-generator": "^10.0",
"symplify\/vendor-patches": "^10.0"
},
"time": "2022-04-11T22:24:50+00:00",
"time": "2022-04-12T15:23:53+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main eab7b79'), '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 21431cc'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 68d30fe'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 31d9892'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e01d41e'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 1e12437'), '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 baf6f9e'), '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 a3ad2a2'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5fc785d'));
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main eab7b79'), '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 ae06e92'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 68d30fe'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 31d9892'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main e01d41e'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 1e12437'), '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 4177545'), '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 a3ad2a2'), 'ssch/typo3-rector' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/ssch/typo3-rector', 'relative_install_path' => '../../../ssch/typo3-rector', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 5fc785d'));
private function __construct()
{
}

View File

@ -15,7 +15,7 @@
"symplify\/phpstan-extensions": "^10.1",
"symplify\/easy-coding-standard": "^10.1",
"symplify\/rule-doc-generator": "^10.1",
"rector\/rector-src": "dev-main#c6a8c6b",
"rector\/rector-src": "dev-main",
"doctrine\/orm": "^2.10",
"symplify\/monorepo-builder": "^10.1",
"phpstan\/phpstan-webmozart-assert": "^1.0",

View File

@ -3,9 +3,9 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
use Rector\Config\RectorConfig;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->defaults()->public()->autowire()->autoconfigure();
$services->load('Rector\\Doctrine\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/Rector', __DIR__ . '/../src/ValueObject']);
};

View File

@ -3,11 +3,11 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\ValueObject\AnnotationToAttribute;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class)->configure([
// class
new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ORM\\Mapping\\Table'),

View File

@ -3,12 +3,12 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\Doctrine\Rector\Class_\AddEntityIdByConditionRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Transform\Rector\Class_\AddInterfaceByTraitRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\Transform\Rector\Class_\AddInterfaceByTraitRector::class)->configure(['Knp\\DoctrineBehaviors\\Model\\Timestampable\\Timestampable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TimestampableInterface', 'Knp\\DoctrineBehaviors\\Model\\Timestampable\\TimestampableMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TimestampableInterface', 'Knp\\DoctrineBehaviors\\Model\\Blameable\\Blameable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\BlameableInterface', 'Knp\\DoctrineBehaviors\\Model\\Blameable\\BlameableMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\BlameableInterface', 'Knp\\DoctrineBehaviors\\Model\\Loggable\\Loggable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\LoggableInterface', 'Knp\\DoctrineBehaviors\\Model\\SoftDeletable\\SoftDeletable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\SoftDeletableInterface', 'Knp\\DoctrineBehaviors\\Model\\SoftDeletable\\SoftDeletableMethodsTrait' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\SoftDeletableInterface', 'Knp\\DoctrineBehaviors\\Model\\Translatable\\Translatable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslatableInterface', 'Knp\\DoctrineBehaviors\\Model\\Translatable\\TranslatableMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslatableInterface', 'Knp\\DoctrineBehaviors\\Model\\Translatable\\Translation' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslationInterface', 'Knp\\DoctrineBehaviors\\Model\\Translatable\\TranslationMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\TranslationInterface', 'Knp\\DoctrineBehaviors\\Model\\Uuidable\\Uuidable' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\UuidableInterface', 'Knp\\DoctrineBehaviors\\Model\\Uuidable\\UuidableMethods' => 'Knp\\DoctrineBehaviors\\Contract\\Entity\\UuidableInterface']);
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->configure([
# move interface to "Contract"

View File

@ -3,6 +3,7 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\Doctrine\Rector\Class_\InitializeDefaultEntityCollectionRector;
use Rector\Doctrine\Rector\Class_\ManagerRegistryGetManagerToEntityManagerRector;
use Rector\Doctrine\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector;
@ -22,9 +23,8 @@ use Rector\Transform\Rector\Attribute\AttributeKeyToClassConstFetchRector;
use Rector\Transform\Rector\MethodCall\ServiceGetterToConstructorInjectionRector;
use Rector\Transform\ValueObject\AttributeKeyToClassConstFetch;
use Rector\Transform\ValueObject\ServiceGetterToConstructorInjection;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\Doctrine\Rector\Class_\ManagerRegistryGetManagerToEntityManagerRector::class);
$services->set(\Rector\Doctrine\Rector\Class_\InitializeDefaultEntityCollectionRector::class);
$services->set(\Rector\Doctrine\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector::class);

View File

@ -3,10 +3,10 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
# see https://github.com/doctrine/persistence/pull/71
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->configure(['Doctrine\\Common\\Persistence\\Event\\LifecycleEventArgs' => 'Doctrine\\Persistence\\Event\\LifecycleEventArgs', 'Doctrine\\Common\\Persistence\\Event\\LoadClassMetadataEventArgs' => 'Doctrine\\Persistence\\Event\\LoadClassMetadataEventArgs', 'Doctrine\\Common\\Persistence\\Event\\ManagerEventArgs' => 'Doctrine\\Persistence\\Event\\ManagerEventArgs', 'Doctrine\\Common\\Persistence\\Mapping\\AbstractClassMetadataFactory' => 'Doctrine\\Persistence\\Mapping\\AbstractClassMetadataFactory', 'Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata' => 'Doctrine\\Persistence\\Mapping\\ClassMetadata', 'Doctrine\\Common\\Persistence\\Mapping\\ClassMetadataFactory' => 'Doctrine\\Persistence\\Mapping\\ClassMetadataFactory', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\FileDriver' => 'Doctrine\\Persistence\\Mapping\\Driver\\FileDriver', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriver' => 'Doctrine\\Persistence\\Mapping\\Driver\\MappingDriver', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\MappingDriverChain' => 'Doctrine\\Persistence\\Mapping\\Driver\\MappingDriverChain', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\PHPDriver' => 'Doctrine\\Persistence\\Mapping\\Driver\\PHPDriver', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\StaticPHPDriver' => 'Doctrine\\Persistence\\Mapping\\Driver\\StaticPHPDriver', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\SymfonyFileLocator' => 'Doctrine\\Persistence\\Mapping\\Driver\\SymfonyFileLocator', 'Doctrine\\Common\\Persistence\\Mapping\\MappingException' => 'Doctrine\\Persistence\\Mapping\\MappingException', 'Doctrine\\Common\\Persistence\\Mapping\\ReflectionService' => 'Doctrine\\Persistence\\Mapping\\ReflectionService', 'Doctrine\\Common\\Persistence\\Mapping\\RuntimeReflectionService' => 'Doctrine\\Persistence\\Mapping\\RuntimeReflectionService', 'Doctrine\\Common\\Persistence\\Mapping\\StaticReflectionService' => 'Doctrine\\Persistence\\Mapping\\StaticReflectionService', 'Doctrine\\Common\\Persistence\\ObjectManager' => 'Doctrine\\Persistence\\ObjectManager', 'Doctrine\\Common\\Persistence\\ObjectManagerDecorator' => 'Doctrine\\Persistence\\ObjectManagerDecorator', 'Doctrine\\Common\\Persistence\\ObjectRepository' => 'Doctrine\\Persistence\\ObjectRepository', 'Doctrine\\Common\\Persistence\\Proxy' => 'Doctrine\\Persistence\\Proxy', 'Doctrine\\Common\\Persistence\\AbstractManagerRegistry' => 'Doctrine\\Persistence\\AbstractManagerRegistry', 'Doctrine\\Common\\Persistence\\Mapping\\Driver\\DefaultFileLocator' => 'Doctrine\\Persistence\\Mapping\\Driver\\DefaultFileLocator', 'Doctrine\\Common\\Persistence\\ManagerRegistry' => 'Doctrine\\Persistence\\ManagerRegistry']);
};

View File

@ -3,10 +3,10 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
# https://github.com/doctrine/dbal/blob/master/UPGRADE.md#deprecated-type-constants
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->configure(['Doctrine\\DBAL\\Types\\Type' => 'Doctrine\\DBAL\\Types\\Types']);
};

View File

@ -3,12 +3,12 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->configure([
// https://github.com/doctrine/dbal/blob/master/UPGRADE.md#deprecations-in-the-wrapper-connection-class
new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Connection', 'executeUpdate', 'executeStatement'),

View File

@ -4,15 +4,15 @@ declare (strict_types=1);
namespace RectorPrefix20220412;
use PHPStan\Type\VoidType;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
# https://github.com/doctrine/dbal/blob/master/UPGRADE.md#bc-break-changes-in-handling-string-and-binary-columns
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->configure([new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Platforms\\AbstractPlatform', 'getVarcharTypeDeclarationSQL', 'getStringTypeDeclarationSQL'), new \Rector\Renaming\ValueObject\MethodCallRename('Doctrine\\DBAL\\Driver\\DriverException', 'getErrorCode', 'getCode')]);
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class)->configure([new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('Doctrine\\DBAL\\Connection', 'ping', new \PHPStan\Type\VoidType())]);
# https://github.com/doctrine/dbal/blob/master/UPGRADE.md#deprecated-abstractionresult

View File

@ -3,6 +3,7 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\Doctrine\Rector\Class_\BlameableBehaviorRector;
use Rector\Doctrine\Rector\Class_\LoggableBehaviorRector;
use Rector\Doctrine\Rector\Class_\SluggableBehaviorRector;
@ -10,10 +11,9 @@ use Rector\Doctrine\Rector\Class_\SoftDeletableBehaviorRector;
use Rector\Doctrine\Rector\Class_\TimestampableBehaviorRector;
use Rector\Doctrine\Rector\Class_\TranslationBehaviorRector;
use Rector\Doctrine\Rector\Class_\TreeBehaviorRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
# version gedmo/doctrine-extensions 2.x to knplabs/doctrine-behaviors 2.0
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\Doctrine\Rector\Class_\TimestampableBehaviorRector::class);
$services->set(\Rector\Doctrine\Rector\Class_\SluggableBehaviorRector::class);
$services->set(\Rector\Doctrine\Rector\Class_\TreeBehaviorRector::class);

View File

@ -3,10 +3,10 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\ValueObject\AnnotationToAttribute;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class)->configure([new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\AlsoLoad'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ChangeTrackingPolicy'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DefaultDiscriminatorValue'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorField'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorMap'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\DiscriminatorValue'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Document'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\EmbeddedDocument'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\EmbedMany'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\EmbedOne'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Field'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\ChunkSize'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\Filename'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\Length'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\Metadata'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\File\\UploadDate'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\HasLifecycleCallbacks'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Id'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Index'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Indexes'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\InheritanceType'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Lock'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\MappedSuperclass'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PostLoad'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PostPersist'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PostRemove'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PostUpdate'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PreFlush'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PreLoad'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PrePersist'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PreRemove'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\PreUpdate'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\QueryResultDocument'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ReadPreference'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ReferenceMany'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ReferenceOne'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\ShardKey'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\UniqueIndex'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Validation'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\Version'), new \Rector\Php80\ValueObject\AnnotationToAttribute('Doctrine\\ODM\\MongoDB\\Mapping\\Annotations\\View')]);
};

View File

@ -3,7 +3,7 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$containerConfigurator->import(__DIR__ . '/doctrine-annotations-to-attributes.php');
use Rector\Config\RectorConfig;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->import(__DIR__ . '/doctrine-annotations-to-attributes.php');
};

View File

@ -3,6 +3,7 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassLike\RemoveAnnotationRector;
use Rector\Doctrine\Rector\Class_\MoveRepositoryFromParentToConstructorRector;
use Rector\Doctrine\Rector\Class_\RemoveRepositoryFromEntityAnnotationRector;
@ -13,15 +14,15 @@ use Rector\Renaming\Rector\PropertyFetch\RenamePropertyRector;
use Rector\Renaming\ValueObject\RenameProperty;
use Rector\Transform\Rector\MethodCall\MethodCallToPropertyFetchRector;
use Rector\Transform\Rector\MethodCall\ReplaceParentCallByPropertyCallRector;
use Rector\Transform\ValueObject\MethodCallToPropertyFetch;
use Rector\Transform\ValueObject\ReplaceParentCallByPropertyCall;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
/**
* @see https://tomasvotruba.com/blog/2017/10/16/how-to-use-repository-with-doctrine-as-service-in-symfony/
* @see https://tomasvotruba.com/blog/2018/04/02/rectify-turn-repositories-to-services-in-symfony/
* @see https://getrector.org/blog/2021/02/08/how-to-instantly-decouple-symfony-doctrine-repository-inheritance-to-clean-composition
*/
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
# order matters, this needs to be first to correctly detect parent repository
// covers "extends EntityRepository"
$services->set(\Rector\Doctrine\Rector\Class_\MoveRepositoryFromParentToConstructorRector::class);

View File

@ -4,13 +4,13 @@ declare (strict_types=1);
namespace RectorPrefix20220412;
use PHPStan\Type\ObjectType;
use Rector\Config\RectorConfig;
use Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector;
use Rector\Removing\ValueObject\ArgumentRemover;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class)->configure([new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Doctrine\\ORM\\Mapping\\ClassMetadataFactory', 'setEntityManager', 0, new \PHPStan\Type\ObjectType('Doctrine\\ORM\\EntityManagerInterface')), new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('Doctrine\\ORM\\Tools\\DebugUnitOfWorkListener', 'dumpIdentityMap', 0, new \PHPStan\Type\ObjectType('Doctrine\\ORM\\EntityManagerInterface'))]);
$services->set(\Rector\Removing\Rector\ClassMethod\ArgumentRemoverRector::class)->configure([new \Rector\Removing\ValueObject\ArgumentRemover('Doctrine\\ORM\\Persisters\\Entity\\AbstractEntityInheritancePersister', 'getSelectJoinColumnSQL', 4, null)]);
};

View File

@ -3,14 +3,15 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\Core\Configuration\Option;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$containerConfigurator->import(__DIR__ . '/config/config.php');
$parameters = $containerConfigurator->parameters();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->import(__DIR__ . '/config/config.php');
$parameters = $rectorConfig->parameters();
$parameters->set(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES, \true);
$parameters->set(\Rector\Core\Configuration\Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests']);
$parameters->set(\Rector\Core\Configuration\Option::PARALLEL, \true);
@ -19,9 +20,10 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
'*/Source/*',
'*/Fixture/*',
]);
$containerConfigurator->import(\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81);
$containerConfigurator->import(\Rector\Set\ValueObject\SetList::DEAD_CODE);
$containerConfigurator->import(\Rector\Set\ValueObject\SetList::CODE_QUALITY);
$services = $containerConfigurator->services();
$rectorConfig->import(\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81);
$rectorConfig->import(\Rector\Set\ValueObject\SetList::DEAD_CODE);
$rectorConfig->import(\Rector\Set\ValueObject\SetList::CODE_QUALITY);
$rectorConfig->import(\Rector\Set\ValueObject\SetList::NAMING);
$services = $rectorConfig->services();
$services->set(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class)->configure(['Doctrine\\*', 'Gedmo\\*', 'Knp\\*', 'DateTime', 'DateTimeInterface']);
};

View File

@ -13,12 +13,12 @@ final class DoctrineItemDefaultValueManipulator
/**
* @param bool|int|string $defaultValue
*/
public function remove(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineTagValueNode, string $item, $defaultValue) : void
public function remove(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, string $item, $defaultValue) : void
{
if (!$this->hasItemWithDefaultValue($doctrineTagValueNode, $item, $defaultValue)) {
if (!$this->hasItemWithDefaultValue($doctrineAnnotationTagValueNode, $item, $defaultValue)) {
return;
}
$doctrineTagValueNode->removeValue($item);
$doctrineAnnotationTagValueNode->removeValue($item);
$phpDocInfo->markAsChanged();
}
/**

View File

@ -101,12 +101,12 @@ final class IssetDimFetchCleaner
}
}
}
private function isArrayDimFetchOnVariable(\PhpParser\Node\Expr $var, \PhpParser\Node\Expr\Variable $desiredVariable) : bool
private function isArrayDimFetchOnVariable(\PhpParser\Node\Expr $expr, \PhpParser\Node\Expr\Variable $desiredVariable) : bool
{
if (!$var instanceof \PhpParser\Node\Expr\ArrayDimFetch) {
if (!$expr instanceof \PhpParser\Node\Expr\ArrayDimFetch) {
return \false;
}
return $this->nodeComparator->areNodesEqual($desiredVariable, $var->var);
return $this->nodeComparator->areNodesEqual($desiredVariable, $expr->var);
}
/**
* @return mixed|mixed[]|string|null

View File

@ -53,9 +53,9 @@ final class ToManyRelationPropertyTypeResolver
public function resolve(\PhpParser\Node\Stmt\Property $property) : ?\PHPStan\Type\Type
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
$toManyRelationTagValueNode = $phpDocInfo->getByAnnotationClasses(self::TO_MANY_ANNOTATION_CLASSES);
if ($toManyRelationTagValueNode !== null) {
return $this->processToManyRelation($property, $toManyRelationTagValueNode);
$doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClasses(self::TO_MANY_ANNOTATION_CLASSES);
if ($doctrineAnnotationTagValueNode !== null) {
return $this->processToManyRelation($property, $doctrineAnnotationTagValueNode);
}
$targetEntity = $this->attributeFinder->findAttributeByClassesArgByName($property, self::TO_MANY_ANNOTATION_CLASSES, 'targetEntity');
if (!$targetEntity instanceof \PhpParser\Node\Expr) {
@ -86,7 +86,7 @@ final class ToManyRelationPropertyTypeResolver
return new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType(self::COLLECTION_TYPE);
}
$entityFullyQualifiedClass = $this->shortClassExpander->resolveFqnTargetEntity($targetEntity, $property);
$relatedEntityType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($entityFullyQualifiedClass);
return new \PHPStan\Type\Generic\GenericObjectType(self::COLLECTION_TYPE, [$relatedEntityType]);
$fullyQualifiedObjectType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($entityFullyQualifiedClass);
return new \PHPStan\Type\Generic\GenericObjectType(self::COLLECTION_TYPE, [$fullyQualifiedObjectType]);
}
}

View File

@ -61,9 +61,9 @@ final class ToOneRelationPropertyTypeResolver
public function resolve(\PhpParser\Node\Stmt\Property $property) : ?\PHPStan\Type\Type
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($property);
$toOneRelationTagValueNode = $phpDocInfo->getByAnnotationClasses(self::TO_ONE_ANNOTATION_CLASSES);
if ($toOneRelationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
return $this->resolveFromDocBlock($phpDocInfo, $property, $toOneRelationTagValueNode);
$doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClasses(self::TO_ONE_ANNOTATION_CLASSES);
if ($doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
return $this->resolveFromDocBlock($phpDocInfo, $property, $doctrineAnnotationTagValueNode);
}
$targetEntity = $this->attributeFinder->findAttributeByClassesArgByName($property, self::TO_ONE_ANNOTATION_CLASSES, 'targetEntity');
if (!$targetEntity instanceof \PhpParser\Node\Expr) {
@ -97,10 +97,10 @@ final class ToOneRelationPropertyTypeResolver
$isNullableValue = $doctrineAnnotationTagValueNode->getValue('nullable');
return $isNullableValue instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode;
}
private function resolveFromDocBlock(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\Property $property, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $toOneRelationTagValueNode) : \PHPStan\Type\Type
private function resolveFromDocBlock(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\Property $property, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode) : \PHPStan\Type\Type
{
$joinDoctrineAnnotationTagValueNode = $phpDocInfo->findOneByAnnotationClass('Doctrine\\ORM\\Mapping\\JoinColumn');
return $this->processToOneRelation($property, $toOneRelationTagValueNode, $joinDoctrineAnnotationTagValueNode);
return $this->processToOneRelation($property, $doctrineAnnotationTagValueNode, $joinDoctrineAnnotationTagValueNode);
}
private function resolveFromObjectType(\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType, bool $isNullable) : \PHPStan\Type\Type
{

View File

@ -174,11 +174,11 @@ CODE_SAMPLE
*/
private function replaceEntityRegistryVariableWithEntityManagerProperty(\PhpParser\Node\Stmt\Class_ $class) : void
{
$this->traverseNodesWithCallable($class->stmts, function (\PhpParser\Node $class) : ?PropertyFetch {
if (!$class instanceof \PhpParser\Node\Expr\Variable) {
$this->traverseNodesWithCallable($class->stmts, function (\PhpParser\Node $node) : ?PropertyFetch {
if (!$node instanceof \PhpParser\Node\Expr\Variable) {
return null;
}
if (!$this->isObjectType($class, new \PHPStan\Type\ObjectType('Doctrine\\Common\\Persistence\\ObjectManager'))) {
if (!$this->isObjectType($node, new \PHPStan\Type\ObjectType('Doctrine\\Common\\Persistence\\ObjectManager'))) {
return null;
}
return new \PhpParser\Node\Expr\PropertyFetch(new \PhpParser\Node\Expr\Variable('this'), self::ENTITY_MANAGER);

View File

@ -70,10 +70,10 @@ CODE_SAMPLE
private function refactorEntityAnnotation(\PhpParser\Node\Stmt\Class_ $class) : void
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class);
$doctrineTagValueNode = $phpDocInfo->getByAnnotationClass('Doctrine\\ORM\\Mapping\\Entity');
if (!$doctrineTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
$doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('Doctrine\\ORM\\Mapping\\Entity');
if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
return;
}
$this->doctrineItemDefaultValueManipulator->remove($phpDocInfo, $doctrineTagValueNode, 'readOnly', \false);
$this->doctrineItemDefaultValueManipulator->remove($phpDocInfo, $doctrineAnnotationTagValueNode, 'readOnly', \false);
}
}

View File

@ -176,9 +176,9 @@ CODE_SAMPLE
}
private function dumpEntityTranslation(\PhpParser\Node\Stmt\Class_ $class, \Rector\Doctrine\ValueObject\PropertyNamesAndPhpDocInfos $propertyNamesAndPhpDocInfos) : void
{
$fileInfo = $this->file->getSmartFileInfo();
$smartFileInfo = $this->file->getSmartFileInfo();
$classShortName = $class->name . 'Translation';
$filePath = \dirname($fileInfo->getRealPath()) . \DIRECTORY_SEPARATOR . $classShortName . '.php';
$filePath = \dirname($smartFileInfo->getRealPath()) . \DIRECTORY_SEPARATOR . $classShortName . '.php';
$namespace = $class->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
if (!$namespace instanceof \PhpParser\Node\Stmt\Namespace_) {
throw new \Rector\Core\Exception\ShouldNotHappenException();

View File

@ -222,19 +222,19 @@ CODE_SAMPLE
}
return $property;
}
private function refactorAttribute(\PhpParser\Node\Expr $targetEntity, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\Property $property) : ?\PhpParser\Node\Stmt\Property
private function refactorAttribute(\PhpParser\Node\Expr $expr, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PhpParser\Node\Stmt\Property $property) : ?\PhpParser\Node\Stmt\Property
{
$phpDocVarTagValueNode = $phpDocInfo->getVarTagValueNode();
$phpDocCollectionVarTagValueNode = $this->collectionVarTagValueNodeResolver->resolve($property);
if ($phpDocVarTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode && !$phpDocCollectionVarTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) {
return null;
}
$targetEntityClassName = $this->targetEntityResolver->resolveFromExpr($targetEntity);
$targetEntityClassName = $this->targetEntityResolver->resolveFromExpr($expr);
if ($targetEntityClassName === null) {
return null;
}
$collectionObjectType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($targetEntityClassName);
$newVarType = $this->collectionTypeFactory->createType($collectionObjectType);
$fullyQualifiedObjectType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($targetEntityClassName);
$newVarType = $this->collectionTypeFactory->createType($fullyQualifiedObjectType);
$this->phpDocTypeChanger->changeVarType($phpDocInfo, $newVarType);
return $property;
}

View File

@ -13,9 +13,9 @@ final class CollectionTypeFactory
{
public function createType(\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : \PHPStan\Type\UnionType
{
$genericType = $this->createGenericObjectType($fullyQualifiedObjectType);
$genericObjectType = $this->createGenericObjectType($fullyQualifiedObjectType);
$arrayType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), $fullyQualifiedObjectType);
return new \PHPStan\Type\UnionType([$genericType, $arrayType]);
return new \PHPStan\Type\UnionType([$genericObjectType, $arrayType]);
}
private function createGenericObjectType(\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : \PHPStan\Type\Generic\GenericObjectType
{

View File

@ -15,11 +15,11 @@ final class PropertyNameAndPhpDocInfo
* @readonly
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
*/
private $phpDocInfos;
public function __construct(string $propertyName, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfos)
private $phpDocInfo;
public function __construct(string $propertyName, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo)
{
$this->propertyName = $propertyName;
$this->phpDocInfos = $phpDocInfos;
$this->phpDocInfo = $phpDocInfo;
}
public function getPropertyName() : string
{
@ -27,6 +27,6 @@ final class PropertyNameAndPhpDocInfo
}
public function getPhpDocInfo() : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
{
return $this->phpDocInfos;
return $this->phpDocInfo;
}
}

View File

@ -3,9 +3,9 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
use Rector\Config\RectorConfig;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->defaults()->public()->autowire()->autoconfigure();
$services->load('Rector\\PHPUnit\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/{Rector,ValueObject,PhpDoc/Node}']);
};

View File

@ -3,10 +3,10 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$containerConfigurator->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_91);
$containerConfigurator->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_90);
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_91);
$rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_90);
};

View File

@ -3,8 +3,8 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$containerConfigurator->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_50);
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_50);
};

View File

@ -3,10 +3,10 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$containerConfigurator->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_60);
$containerConfigurator->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_50);
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_60);
$rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_50);
};

View File

@ -3,10 +3,10 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$containerConfigurator->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_70);
$containerConfigurator->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_60);
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_70);
$rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_60);
};

View File

@ -3,10 +3,10 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$containerConfigurator->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_80);
$containerConfigurator->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_70);
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_80);
$rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_70);
};

View File

@ -3,10 +3,10 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$containerConfigurator->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_90);
$containerConfigurator->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_80);
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_90);
$rectorConfig->import(\Rector\PHPUnit\Set\PHPUnitLevelSetList::UP_TO_PHPUNIT_80);
};

View File

@ -5,6 +5,7 @@ namespace RectorPrefix20220412;
use Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector;
use Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector;
use Rector\PHPUnit\Rector\Class_\ConstructClassMethodToSetUpTestCaseRector;
use Rector\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector;
@ -12,9 +13,8 @@ use Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector;
use Rector\PHPUnit\Rector\MethodCall\AssertEqualsToSameRector;
use Rector\PHPUnit\Rector\MethodCall\AssertSameTrueFalseToAssertTrueFalseRector;
use Rector\PHPUnit\Rector\MethodCall\RemoveExpectAnyFromMockRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\PHPUnit\Rector\MethodCall\RemoveExpectAnyFromMockRector::class);
$services->set(\Rector\PHPUnit\Rector\Class_\AddSeeTestAnnotationRector::class);
$services->set(\Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector::class)->configure([new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield('PHPUnit\\Framework\\TestCase', 'provide*'), new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield('PHPUnit\\Framework\\TestCase', 'dataProvider*')]);

View File

@ -3,13 +3,13 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector;
use Rector\PHPUnit\Rector\MethodCall\DelegateExceptionArgumentsRector;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
# handles 2nd and 3rd argument of setExpectedException
$services->set(\Rector\PHPUnit\Rector\MethodCall\DelegateExceptionArgumentsRector::class);
$services->set(\Rector\PHPUnit\Rector\ClassMethod\ExceptionAnnotationRector::class);

View File

@ -3,9 +3,9 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Rector\MethodCall\UseSpecificWillMethodRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\PHPUnit\Rector\MethodCall\UseSpecificWillMethodRector::class);
};

View File

@ -3,6 +3,7 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Rector\Foreach_\SimplifyForeachInstanceOfRector;
use Rector\PHPUnit\Rector\MethodCall\AssertCompareToSpecificMethodRector;
use Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector;
@ -15,9 +16,8 @@ use Rector\PHPUnit\Rector\MethodCall\AssertRegExpRector;
use Rector\PHPUnit\Rector\MethodCall\AssertSameBoolNullToSpecificMethodRector;
use Rector\PHPUnit\Rector\MethodCall\AssertTrueFalseInternalTypeToSpecificMethodRector;
use Rector\PHPUnit\Rector\MethodCall\AssertTrueFalseToSpecificMethodRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\PHPUnit\Rector\MethodCall\AssertNotOperatorRector::class);
$services->set(\Rector\PHPUnit\Rector\MethodCall\AssertComparisonToSpecificMethodRector::class);
$services->set(\Rector\PHPUnit\Rector\MethodCall\AssertTrueFalseToSpecificMethodRector::class);

View File

@ -5,8 +5,8 @@ namespace RectorPrefix20220412;
use Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector;
use Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
use Rector\Config\RectorConfig;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\CodingStyle\Rector\ClassMethod\ReturnArrayClassMethodToYieldRector::class)->configure([new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield('PHPUnit\\Framework\\TestCase', 'provide*'), new \Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield('PHPUnit\\Framework\\TestCase', 'dataProvider*')]);
};

View File

@ -3,11 +3,11 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->configure([new \Rector\Renaming\ValueObject\MethodCallRename(
'PHPUnit_Framework_MockObject_MockObject',
# see https://github.com/sebastianbergmann/phpunit-mock-objects/issues/137

View File

@ -3,9 +3,9 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Rector\StaticCall\GetMockRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\PHPUnit\Rector\StaticCall\GetMockRector::class);
};

View File

@ -3,6 +3,7 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector;
use Rector\PHPUnit\Rector\MethodCall\GetMockBuilderGetMockToCreateMockRector;
use Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector;
@ -10,10 +11,9 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Rector\Renaming\ValueObject\PseudoNamespaceToNamespace;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$containerConfigurator->import(__DIR__ . '/phpunit-exception.php');
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->import(__DIR__ . '/phpunit-exception.php');
$services = $rectorConfig->services();
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->configure([new \Rector\Renaming\ValueObject\MethodCallRename('PHPUnit\\Framework\\TestCase', 'createMockBuilder', 'getMockBuilder')]);
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->configure(['PHPUnit_Framework_MockObject_Stub' => 'PHPUnit\\Framework\\MockObject\\Stub', 'PHPUnit_Framework_MockObject_Stub_Return' => 'PHPUnit\\Framework\\MockObject\\Stub\\ReturnStub', 'PHPUnit_Framework_MockObject_Matcher_Parameters' => 'PHPUnit\\Framework\\MockObject\\Matcher\\Parameters', 'PHPUnit_Framework_MockObject_Matcher_Invocation' => 'PHPUnit\\Framework\\MockObject\\Matcher\\Invocation', 'PHPUnit_Framework_MockObject_MockObject' => 'PHPUnit\\Framework\\MockObject\\MockObject', 'PHPUnit_Framework_MockObject_Invocation_Object' => 'PHPUnit\\Framework\\MockObject\\Invocation\\ObjectInvocation']);
$services->set(\Rector\Renaming\Rector\FileWithoutNamespace\PseudoNamespaceToNamespaceRector::class)->configure([

View File

@ -3,13 +3,13 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Rector\Class_\RemoveDataProviderTestPrefixRector;
use Rector\Renaming\Rector\ClassMethod\RenameAnnotationRector;
use Rector\Renaming\ValueObject\RenameAnnotationByType;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$containerConfigurator->import(__DIR__ . '/phpunit-exception.php');
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->import(__DIR__ . '/phpunit-exception.php');
$services = $rectorConfig->services();
$services->set(\Rector\Renaming\Rector\ClassMethod\RenameAnnotationRector::class)->configure([new \Rector\Renaming\ValueObject\RenameAnnotationByType('PHPUnit\\Framework\\TestCase', 'scenario', 'test')]);
$services->set(\Rector\PHPUnit\Rector\Class_\RemoveDataProviderTestPrefixRector::class);
};

View File

@ -3,9 +3,9 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Rector\MethodCall\WithConsecutiveArgToArrayRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\PHPUnit\Rector\MethodCall\WithConsecutiveArgToArrayRector::class);
};

View File

@ -3,9 +3,9 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Rector\MethodCall\ReplaceAssertArraySubsetWithDmsPolyfillRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\PHPUnit\Rector\MethodCall\ReplaceAssertArraySubsetWithDmsPolyfillRector::class);
};

View File

@ -5,6 +5,7 @@ namespace RectorPrefix20220412;
use PHPStan\Type\MixedType;
use PHPStan\Type\VoidType;
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\MethodName;
use Rector\PHPUnit\Rector\MethodCall\AssertEqualsParameterToSpecificMethodsTypeRector;
use Rector\PHPUnit\Rector\MethodCall\SpecificAssertContainsRector;
@ -14,10 +15,9 @@ use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$containerConfigurator->import(__DIR__ . '/phpunit-exception.php');
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->import(__DIR__ . '/phpunit-exception.php');
$services = $rectorConfig->services();
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class)->configure([
// https://github.com/rectorphp/rector/issues/1024 - no type, $dataName
new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('PHPUnit\\Framework\\TestCase', \Rector\Core\ValueObject\MethodName::CONSTRUCT, 2, new \PHPStan\Type\MixedType()),

View File

@ -3,14 +3,14 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Rector\Class_\TestListenerToHooksRector;
use Rector\PHPUnit\Rector\MethodCall\ExplicitPhpErrorApiRector;
use Rector\PHPUnit\Rector\MethodCall\SpecificAssertContainsWithoutIdentityRector;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\PHPUnit\Rector\Class_\TestListenerToHooksRector::class);
$services->set(\Rector\PHPUnit\Rector\MethodCall\ExplicitPhpErrorApiRector::class);
$services->set(\Rector\PHPUnit\Rector\MethodCall\SpecificAssertContainsWithoutIdentityRector::class);

View File

@ -3,12 +3,12 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Rector\Class_\AddProphecyTraitRector;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$services = $containerConfigurator->services();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$services = $rectorConfig->services();
$services->set(\Rector\PHPUnit\Rector\Class_\AddProphecyTraitRector::class);
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->configure([
// https://github.com/sebastianbergmann/phpunit/issues/4087

View File

@ -3,13 +3,13 @@
declare (strict_types=1);
namespace RectorPrefix20220412;
use Rector\Config\RectorConfig;
use Rector\Core\Configuration\Option;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$parameters = $containerConfigurator->parameters();
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$parameters = $rectorConfig->parameters();
$parameters->set(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES, \true);
$parameters->set(\Rector\Core\Configuration\Option::PARALLEL, \true);
$parameters->set(\Rector\Core\Configuration\Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests']);
@ -18,18 +18,20 @@ return static function (\Symfony\Component\DependencyInjection\Loader\Configurat
'*/Source/*',
'*/Fixture/*',
// object types
\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class => [__DIR__ . '/src/Rector/MethodCall/WithConsecutiveArgToArrayRector.php', __DIR__ . '/src/Rector/MethodCall/UseSpecificWillMethodRector.php', __DIR__ . '/src/Rector/Class_/TestListenerToHooksRector.php', __DIR__ . '/src/NodeFactory/ConsecutiveAssertionFactory.php', __DIR__ . '/src/NodeAnalyzer/TestsNodeAnalyzer.php', __DIR__ . '/src/NodeFactory/DataProviderClassMethodFactory.php'],
\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class => [__DIR__ . '/src/Rector/MethodCall/WithConsecutiveArgToArrayRector.php', __DIR__ . '/src/Rector/MethodCall/UseSpecificWillMethodRector.php', __DIR__ . '/src/Rector/Class_/TestListenerToHooksRector.php', __DIR__ . '/src/NodeFactory/ConsecutiveAssertionFactory.php', __DIR__ . '/src/NodeAnalyzer/TestsNodeAnalyzer.php', __DIR__ . '/src/NodeFactory/DataProviderClassMethodFactory.php', __DIR__ . '/config'],
]);
// needed for DEAD_CODE list, just in split package like this
$containerConfigurator->import(__DIR__ . '/config/config.php');
$containerConfigurator->import(\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81);
$containerConfigurator->import(\Rector\Set\ValueObject\SetList::DEAD_CODE);
$containerConfigurator->import(\Rector\Set\ValueObject\SetList::CODE_QUALITY);
$containerConfigurator->import(\Rector\Set\ValueObject\SetList::CODING_STYLE);
$containerConfigurator->import(\Rector\Set\ValueObject\SetList::EARLY_RETURN);
$services = $containerConfigurator->services();
$rectorConfig->import(__DIR__ . '/config/config.php');
$rectorConfig->import(\Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81);
$rectorConfig->import(\Rector\Set\ValueObject\SetList::DEAD_CODE);
$rectorConfig->import(\Rector\Set\ValueObject\SetList::CODE_QUALITY);
$rectorConfig->import(\Rector\Set\ValueObject\SetList::CODING_STYLE);
$rectorConfig->import(\Rector\Set\ValueObject\SetList::EARLY_RETURN);
$rectorConfig->import(\Rector\Set\ValueObject\SetList::NAMING);
$services = $rectorConfig->services();
$services->set(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class)->configure([
// keep unprefixed to protected from downgrade
'PHPUnit\\Framework\\Assert',
'PHPUnit\\Framework\\MockObject\\*',
'PHPUnit\\Framework\\TestCase',
'Prophecy\\Prophet',

View File

@ -36,8 +36,8 @@ final class ExpectExceptionMethodCallFactory
public function createFromTagValueNodes(array $phpDocTagNodes, string $methodName) : array
{
$methodCallExpressions = [];
foreach ($phpDocTagNodes as $genericTagValueNode) {
$methodCall = $this->createMethodCall($genericTagValueNode, $methodName);
foreach ($phpDocTagNodes as $phpDocTagNode) {
$methodCall = $this->createMethodCall($phpDocTagNode, $methodName);
$methodCallExpressions[] = new \PhpParser\Node\Stmt\Expression($methodCall);
}
return $methodCallExpressions;

View File

@ -102,8 +102,8 @@ CODE_SAMPLE
if ($this->hasAlreadySeeAnnotation($phpDocInfo, $matchingTestClassName)) {
return null;
}
$newSeeTagNode = $this->createSeePhpDocTagNode($matchingTestClassName);
$phpDocInfo->addPhpDocTagNode($newSeeTagNode);
$phpDocTagNode = $this->createSeePhpDocTagNode($matchingTestClassName);
$phpDocInfo->addPhpDocTagNode($phpDocTagNode);
return $node;
}
private function shouldSkipClass(\PhpParser\Node\Stmt\Class_ $class) : bool
@ -180,11 +180,11 @@ CODE_SAMPLE
*/
private function matchExistingClassName(array $classNames) : ?string
{
foreach ($classNames as $possibleTestClassName) {
if (!$this->reflectionProvider->hasClass($possibleTestClassName)) {
foreach ($classNames as $className) {
if (!$this->reflectionProvider->hasClass($className)) {
continue;
}
return $possibleTestClassName;
return $className;
}
return null;
}

View File

@ -128,8 +128,8 @@ CODE_SAMPLE
if (!$node instanceof \PhpParser\Node\Expr\MethodCall) {
return null;
}
foreach ($this->arrayArgumentsToDataProviders as $arrayArgumentsToDataProvider) {
$this->refactorMethodCallWithConfiguration($node, $arrayArgumentsToDataProvider);
foreach ($this->arrayArgumentsToDataProviders as $arrayArgumentToDataProvider) {
$this->refactorMethodCallWithConfiguration($node, $arrayArgumentToDataProvider);
}
return null;
});
@ -182,9 +182,9 @@ CODE_SAMPLE
}
$this->refactorTestClassMethodParams($classMethod, $paramAndArgs);
// add data provider annotation
$dataProviderTagNode = $this->createDataProviderTagNode($dataProviderMethodName);
$phpDocTagNode = $this->createDataProviderTagNode($dataProviderMethodName);
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod);
$phpDocInfo->addPhpDocTagNode($dataProviderTagNode);
$phpDocInfo->addPhpDocTagNode($phpDocTagNode);
$phpDocInfo->makeMultiLined();
}
/**

View File

@ -48,14 +48,14 @@ CODE_SAMPLE
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
/** @var MethodCall|StaticCall|null $matchedNode */
$matchedNode = $this->foreachManipulator->matchOnlyStmt($node, function (\PhpParser\Node $node, \PhpParser\Node\Stmt\Foreach_ $foreachNode) : ?Node {
$matchedNode = $this->foreachManipulator->matchOnlyStmt($node, function (\PhpParser\Node $node, \PhpParser\Node\Stmt\Foreach_ $foreach) : ?Node {
if (!$node instanceof \PhpParser\Node\Expr\MethodCall && !$node instanceof \PhpParser\Node\Expr\StaticCall) {
return null;
}
if (!$this->isName($node->name, 'assertInstanceOf')) {
return null;
}
if (!$this->nodeComparator->areNodesEqual($foreachNode->valueVar, $node->args[1]->value)) {
if (!$this->nodeComparator->areNodesEqual($foreach->valueVar, $node->args[1]->value)) {
return null;
}
return $node;

View File

@ -111,16 +111,16 @@ final class AssertIssetToSpecificMethodRector extends \Rector\Core\Rector\Abstra
// object not found, skip
return $resolved instanceof \PHPStan\Type\ObjectWithoutClassType;
}
$reflection = $resolved->getClassReflection();
if (!$reflection instanceof \PHPStan\Reflection\ClassReflection) {
$classReflection = $resolved->getClassReflection();
if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) {
return \false;
}
if ($reflection->hasMethod('__isset')) {
if ($classReflection->hasMethod('__isset')) {
return \true;
}
// reflection->getParents() got empty array when
// extends class not found by PHPStan
$className = $reflection->getName();
$className = $classReflection->getName();
$class = $this->astResolver->resolveClassFromName($className);
if (!$class instanceof \PhpParser\Node\Stmt\Class_) {
return \false;

View File

@ -196,8 +196,8 @@ CODE_SAMPLE
private function resolveNumberOfRequiredParameters(string $mockClass, string $mockMethod) : int
{
$classReflection = $this->reflectionProvider->getClass($mockClass);
$nativeClassReflection = $classReflection->getNativeReflection();
$reflectionMethod = $nativeClassReflection->getMethod($mockMethod);
$reflectionClass = $classReflection->getNativeReflection();
$reflectionMethod = $reflectionClass->getMethod($mockMethod);
return $reflectionMethod->getNumberOfParameters();
}
}

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20220412\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit13e807cd3be494fed4e52d5cff90940f', false) && !interface_exists('ComposerAutoloaderInit13e807cd3be494fed4e52d5cff90940f', false) && !trait_exists('ComposerAutoloaderInit13e807cd3be494fed4e52d5cff90940f', false)) {
spl_autoload_call('RectorPrefix20220412\ComposerAutoloaderInit13e807cd3be494fed4e52d5cff90940f');
if (!class_exists('ComposerAutoloaderInit78c49bb15bb72f975752ce11f96a623b', false) && !interface_exists('ComposerAutoloaderInit78c49bb15bb72f975752ce11f96a623b', false) && !trait_exists('ComposerAutoloaderInit78c49bb15bb72f975752ce11f96a623b', false)) {
spl_autoload_call('RectorPrefix20220412\ComposerAutoloaderInit78c49bb15bb72f975752ce11f96a623b');
}
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('RectorPrefix20220412\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -59,9 +59,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20220412\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire13e807cd3be494fed4e52d5cff90940f')) {
function composerRequire13e807cd3be494fed4e52d5cff90940f() {
return \RectorPrefix20220412\composerRequire13e807cd3be494fed4e52d5cff90940f(...func_get_args());
if (!function_exists('composerRequire78c49bb15bb72f975752ce11f96a623b')) {
function composerRequire78c49bb15bb72f975752ce11f96a623b() {
return \RectorPrefix20220412\composerRequire78c49bb15bb72f975752ce11f96a623b(...func_get_args());
}
}
if (!function_exists('scanPath')) {