Updated Rector to commit 8537bbd52a5b9d8aa619326b750df6dcb1b30f32

8537bbd52a [DeadCode] Skip append += assignment on RemoveUnusedPrivatePropertyRector (#4506)
This commit is contained in:
Tomas Votruba 2023-07-13 16:05:50 +00:00
parent 4da4f21668
commit 6f18436957
125 changed files with 16 additions and 3615 deletions

2
vendor/autoload.php vendored
View File

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

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit507b4ac236cd2f9f74226dd15857168d
class ComposerAutoloaderInita0fc3bee25f0e3ca207bc6ec0fa01e46
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit507b4ac236cd2f9f74226dd15857168d
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit507b4ac236cd2f9f74226dd15857168d', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInita0fc3bee25f0e3ca207bc6ec0fa01e46', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit507b4ac236cd2f9f74226dd15857168d', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInita0fc3bee25f0e3ca207bc6ec0fa01e46', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit507b4ac236cd2f9f74226dd15857168d::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInita0fc3bee25f0e3ca207bc6ec0fa01e46::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit507b4ac236cd2f9f74226dd15857168d::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInita0fc3bee25f0e3ca207bc6ec0fa01e46::$files;
$requireFile = \Closure::bind(static function ($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 ComposerStaticInit507b4ac236cd2f9f74226dd15857168d
class ComposerStaticInita0fc3bee25f0e3ca207bc6ec0fa01e46
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3037,9 +3037,9 @@ class ComposerStaticInit507b4ac236cd2f9f74226dd15857168d
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit507b4ac236cd2f9f74226dd15857168d::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit507b4ac236cd2f9f74226dd15857168d::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit507b4ac236cd2f9f74226dd15857168d::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInita0fc3bee25f0e3ca207bc6ec0fa01e46::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInita0fc3bee25f0e3ca207bc6ec0fa01e46::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInita0fc3bee25f0e3ca207bc6ec0fa01e46::$classMap;
}, null, ClassLoader::class);
}

View File

@ -1917,12 +1917,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "6b6c7d68e76172593c0f2f523cecfe4fbf099531"
"reference": "6af6be50bb83c3608e2a9472fb8b0b50d55bb4ff"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/6b6c7d68e76172593c0f2f523cecfe4fbf099531",
"reference": "6b6c7d68e76172593c0f2f523cecfe4fbf099531",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/6af6be50bb83c3608e2a9472fb8b0b50d55bb4ff",
"reference": "6af6be50bb83c3608e2a9472fb8b0b50d55bb4ff",
"shasum": ""
},
"require": {
@ -1947,7 +1947,7 @@
"tomasvotruba\/type-coverage": "^0.2",
"tomasvotruba\/unused-public": "^0.1"
},
"time": "2023-07-13T14:24:28+00:00",
"time": "2023-07-13T16:00:12+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-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 6b6c7d6'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 734960f'), '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 59b84b7'), '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 e788554'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 6af6be5'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 734960f'), '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 59b84b7'), '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 e788554'));
private function __construct()
{
}

View File

@ -1,23 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\Fixture;
use Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\Fixture\DefaultEntity;
/**
* @ORM\Entity()
*/
class ManyToOneDefault
{
/**
* @ORM\ManyToOne(targetEntity="DefaultEntity")
*/
private $defaultEntity;
public function setDefaultEntity(DefaultEntity $defaultEntity)
{
$this->defaultEntity = $defaultEntity;
}
}
?>

View File

@ -1,23 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\Fixture;
use Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\Fixture\DefaultEntity;
/**
* @ORM\Entity()
*/
class ManyToOneDefaultSetterNullable
{
/**
* @ORM\ManyToOne(targetEntity="DefaultEntity")
*/
private $defaultEntity;
public function setDefaultEntity(?DefaultEntity $defaultEntity)
{
$this->defaultEntity = $defaultEntity;
}
}
?>

View File

@ -1,47 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\Fixture;
use Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\Fixture\NotNullableEntity;
/**
* @ORM\Entity()
*/
class ManyToOneNotNullable
{
/**
* @ORM\ManyToOne(targetEntity="NotNullableEntity")
* @ORM\JoinColumn(nullable=false)
*/
private $notNullableEntity;
public function setNotNullableEntity(?NotNullableEntity $notNullableEntity)
{
$this->notNullableEntity = $notNullableEntity;
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\Fixture;
/**
* @ORM\Entity()
*/
class ManyToOneNotNullable
{
/**
* @ORM\ManyToOne(targetEntity="NotNullableEntity")
* @ORM\JoinColumn(nullable=false)
*/
private $notNullableEntity;
public function setNotNullableEntity(NotNullableEntity $notNullableEntity)
{
$this->notNullableEntity = $notNullableEntity;
}
}
?>

View File

@ -1,24 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\Fixture;
use Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\Fixture\NotNullableEntity;
/**
* @ORM\Entity()
*/
class ManyToOneNotNullableSetterNotNullable
{
/**
* @ORM\ManyToOne(targetEntity="NotNullableEntity")
* @ORM\JoinColumn(nullable=false)
*/
private $notNullableEntity;
public function setNotNullableEntity(NotNullableEntity $notNullableEntity)
{
$this->notNullableEntity = $notNullableEntity;
}
}
?>

View File

@ -1,24 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\Fixture;
use Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\Fixture\NullableEntity;
/**
* @ORM\Entity()
*/
class ManyToOneNullable
{
/**
* @ORM\ManyToOne(targetEntity="NullableEntity")
* @ORM\JoinColumn(nullable=true)
*/
private $nullableEntity;
public function setNullableEntity(NullableEntity $nullableEntity)
{
$this->nullableEntity = $nullableEntity;
}
}
?>

View File

@ -1,24 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\Fixture;
use Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector\Fixture\NullableEntity;
/**
* @ORM\Entity()
*/
class ManyToOneNullableSetterNotNullable
{
/**
* @ORM\ManyToOne(targetEntity="NullableEntity")
* @ORM\JoinColumn(nullable=true)
*/
private $nullableEntity;
public function setNullableEntity(?NullableEntity $nullableEntity)
{
$this->nullableEntity = $nullableEntity;
}
}
?>

View File

@ -1,23 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Tests\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector;
use Iterator;
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class MakeEntitySetterNullabilityInSyncWithPropertyRectorTest extends AbstractRectorTestCase
{
public function test(string $filePath) : void
{
$this->doTestFile($filePath);
}
public static function provideData() : Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
public function provideConfigFilePath() : string
{
return __DIR__ . '/config/configured_rule.php';
}
}

View File

@ -1,12 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202307;
use Rector\Config\RectorConfig;
use Rector\Doctrine\CodeQuality\Rector\ClassMethod\MakeEntitySetterNullabilityInSyncWithPropertyRector;
use Rector\Doctrine\Tests\ConfigList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->import(ConfigList::MAIN);
$rectorConfig->rule(MakeEntitySetterNullabilityInSyncWithPropertyRector::class);
};

View File

@ -1,23 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector;
use Iterator;
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class AutoImportTest extends AbstractRectorTestCase
{
public function test(string $filePath) : void
{
$this->doTestFile($filePath);
}
public static function provideData() : Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/FixtureAutoImport');
}
public function provideConfigFilePath() : string
{
return __DIR__ . '/config/auto_import.php';
}
}

View File

@ -1,33 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class SomeClass
{
#[ORM\OneToMany(targetEntity: "MarketingEvent")]
private $marketingEvents = [];
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class SomeClass
{
#[ORM\OneToMany(targetEntity: "MarketingEvent")]
private $marketingEvents = [];
public function __construct()
{
$this->marketingEvents = new \Doctrine\Common\Collections\ArrayCollection();
}
}
?>

View File

@ -1,44 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector\Fixture;
/**
* @ORM\Entity
*/
class ExistingConstructor
{
/**
* @ORM\OneToMany(targetEntity="MarketingEvent")
*/
private $marketingEvents = [];
public function __construct()
{
$value = 5;
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector\Fixture;
/**
* @ORM\Entity
*/
class ExistingConstructor
{
/**
* @ORM\OneToMany(targetEntity="MarketingEvent")
*/
private $marketingEvents = [];
public function __construct()
{
$this->marketingEvents = new \Doctrine\Common\Collections\ArrayCollection();
$value = 5;
}
}
?>

View File

@ -1,37 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector\Fixture;
/**
* @ORM\Entity
*/
class SomeClass
{
/**
* @ORM\OneToMany(targetEntity="MarketingEvent")
*/
private $marketingEvents = [];
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector\Fixture;
/**
* @ORM\Entity
*/
class SomeClass
{
/**
* @ORM\OneToMany(targetEntity="MarketingEvent")
*/
private $marketingEvents = [];
public function __construct()
{
$this->marketingEvents = new \Doctrine\Common\Collections\ArrayCollection();
}
}
?>

View File

@ -1,22 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector\Fixture;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
*/
class SkipAdded
{
/**
* @ORM\OneToMany(targetEntity="MarketingEvent")
*/
private $marketingEvents = [];
public function __construct()
{
$this->marketingEvents = new ArrayCollection();
$value = 5;
}
}

View File

@ -1,22 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector\Fixture;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
*/
class SkipAddedValues
{
/**
* @ORM\OneToMany(targetEntity="MarketingEvent")
*/
private $marketingEvents = [];
public function __construct(array $marketingEvents)
{
$this->marketingEvents = new ArrayCollection([$marketingEvents]);
$value = 5;
}
}

View File

@ -1,89 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector\FixtureAutoImport;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Rector\Doctrine\Tests\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector\FixtureAutoImport\Category;
/**
* @ORM\Table(name="articles")
* @ORM\Entity(repositoryClass="Domain\Repository\ArticleRepository")
*/
class DoNotrepetitiveAssign
{
/**
* @var string|null
*
* @ORM\Column(name="id", type="guid")
* @ORM\Id
* @ORM\GeneratedValue(strategy="UUID")
*/
protected $id;
/**
* @ORM\Column(name="created_at", type="datetime", nullable=true)
*/
protected ?\DateTimeInterface $createdAt;
/**
* @var Collection|Category[]
*
* @ORM\ManyToMany(targetEntity="Category", cascade={"persist", "merge"})
* @ORM\JoinTable(name="articles_categories")
*/
private Collection $categories;
public function __construct()
{
$this->categories = new ArrayCollection();
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector\FixtureAutoImport;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* @ORM\Table(name="articles")
* @ORM\Entity(repositoryClass="Domain\Repository\ArticleRepository")
*/
class DoNotrepetitiveAssign
{
/**
* @var string|null
*
* @ORM\Column(name="id", type="guid")
* @ORM\Id
* @ORM\GeneratedValue(strategy="UUID")
*/
protected $id;
/**
* @ORM\Column(name="created_at", type="datetime", nullable=true)
*/
protected ?DateTimeInterface $createdAt;
/**
* @var Collection|Category[]
*
* @ORM\ManyToMany(targetEntity="Category", cascade={"persist", "merge"})
* @ORM\JoinTable(name="articles_categories")
*/
private Collection $categories;
public function __construct()
{
$this->categories = new ArrayCollection();
}
}
?>

View File

@ -1,23 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector;
use Iterator;
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class InitializeDefaultEntityCollectionRectorTest extends AbstractRectorTestCase
{
public function test(string $filePath) : void
{
$this->doTestFile($filePath);
}
public static function provideData() : Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
public function provideConfigFilePath() : string
{
return __DIR__ . '/config/configured_rule.php';
}
}

View File

@ -1,13 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202307;
use Rector\Config\RectorConfig;
use Rector\Doctrine\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector;
use Rector\Doctrine\Tests\ConfigList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->import(ConfigList::MAIN);
$rectorConfig->importNames();
$rectorConfig->rule(InitializeDefaultEntityCollectionRector::class);
};

View File

@ -1,12 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202307;
use Rector\Config\RectorConfig;
use Rector\Doctrine\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector;
use Rector\Doctrine\Tests\ConfigList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->import(ConfigList::MAIN);
$rectorConfig->rule(InitializeDefaultEntityCollectionRector::class);
};

View File

@ -1,52 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector\Fixture;
use DateTimeInterface;
/**
* @ORM\Entity()
*/
class AlreadyConstructor
{
/**
* @var DateTimeInterface
*
* @ORM\Column(type="datetime", nullable=false, options={"default"="now()"})
*/
private $when = 'now()';
public function __construct()
{
$value = 10;
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector\Fixture;
use DateTimeInterface;
/**
* @ORM\Entity()
*/
class AlreadyConstructor
{
/**
* @var DateTimeInterface
*
* @ORM\Column(type="datetime", nullable=false)
*/
private $when;
public function __construct()
{
$value = 10;
$this->when = new \DateTime();
}
}
?>

View File

@ -1,45 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector\Fixture;
use DateTimeInterface;
/**
* @ORM\Entity()
*/
class User
{
/**
* @var DateTimeInterface
*
* @ORM\Column(type="datetime", nullable=false, options={"default"="now()"})
*/
private $when = 'now()';
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector\Fixture;
use DateTimeInterface;
/**
* @ORM\Entity()
*/
class User
{
/**
* @var DateTimeInterface
*
* @ORM\Column(type="datetime", nullable=false)
*/
private $when;
public function __construct()
{
$this->when = new \DateTime();
}
}
?>

View File

@ -1,37 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector\Fixture;
/**
* @ORM\Entity()
*/
class MoveFullDate
{
/**
* @ORM\Column(type="datetime", nullable=false, options={"default"="1900-01-01 00=00=00"})
*/
private $when = '1900-01-01 00:00:00';
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector\Fixture;
/**
* @ORM\Entity()
*/
class MoveFullDate
{
/**
* @ORM\Column(type="datetime", nullable=false)
*/
private $when;
public function __construct()
{
$this->when = new \DateTime('1900-01-01 00:00:00');
}
}
?>

View File

@ -1,23 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector\Fixture;
use DateTimeInterface;
/**
* @ORM\Entity()
*/
class SkipAlreadyDefaultConstructor
{
/**
* @var DateTimeInterface
*
* @ORM\Column(type="datetime", nullable=false, options={"default"="now()"})
*/
private $when = 'now()';
public function __construct()
{
$this->when = \Nette\Utils\DateTime::from('now');
}
}

View File

@ -1,29 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector\Fixture;
use DateTime;
/**
* @ORM\Table(name="signing_parties")
* @ORM\Entity(repositoryClass="MvSignature\Repository\SigningPartyRepository")
*/
class SkipNoConstructorDefaultNull
{
/**
* @ORM\Column(name="reminded_at", type="datetime", nullable=true)
*/
private ?DateTime $remindedAt = null;
public function getRemindedAt(): ?DateTime
{
return $this->remindedAt;
}
public function setRemindedAt(?DateTime $remindedAt): SkipNoConstructorDefaultNull
{
$this->remindedAt = $remindedAt;
return $this;
}
}

View File

@ -1,18 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector\Fixture;
use DateTimeInterface;
/**
* @ORM\Entity()
*/
class SkipNullDefaults
{
/**
* @var DateTimeInterface
*
* @ORM\Column(type="datetime", nullable=false)
*/
private $when;
}

View File

@ -1,17 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector\Fixture;
use DateTime;
final class SkipNullalbeProperty
{
/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected ?DateTime $date = null;
public function __construct()
{
}
}

View File

@ -1,23 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector;
use Iterator;
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class MoveCurrentDateTimeDefaultInEntityToConstructorRectorTest extends AbstractRectorTestCase
{
public function test(string $filePath) : void
{
$this->doTestFile($filePath);
}
public static function provideData() : Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
public function provideConfigFilePath() : string
{
return __DIR__ . '/config/configured_rule.php';
}
}

View File

@ -1,12 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202307;
use Rector\Config\RectorConfig;
use Rector\Doctrine\CodeQuality\Rector\Class_\MoveCurrentDateTimeDefaultInEntityToConstructorRector;
use Rector\Doctrine\Tests\ConfigList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->import(ConfigList::MAIN);
$rectorConfig->rule(MoveCurrentDateTimeDefaultInEntityToConstructorRector::class);
};

View File

@ -1,27 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\RemoveEmptyTableAttributeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table]
#[ORM\Table]
#[ORM\Entity]
class Product
{
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\AttributeGroup\RemoveEmptyTableAttributeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class Product
{
}
?>

View File

@ -1,26 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\RemoveEmptyTableAttributeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table]
#[ORM\Entity]
class Product
{
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\AttributeGroup\RemoveEmptyTableAttributeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class Product
{
}
?>

View File

@ -1,10 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\RemoveEmptyTableAttributeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class SkipDone
{
}

View File

@ -1,11 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\RemoveEmptyTableAttributeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Table(name: 'skip_not_empty')]
#[ORM\Entity]
class SkipNotEmpty
{
}

View File

@ -1,23 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Class_\RemoveEmptyTableAttributeRector;
use Iterator;
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class RemoveEmptyTableAttributeRectorTest extends AbstractRectorTestCase
{
public function test(string $filePath) : void
{
$this->doTestFile($filePath);
}
public static function provideData() : Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
public function provideConfigFilePath() : string
{
return __DIR__ . '/config/configured_rule.php';
}
}

View File

@ -1,12 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202307;
use Rector\Config\RectorConfig;
use Rector\Doctrine\CodeQuality\Rector\Class_\RemoveEmptyTableAttributeRector;
use Rector\Doctrine\Tests\ConfigList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->import(ConfigList::MAIN);
$rectorConfig->rule(RemoveEmptyTableAttributeRector::class);
};

View File

@ -1,23 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ChangeBigIntEntityPropertyToIntTypeRector;
use Iterator;
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class ChangeBigIntEntityPropertyToIntTypeRectorTest extends AbstractRectorTestCase
{
public function test(string $filePath) : void
{
$this->doTestFile($filePath);
}
public static function provideData() : Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
public function provideConfigFilePath() : string
{
return __DIR__ . '/config/configured_rule.php';
}
}

View File

@ -1,39 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ChangeBigIntEntityPropertyToIntTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class SomeEntity
{
/**
* @var int|null
* @ORM\Column(type="bigint", nullable=true)
*/
private $bigNumber;
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ChangeBigIntEntityPropertyToIntTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class SomeEntity
{
/**
* @var string|null
* @ORM\Column(type="bigint", nullable=true)
*/
private $bigNumber;
}
?>

View File

@ -1,39 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ChangeBigIntEntityPropertyToIntTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class OnlyInt
{
/**
* @var int
* @ORM\Column(type="bigint", nullable=true)
*/
private $bigNumber;
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ChangeBigIntEntityPropertyToIntTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class OnlyInt
{
/**
* @var string
* @ORM\Column(type="bigint", nullable=true)
*/
private $bigNumber;
}
?>

View File

@ -1,39 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ChangeBigIntEntityPropertyToIntTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class RandomFloat
{
/**
* @var float
* @ORM\Column(type="bigint", nullable=true)
*/
private $bigNumber;
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ChangeBigIntEntityPropertyToIntTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class RandomFloat
{
/**
* @var string
* @ORM\Column(type="bigint", nullable=true)
*/
private $bigNumber;
}
?>

View File

@ -1,17 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ChangeBigIntEntityPropertyToIntTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class SkipAlreadyString
{
/**
* @var string
* @ORM\Column(type="bigint", nullable=true)
*/
private $bigNumber;
}

View File

@ -1,12 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202307;
use Rector\Config\RectorConfig;
use Rector\Doctrine\CodeQuality\Rector\Property\ChangeBigIntEntityPropertyToIntTypeRector;
use Rector\Doctrine\Tests\ConfigList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->import(ConfigList::MAIN);
$rectorConfig->rule(ChangeBigIntEntityPropertyToIntTypeRector::class);
};

View File

@ -1,23 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector;
use Iterator;
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class CorrectDefaultTypesOnEntityPropertyRectorTest extends AbstractRectorTestCase
{
public function test(string $filePath) : void
{
$this->doTestFile($filePath);
}
public static function provideData() : Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
public function provideConfigFilePath() : string
{
return __DIR__ . '/config/configured_rule.php';
}
}

View File

@ -1,37 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class User
{
/**
* @ORM\Column(name="is_old", type="boolean")
*/
private $isOld = '0';
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class User
{
/**
* @ORM\Column(name="is_old", type="boolean")
*/
private $isOld = false;
}
?>

View File

@ -1,37 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class IntegerColumn
{
/**
* @ORM\Column(type="integer")
*/
private $stav = '1';
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class IntegerColumn
{
/**
* @ORM\Column(type="integer")
*/
private $stav = 1;
}
?>

View File

@ -1,21 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class SkipAlready
{
/**
* @ORM\Column(type="integer")
*/
private $stav = 1;
/**
* @ORM\Column(type="boolean")
*/
private $can = true;
}

View File

@ -1,15 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
define("DEFAULT_CONST") = true;
final class SkipConstInitializedBoolProperty
{
/**
* @ORM\Column(type="boolean")
*/
private ?bool $isActive = DEFAULT_CONST;
}

View File

@ -1,16 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
final class SkipConstInitializedBoolProperty
{
public const DEFAULT_CONST = true;
/**
* @ORM\Column(type="boolean")
*/
private ?bool $isActive = self::DEFAULT_CONST;
}

View File

@ -1,13 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
final class SkipNullableBoolProperty
{
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private ?bool $isActive = null;
}

View File

@ -1,13 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
final class SkipNullableProperty
{
/**
* @ORM\Column(type="integer", nullable=true)
*/
private ?int $entityId = null;
}

View File

@ -1,23 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class PointedToConstantValue
{
public const ONE = 1;
/**
* @ORM\Column(type="integer")
*/
private $stav = self::ONE;
/**
* @ORM\Column(type="integer")
*/
private $stav2 = SOME_CONSTANT_VALUE;
}

View File

@ -1,13 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
final class SkipStringNullableProperty
{
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $entityId = null;
}

View File

@ -1,37 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class SmallInt
{
/**
* @ORM\Column(type="smallint")
*/
private $stav = '1';
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class SmallInt
{
/**
* @ORM\Column(type="smallint")
*/
private $stav = 1;
}
?>

View File

@ -1,12 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202307;
use Rector\Config\RectorConfig;
use Rector\Doctrine\CodeQuality\Rector\Property\CorrectDefaultTypesOnEntityPropertyRector;
use Rector\Doctrine\Tests\ConfigList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->import(ConfigList::MAIN);
$rectorConfig->rule(CorrectDefaultTypesOnEntityPropertyRector::class);
};

View File

@ -1,23 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector;
use Iterator;
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class DoctrineTargetEntityStringToClassConstantRectorTest extends AbstractRectorTestCase
{
public function test(string $filePath) : void
{
$this->doTestFile($filePath);
}
public static function provideData() : Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
public function provideConfigFilePath() : string
{
return __DIR__ . '/config/configured_rule.php';
}
}

View File

@ -1,57 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Annotation;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\{AnotherClass as AnotherClassA, AnotherClass as AnotherClassB};
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass as AnotherClassC;
final class MyEntity
{
/**
* @ORM\Embedded(class="AnotherClassA")
*/
private $other;
/**
* @ORM\OneToMany(targetEntity="AnotherClassB")
*/
private readonly ?Collection $items;
/**
* @ORM\OneToMany(targetEntity="AnotherClassC")
*/
private readonly ?Collection $items2;
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Annotation;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\{AnotherClass as AnotherClassA, AnotherClass as AnotherClassB};
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass as AnotherClassC;
final class MyEntity
{
/**
* @ORM\Embedded(class=\Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)
*/
private $other;
/**
* @ORM\OneToMany(targetEntity=\Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)
*/
private readonly ?Collection $items;
/**
* @ORM\OneToMany(targetEntity=\Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)
*/
private readonly ?Collection $items2;
}
?>

View File

@ -1,85 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Annotation;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
final class MyEntity
{
/**
* @ORM\Embedded(class="AnotherClass")
*/
private $other;
/**
* @ORM\OneToMany(targetEntity="AnotherClass")
*/
private readonly ?Collection $items;
/**
* @ORM\ManyToOne(targetEntity="AnotherClass")
*/
private readonly ?Collection $items2;
/**
* @ORM\ManyToMany(targetEntity="AnotherClass")
*/
private readonly ?Collection $items3;
/**
* @ORM\OneToOne(mappedBy="class", targetEntity="AnotherClass")
*/
private readonly ?Collection $items4;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Annotation;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
final class MyEntity
{
/**
* @ORM\Embedded(class=\Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)
*/
private $other;
/**
* @ORM\OneToMany(targetEntity=\Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)
*/
private readonly ?Collection $items;
/**
* @ORM\ManyToOne(targetEntity=\Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)
*/
private readonly ?Collection $items2;
/**
* @ORM\ManyToMany(targetEntity=\Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)
*/
private readonly ?Collection $items3;
/**
* @ORM\OneToOne(mappedBy="class", targetEntity=\Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)
*/
private readonly ?Collection $items4;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>

View File

@ -1,63 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Annotation;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
final class MyEntity
{
/**
* Wrong Usage: @ORM\Embedded has a "class" attribute, but no "targetEntity"!
*
* @ORM\Embedded(targetEntity="AnotherClass")
*/
private $other;
/**
* Wrong Usage: @ORM\OneToMany has a "targetEntity" attribute, but no "class"!
*
* @ORM\OneToMany(class="AnotherClass")
*/
private readonly ?Collection $items;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Annotation;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
final class MyEntity
{
/**
* Wrong Usage: @ORM\Embedded has a "class" attribute, but no "targetEntity"!
*
* @ORM\Embedded(targetEntity="AnotherClass")
*/
private $other;
/**
* Wrong Usage: @ORM\OneToMany has a "targetEntity" attribute, but no "class"!
*
* @ORM\OneToMany(class="AnotherClass")
*/
private readonly ?Collection $items;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>

View File

@ -1,51 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Annotation;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
/**
* @see https://github.com/doctrine/orm/issues/8818
*/
final class MyEntity
{
/**
* @ORM\ManyToOne(targetEntity="App:AnotherClass")
*/
private readonly ?Collection $items;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Annotation;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
/**
* @see https://github.com/doctrine/orm/issues/8818
*/
final class MyEntity
{
/**
* @ORM\ManyToOne(targetEntity="App:AnotherClass")
*/
private readonly ?Collection $items;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>

View File

@ -1,33 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Annotation;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
final class MyEntity
{
/**
* @ORM\ManyToOne(targetEntity="UnresolvableClass")
*/
private readonly ?Collection $items;
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Annotation;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
final class MyEntity
{
/**
* @ORM\ManyToOne(targetEntity="UnresolvableClass")
*/
private readonly ?Collection $items;
}
?>

View File

@ -1,45 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Annotation;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
final class MyEntity
{
/**
* @ORM\ManyToOne(targetEntity="Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass")
*/
private readonly ?Collection $items;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Annotation;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
final class MyEntity
{
/**
* @ORM\ManyToOne(targetEntity=\Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)
*/
private readonly ?Collection $items;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>

View File

@ -1,45 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Attribute;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\{AnotherClass as AnotherClassA, AnotherClass as AnotherClassB};
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass as AnotherClassC;
final class MyEntity
{
#[ORM\Embedded(class: "AnotherClassA")]
private $other;
#[ORM\OneToMany(targetEntity: "AnotherClassB")]
private readonly ?Collection $items;
#[ORM\OneToMany(targetEntity: "AnotherClassC")]
private readonly ?Collection $items2;
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Attribute;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\{AnotherClass as AnotherClassA, AnotherClass as AnotherClassB};
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass as AnotherClassC;
final class MyEntity
{
#[ORM\Embedded(class: \Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)]
private $other;
#[ORM\OneToMany(targetEntity: \Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)]
private readonly ?Collection $items;
#[ORM\OneToMany(targetEntity: \Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)]
private readonly ?Collection $items2;
}
?>

View File

@ -1,57 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Attribute;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
final class MyEntity
{
#[ORM\Embedded(class: "AnotherClass")]
private readonly ?Collection $other;
#[ORM\OneToMany(targetEntity: "AnotherClass")]
private readonly ?Collection $items;
#[ORM\ManyToOne(targetEntity: "AnotherClass")]
private readonly ?Collection $items2;
#[ORM\ManyToMany(targetEntity: "AnotherClass")]
private readonly ?Collection $items3;
#[ORM\OneToOne(mappedBy: 'class', targetEntity: "AnotherClass")]
private readonly ?Collection $items4;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Attribute;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
final class MyEntity
{
#[ORM\Embedded(class: \Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)]
private readonly ?Collection $other;
#[ORM\OneToMany(targetEntity: \Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)]
private readonly ?Collection $items;
#[ORM\ManyToOne(targetEntity: \Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)]
private readonly ?Collection $items2;
#[ORM\ManyToMany(targetEntity: \Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)]
private readonly ?Collection $items3;
#[ORM\OneToOne(mappedBy: 'class', targetEntity: \Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)]
private readonly ?Collection $items4;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>

View File

@ -1,59 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Attribute;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
final class MyEntity
{
/**
* Wrong Usage: @ORM\Embedded has a "class" attribute, but no "targetEntity"!
*/
#[ORM\Embedded(targetEntity: "AnotherClass")]
private $other;
/**
* Wrong Usage: @ORM\OneToMany has a "targetEntity" attribute, but no "class"!
*/
#[ORM\OneToMany(class: "AnotherClass")]
private readonly ?Collection $items;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Attribute;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
final class MyEntity
{
/**
* Wrong Usage: @ORM\Embedded has a "class" attribute, but no "targetEntity"!
*/
#[ORM\Embedded(targetEntity: "AnotherClass")]
private $other;
/**
* Wrong Usage: @ORM\OneToMany has a "targetEntity" attribute, but no "class"!
*/
#[ORM\OneToMany(class: "AnotherClass")]
private readonly ?Collection $items;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>

View File

@ -1,41 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Attribute;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
final class MyEntity
{
#[ORM\ManyToOne(targetEntity: "App:AnotherClass")]
private readonly ?Collection $items;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Attribute;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
final class MyEntity
{
#[ORM\ManyToOne(targetEntity: "App:AnotherClass")]
private readonly ?Collection $items;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>

View File

@ -1,29 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Attribute;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
final class MyEntity
{
#[ORM\ManyToOne(targetEntity: "UnresolvableClass")]
private readonly ?Collection $items;
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Attribute;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
final class MyEntity
{
#[ORM\ManyToOne(targetEntity: "UnresolvableClass")]
private readonly ?Collection $items;
}
?>

View File

@ -1,41 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Attribute;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
final class MyEntity
{
#[ORM\ManyToOne(targetEntity: "Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass")]
private readonly ?Collection $items;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Fixture\Attribute;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass;
final class MyEntity
{
#[ORM\ManyToOne(targetEntity: \Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source\AnotherClass::class)]
private readonly ?Collection $items;
public function addItem(AnotherClass $myOtherEntity): void
{
$this->items->add($myOtherEntity);
}
}
?>

View File

@ -1,8 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector\Source;
final class AnotherClass
{
}

View File

@ -1,12 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202307;
use Rector\Config\RectorConfig;
use Rector\Doctrine\CodeQuality\Rector\Property\DoctrineTargetEntityStringToClassConstantRector;
use Rector\Doctrine\Tests\ConfigList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->import(ConfigList::MAIN);
$rectorConfig->rule(DoctrineTargetEntityStringToClassConstantRector::class);
};

View File

@ -1,70 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
final class AdderParam
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
*/
private $trainings = [];
/**
* @param \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training $training
* @return $this
*/
public function addTraining(\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training $training): self
{
if (!$this->trainings->contains($training)) {
$this->trainings[] = $training;
}
return $this;
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
final class AdderParam
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
* @var \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training>|\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training[]
*/
private $trainings = [];
/**
* @param \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training $training
* @return $this
*/
public function addTraining(\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training $training): self
{
if (!$this->trainings->contains($training)) {
$this->trainings[] = $training;
}
return $this;
}
}
?>

View File

@ -1,62 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
final class AdderParamWithTypehintOnly
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
*/
private $trainings = [];
public function addTraining(\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training $training): self
{
if (!$this->trainings->contains($training)) {
$this->trainings[] = $training;
}
return $this;
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
final class AdderParamWithTypehintOnly
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
* @var \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training>|\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training[]
*/
private $trainings = [];
public function addTraining(\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training $training): self
{
if (!$this->trainings->contains($training)) {
$this->trainings[] = $training;
}
return $this;
}
}
?>

View File

@ -1,42 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
class NoVar
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
*/
private $trainings = [];
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
class NoVar
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
* @var \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training>|\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training[]
*/
private $trainings = [];
}
?>

View File

@ -1,36 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
#[ORM\Entity]
class NoVar
{
#[ORM\OneToMany(targetEntity:Training::class, mappedBy:"trainer")]
private $trainings = [];
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
#[ORM\Entity]
class NoVar
{
/**
* @var \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training>|\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training[]
*/
#[ORM\OneToMany(targetEntity:Training::class, mappedBy:"trainer")]
private $trainings = [];
}
?>

View File

@ -1,58 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
final class ParamWithoutArray
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
*/
private $trainings = [];
/**
* @param Collection $collection
*/
public function setTrainings($collection): void
{
$this->trainings = $collection;
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
final class ParamWithoutArray
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
* @var \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training>|\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training[]
*/
private $trainings = [];
/**
* @param \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training>|\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training[] $collection
*/
public function setTrainings($collection): void
{
$this->trainings = $collection;
}
}
?>

View File

@ -1,23 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\CountryRef;
#[ORM\Entity]
class SkipCollectionGenericClass
{
/**
* @var Collection<int, CountryRef>
*/
#[ORM\OneToMany(mappedBy: 'country', targetEntity: CountryRef::class, cascade: ['persist'])]
private Collection $countryRefs;
public function __construct()
{
$this->countryRefs = new ArrayCollection();
}
}

View File

@ -1,24 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use DateTimeImmutable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class SkipCollectionGenericObject
{
/**
* @var Collection<int, object>
*/
#[ORM\OneToMany(mappedBy: 'port', targetEntity: object::class)]
private Collection $oi;
public function __construct()
{
$this->oi = new ArrayCollection();
}
}

View File

@ -1,43 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
class VarSomeClass
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
* @var Collection<int, string>|Training[]
*/
private $trainings = [];
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
class VarSomeClass
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
* @var \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training>|\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training[]
*/
private $trainings = [];
}
?>

View File

@ -1,73 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
class VarStatic
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
* @var Collection|Training[]
*/
private $trainings = [];
/**
* @var string
*/
private static $value = '';
public static function getValue()
{
return self::$value;
}
public static function setValue(string $value)
{
self::$value = $value;
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
class VarStatic
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
* @var \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training>|\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training[]
*/
private $trainings = [];
/**
* @var string
*/
private static $value = '';
public static function getValue()
{
return self::$value;
}
public static function setValue(string $value)
{
self::$value = $value;
}
}
?>

View File

@ -1,41 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
class VarWithoutArray
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
* @var Training[]
*/
private $trainings = [];
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
class VarWithoutArray
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
* @var \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training>|\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training[]
*/
private $trainings = [];
}
?>

View File

@ -1,41 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
class VarWithoutCollection
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
* @var Training[]
*/
private $trainings = [];
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
use Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training;
/**
* @ORM\Entity
*/
class VarWithoutCollection
{
/**
* @ORM\OneToMany(targetEntity=Training::class, mappedBy="trainer")
* @var \Doctrine\Common\Collections\Collection<int, \Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training>|\Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source\Training[]
*/
private $trainings = [];
}
?>

View File

@ -1,23 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector;
use Iterator;
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class ImproveDoctrineCollectionDocTypeInEntityRectorTest extends AbstractRectorTestCase
{
public function test(string $filePath) : void
{
$this->doTestFile($filePath);
}
public static function provideData() : Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
public function provideConfigFilePath() : string
{
return __DIR__ . '/config/configured_rule.php';
}
}

View File

@ -1,8 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source;
final class CountryRef
{
}

View File

@ -1,8 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector\Source;
final class Training
{
}

View File

@ -1,12 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202307;
use Rector\Config\RectorConfig;
use Rector\Doctrine\CodeQuality\Rector\Property\ImproveDoctrineCollectionDocTypeInEntityRector;
use Rector\Doctrine\Tests\ConfigList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->import(ConfigList::MAIN);
$rectorConfig->rule(ImproveDoctrineCollectionDocTypeInEntityRector::class);
};

View File

@ -1,51 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\MakeEntityDateTimePropertyDateTimeInterfaceRector\Fixture;
use DateTime;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class User
{
/**
* @var DateTime|null
*/
private $bornAt;
public function setBornAt(DateTimeInterface $bornAt)
{
$this->bornAt = $bornAt;
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\MakeEntityDateTimePropertyDateTimeInterfaceRector\Fixture;
use DateTime;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class User
{
/**
* @var \DateTimeInterface|null
*/
private $bornAt;
public function setBornAt(DateTimeInterface $bornAt)
{
$this->bornAt = $bornAt;
}
}
?>

View File

@ -1,41 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\MakeEntityDateTimePropertyDateTimeInterfaceRector\Fixture;
use DateTime;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(readOnly: true)]
#[ORM\Table(name: 'x_y_z')]
class NullableTypedPropertyDateTime
{
/**
* @var DateTime|null
*/
#[ORM\Column(name: 'canceledAt', type: 'datetime', nullable: true)]
private ?DateTimeInterface $canceledat = null;
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\MakeEntityDateTimePropertyDateTimeInterfaceRector\Fixture;
use DateTime;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(readOnly: true)]
#[ORM\Table(name: 'x_y_z')]
class NullableTypedPropertyDateTime
{
/**
* @var \DateTimeInterface|null
*/
#[ORM\Column(name: 'canceledAt', type: 'datetime', nullable: true)]
private ?DateTimeInterface $canceledat = null;
}
?>

View File

@ -1,22 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\MakeEntityDateTimePropertyDateTimeInterfaceRector\Fixture;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class SkipDateTimeInterface
{
/**
* @var DateTimeInterface|null
*/
private $bornAt;
public function setBornAt(DateTimeInterface $bornAt)
{
$this->bornAt = $bornAt;
}
}

View File

@ -1,23 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\MakeEntityDateTimePropertyDateTimeInterfaceRector;
use Iterator;
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class MakeEntityDateTimePropertyDateTimeInterfaceRectorTest extends AbstractRectorTestCase
{
public function test(string $filePath) : void
{
$this->doTestFile($filePath);
}
public static function provideData() : Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
public function provideConfigFilePath() : string
{
return __DIR__ . '/config/configured_rule.php';
}
}

View File

@ -1,12 +0,0 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202307;
use Rector\Config\RectorConfig;
use Rector\Doctrine\CodeQuality\Rector\Property\MakeEntityDateTimePropertyDateTimeInterfaceRector;
use Rector\Doctrine\Tests\ConfigList;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->import(ConfigList::MAIN);
$rectorConfig->rule(MakeEntityDateTimePropertyDateTimeInterfaceRector::class);
};

View File

@ -1,31 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
class ColumnNotNullable
{
/**
* @ORM\Column(type="string", nullable=false)
*/
private $surname;
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
class ColumnNotNullable
{
/**
* @ORM\Column(type="string", nullable=false)
*/
private string $surname;
}
?>

View File

@ -1,31 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
class ColumnNullable
{
/**
* @ORM\Column(type="string", nullable=true)
*/
private $surname;
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
class ColumnNullable
{
/**
* @ORM\Column(type="string", nullable=true)
*/
private ?string $surname = null;
}
?>

View File

@ -1,27 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
class ColumnNullableAttribute
{
#[ORM\Column(type: 'string', nullable: true)]
private $surname;
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
class ColumnNullableAttribute
{
#[ORM\Column(type: 'string', nullable: true)]
private ?string $surname = null;
}
?>

View File

@ -1,49 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class ColumnTypeBoolean
{
#[ORM\Column(type: 'boolean', length: 255, nullable: true)]
private $property;
public function getProperty(): ?bool
{
return $this->property;
}
public function setProperty(?bool $property): void
{
$this->property = $property;
}
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class ColumnTypeBoolean
{
#[ORM\Column(type: 'boolean', length: 255, nullable: true)]
private ?bool $property = null;
public function getProperty(): ?bool
{
return $this->property;
}
public function setProperty(?bool $property): void
{
$this->property = $property;
}
}
?>

View File

@ -1,27 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
class NotNullableAttribute
{
#[ORM\Column(type: 'string', nullable: false)]
private $surname;
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
class NotNullableAttribute
{
#[ORM\Column(type: 'string', nullable: false)]
private string $surname;
}
?>

View File

@ -1,31 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
class SimpleColumn
{
/**
* @ORM\Column(type="string")
*/
private $name;
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
class SimpleColumn
{
/**
* @ORM\Column(type="string")
*/
private ?string $name = null;
}
?>

View File

@ -1,27 +0,0 @@
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
class SimpleColumnAttribute
{
#[ORM\Column(type: 'string')]
private $name;
}
?>
-----
<?php
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector\Fixture;
use Doctrine\ORM\Mapping as ORM;
class SimpleColumnAttribute
{
#[ORM\Column(type: 'string')]
private ?string $name = null;
}
?>

View File

@ -1,24 +0,0 @@
<?php
declare (strict_types=1);
namespace Rector\Doctrine\Tests\CodeQuality\Rector\Property\TypedPropertyFromColumnTypeRector;
use Iterator;
use RectorPrefix202307\PHPUnit\Framework\Attributes\DataProvider;
use RectorPrefix202307\PHPUnit\Framework\Attributes\RunClassInSeparateProcess;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
final class TypedPropertyFromColumnTypeRectorTest extends AbstractRectorTestCase
{
public function test(string $filePath) : void
{
$this->doTestFile($filePath);
}
public static function provideData() : Iterator
{
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
}
public function provideConfigFilePath() : string
{
return __DIR__ . '/config/configured_rule.php';
}
}

Some files were not shown because too many files have changed in this diff Show More