Skip to content

Commit

Permalink
Updated Rector to commit f366a7e66228f35dc877e816b553c4f38332f801
Browse files Browse the repository at this point in the history
rectorphp/rector-src@f366a7e [DX] add notifyWithPhpSetsNotSuitableForPHP80() (#5988)
  • Loading branch information
TomasVotruba committed Jun 20, 2024
1 parent 14cd108 commit 9d08250
Show file tree
Hide file tree
Showing 21 changed files with 112 additions and 260 deletions.
1 change: 0 additions & 1 deletion vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,6 @@
'Rector\\Doctrine\\TypeAnalyzer\\CollectionTypeFactory' => $vendorDir . '/rector/rector-doctrine/src/TypeAnalyzer/CollectionTypeFactory.php',
'Rector\\Doctrine\\TypeAnalyzer\\CollectionTypeResolver' => $vendorDir . '/rector/rector-doctrine/src/TypeAnalyzer/CollectionTypeResolver.php',
'Rector\\Doctrine\\TypeAnalyzer\\CollectionVarTagValueNodeResolver' => $vendorDir . '/rector/rector-doctrine/src/TypeAnalyzer/CollectionVarTagValueNodeResolver.php',
'Rector\\Doctrine\\TypeAnalyzer\\DoctrineCollectionTypeAnalyzer' => $vendorDir . '/rector/rector-doctrine/src/TypeAnalyzer/DoctrineCollectionTypeAnalyzer.php',
'Rector\\DowngradePhp72\\NodeAnalyzer\\BuiltInMethodAnalyzer' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp72/NodeAnalyzer/BuiltInMethodAnalyzer.php',
'Rector\\DowngradePhp72\\NodeAnalyzer\\OverrideFromAnonymousClassMethodAnalyzer' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp72/NodeAnalyzer/OverrideFromAnonymousClassMethodAnalyzer.php',
'Rector\\DowngradePhp72\\NodeAnalyzer\\RegexFuncAnalyzer' => $vendorDir . '/rector/rector-downgrade-php/rules/DowngradePhp72/NodeAnalyzer/RegexFuncAnalyzer.php',
Expand Down
1 change: 0 additions & 1 deletion vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,6 @@ class ComposerStaticInitc6bcdb63495c7f1cc77baa21ee134e8a
'Rector\\Doctrine\\TypeAnalyzer\\CollectionTypeFactory' => __DIR__ . '/..' . '/rector/rector-doctrine/src/TypeAnalyzer/CollectionTypeFactory.php',
'Rector\\Doctrine\\TypeAnalyzer\\CollectionTypeResolver' => __DIR__ . '/..' . '/rector/rector-doctrine/src/TypeAnalyzer/CollectionTypeResolver.php',
'Rector\\Doctrine\\TypeAnalyzer\\CollectionVarTagValueNodeResolver' => __DIR__ . '/..' . '/rector/rector-doctrine/src/TypeAnalyzer/CollectionVarTagValueNodeResolver.php',
'Rector\\Doctrine\\TypeAnalyzer\\DoctrineCollectionTypeAnalyzer' => __DIR__ . '/..' . '/rector/rector-doctrine/src/TypeAnalyzer/DoctrineCollectionTypeAnalyzer.php',
'Rector\\DowngradePhp72\\NodeAnalyzer\\BuiltInMethodAnalyzer' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp72/NodeAnalyzer/BuiltInMethodAnalyzer.php',
'Rector\\DowngradePhp72\\NodeAnalyzer\\OverrideFromAnonymousClassMethodAnalyzer' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp72/NodeAnalyzer/OverrideFromAnonymousClassMethodAnalyzer.php',
'Rector\\DowngradePhp72\\NodeAnalyzer\\RegexFuncAnalyzer' => __DIR__ . '/..' . '/rector/rector-downgrade-php/rules/DowngradePhp72/NodeAnalyzer/RegexFuncAnalyzer.php',
Expand Down
46 changes: 23 additions & 23 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -1680,37 +1680,38 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-doctrine.git",
"reference": "6eb8de836a52701d15ab3fd020052a1843fad992"
"reference": "c3c91df9134657245c63d956aa6afc5bbdba5d6f"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/6eb8de836a52701d15ab3fd020052a1843fad992",
"reference": "6eb8de836a52701d15ab3fd020052a1843fad992",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-doctrine\/zipball\/c3c91df9134657245c63d956aa6afc5bbdba5d6f",
"reference": "c3c91df9134657245c63d956aa6afc5bbdba5d6f",
"shasum": ""
},
"require": {
"php": ">=8.2",
"symfony\/yaml": "^6.4"
"symfony\/yaml": "^7.1"
},
"require-dev": {
"doctrine\/doctrine-bundle": "^2.11",
"doctrine\/orm": "^2.18",
"doctrine\/doctrine-bundle": "^2.12",
"doctrine\/orm": "^2.19",
"phpstan\/extension-installer": "^1.3",
"phpstan\/phpstan": "^1.10.57",
"phpstan\/phpstan": "^1.11",
"phpstan\/phpstan-webmozart-assert": "^1.2",
"phpunit\/phpunit": "^10.5",
"rector\/rector-generator": "^0.7.10",
"rector\/rector-generator": "^0.7.12",
"rector\/rector-src": "dev-main",
"symplify\/easy-coding-standard": "^12.1",
"rector\/type-perfect": "^0.1.6",
"symplify\/easy-coding-standard": "^12.3",
"symplify\/phpstan-extensions": "^11.4",
"symplify\/phpstan-rules": "^11.4",
"symplify\/phpstan-rules": "^13.0",
"symplify\/rule-doc-generator": "^12.1",
"symplify\/vendor-patches": "^11.3",
"tomasvotruba\/class-leak": "^0.2.13",
"tomasvotruba\/class-leak": "^0.2.15",
"tomasvotruba\/unused-public": "^0.3",
"tracy\/tracy": "^2.10"
},
"time": "2024-05-30T08:28:26+00:00",
"time": "2024-06-20T14:04:02+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
Expand Down Expand Up @@ -2540,31 +2541,30 @@
},
{
"name": "symfony\/yaml",
"version": "v6.4.8",
"version_normalized": "6.4.8.0",
"version": "v7.1.1",
"version_normalized": "7.1.1.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/symfony\/yaml.git",
"reference": "52903de178d542850f6f341ba92995d3d63e60c9"
"reference": "fa34c77015aa6720469db7003567b9f772492bf2"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/yaml\/zipball\/52903de178d542850f6f341ba92995d3d63e60c9",
"reference": "52903de178d542850f6f341ba92995d3d63e60c9",
"url": "https:\/\/api.github.com\/repos\/symfony\/yaml\/zipball\/fa34c77015aa6720469db7003567b9f772492bf2",
"reference": "fa34c77015aa6720469db7003567b9f772492bf2",
"shasum": ""
},
"require": {
"php": ">=8.1",
"symfony\/deprecation-contracts": "^2.5|^3",
"php": ">=8.2",
"symfony\/polyfill-ctype": "^1.8"
},
"conflict": {
"symfony\/console": "<5.4"
"symfony\/console": "<6.4"
},
"require-dev": {
"symfony\/console": "^5.4|^6.0|^7.0"
"symfony\/console": "^6.4|^7.0"
},
"time": "2024-05-31T14:49:08+00:00",
"time": "2024-05-31T14:57:53+00:00",
"bin": [
"Resources\/bin\/yaml-lint"
],
Expand Down Expand Up @@ -2595,7 +2595,7 @@
"description": "Loads and dumps YAML files",
"homepage": "https:\/\/symfony.com",
"support": {
"source": "https:\/\/github.com\/symfony\/yaml\/tree\/v6.4.8"
"source": "https:\/\/github.com\/symfony\/yaml\/tree\/v7.1.1"
},
"funding": [
{
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/installed.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vendor/rector/extension-installer/src/GeneratedConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 6eb8de8'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main a16ded4'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 6816002'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main b4dfb48'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main c3c91df'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main a16ded4'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 6816002'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main b4dfb48'));
private function __construct()
{
}
Expand Down
17 changes: 9 additions & 8 deletions vendor/rector/rector-doctrine/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@
"description": "Rector upgrades rules for Doctrine",
"require": {
"php": ">=8.2",
"symfony\/yaml": "^6.4"
"symfony\/yaml": "^7.1"
},
"require-dev": {
"doctrine\/doctrine-bundle": "^2.11",
"doctrine\/orm": "^2.18",
"doctrine\/doctrine-bundle": "^2.12",
"doctrine\/orm": "^2.19",
"phpstan\/extension-installer": "^1.3",
"phpstan\/phpstan": "^1.10.57",
"phpstan\/phpstan": "^1.11",
"phpstan\/phpstan-webmozart-assert": "^1.2",
"phpunit\/phpunit": "^10.5",
"rector\/rector-generator": "^0.7.10",
"rector\/rector-generator": "^0.7.12",
"rector\/rector-src": "dev-main",
"symplify\/easy-coding-standard": "^12.1",
"rector\/type-perfect": "^0.1.6",
"symplify\/easy-coding-standard": "^12.3",
"symplify\/phpstan-extensions": "^11.4",
"symplify\/phpstan-rules": "^11.4",
"symplify\/phpstan-rules": "^13.0",
"symplify\/rule-doc-generator": "^12.1",
"symplify\/vendor-patches": "^11.3",
"tomasvotruba\/class-leak": "^0.2.13",
"tomasvotruba\/class-leak": "^0.2.15",
"tomasvotruba\/unused-public": "^0.3",
"tracy\/tracy": "^2.10"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public function transform(EntityMapping $entityMapping, Class_ $class) : void
$this->addIndexes($classMapping['indexes'] ?? [], $class, MappingClass::INDEX);
$this->addIndexes($classMapping['uniqueConstraints'] ?? [], $class, MappingClass::UNIQUE_CONSTRAINT);
}
public function getClassName() : string
{
return MappingClass::TABLE;
}
/**
* @param array<string, array<string, mixed>> $mapping
* @param MappingClass::* $attribute
Expand All @@ -52,8 +56,4 @@ private function addIndexes(array $mapping, Class_ $class, string $attribute) :
$class->attrGroups[] = AttributeFactory::createGroup($attribute, $args);
}
}
public function getClassName() : string
{
return MappingClass::TABLE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public function transform(EntityMapping $entityMapping, $property) : void
$this->transformMapping($property, $entityMapping->matchManyToManyPropertyMapping($property)['joinTable'] ?? null);
$this->transformMapping($property, $entityMapping->matchManyToOnePropertyMapping($property));
}
public function getClassName() : string
{
return MappingClass::JOIN_COLUMN;
}
/**
* @param array<string, array<string, mixed>>|null $mapping
* @param \PhpParser\Node\Stmt\Property|\PhpParser\Node\Param $property
Expand All @@ -53,10 +57,6 @@ private function transformMapping($property, ?array $mapping) : void
$property->attrGroups[] = $this->createJoinColumnAttrGroup($columnName, $joinColumn);
}
}
public function getClassName() : string
{
return MappingClass::JOIN_COLUMN;
}
/**
* @param int|string $columnName
* @param mixed $joinColumn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,21 @@

use PhpParser\Node;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Expression;
use Rector\Doctrine\NodeAnalyzer\AttrinationFinder;
use Rector\Doctrine\NodeFactory\ArrayCollectionAssignFactory;
use Rector\NodeManipulator\ClassDependencyManipulator;
use Rector\Rector\AbstractRector;
use Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/best-practices.html#initialize-collections-in-the-constructor
*
* @see \Rector\Doctrine\Tests\CodeQuality\Rector\Class_\InitializeDefaultEntityCollectionRector\InitializeDefaultEntityCollectionRectorTest
*
* @deprecated This rule can create incomplete assign of object to an array. Use the @see \Rector\Doctrine\CodeQuality\Rector\Class_\ExplicitRelationCollectionRector instead.
* @deprecated This rule can create incomplete assign of object to an array. Use the
* @see \Rector\Doctrine\CodeQuality\Rector\Class_\ExplicitRelationCollectionRector instead
*/
final class InitializeDefaultEntityCollectionRector extends AbstractRector
{
/**
* @readonly
* @var \Rector\NodeManipulator\ClassDependencyManipulator
*/
private $classDependencyManipulator;
/**
* @readonly
* @var \Rector\Doctrine\NodeFactory\ArrayCollectionAssignFactory
*/
private $arrayCollectionAssignFactory;
/**
* @readonly
* @var \Rector\Doctrine\NodeAnalyzer\AttrinationFinder
*/
private $attrinationFinder;
/**
* @readonly
* @var \Rector\TypeDeclaration\AlreadyAssignDetector\ConstructorAssignDetector
*/
private $constructorAssignDetector;
/**
* @var string[]
* @var bool
*/
private const TO_MANY_ANNOTATION_CLASSES = ['Doctrine\\ORM\\Mapping\\OneToMany', 'Doctrine\\ORM\\Mapping\\ManyToMany'];
public function __construct(ClassDependencyManipulator $classDependencyManipulator, ArrayCollectionAssignFactory $arrayCollectionAssignFactory, AttrinationFinder $attrinationFinder, ConstructorAssignDetector $constructorAssignDetector)
{
$this->classDependencyManipulator = $classDependencyManipulator;
$this->arrayCollectionAssignFactory = $arrayCollectionAssignFactory;
$this->attrinationFinder = $attrinationFinder;
$this->constructorAssignDetector = $constructorAssignDetector;
}
private $hasWarned = \false;
public function getRuleDefinition() : RuleDefinition
{
return new RuleDefinition('Initialize collection property in Entity constructor', [new CodeSample(<<<'CODE_SAMPLE'
Expand Down Expand Up @@ -102,49 +69,12 @@ public function getNodeTypes() : array
*/
public function refactor(Node $node) : ?Node
{
if (!$this->attrinationFinder->hasByOne($node, 'Doctrine\\ORM\\Mapping\\Entity')) {
if ($this->hasWarned) {
return null;
}
$toManyPropertyNames = $this->resolveToManyPropertyNames($node);
if ($toManyPropertyNames === []) {
return null;
}
$assigns = $this->createAssignsOfArrayCollectionsForPropertyNames($toManyPropertyNames);
$this->classDependencyManipulator->addStmtsToConstructorIfNotThereYet($node, $assigns);
return $node;
}
/**
* @return string[]
*/
private function resolveToManyPropertyNames(Class_ $class) : array
{
$collectionPropertyNames = [];
foreach ($class->getProperties() as $property) {
if (\count($property->props) !== 1) {
continue;
}
if (!$this->attrinationFinder->hasByMany($property, self::TO_MANY_ANNOTATION_CLASSES)) {
continue;
}
/** @var string $propertyName */
$propertyName = $this->getName($property);
if ($this->constructorAssignDetector->isPropertyAssigned($class, $propertyName)) {
continue;
}
$collectionPropertyNames[] = $propertyName;
}
return $collectionPropertyNames;
}
/**
* @param string[] $propertyNames
* @return Expression[]
*/
private function createAssignsOfArrayCollectionsForPropertyNames(array $propertyNames) : array
{
$assigns = [];
foreach ($propertyNames as $propertyName) {
$assigns[] = $this->arrayCollectionAssignFactory->createFromPropertyName($propertyName);
}
return $assigns;
\trigger_error(\sprintf('The "%s" rule was deprecated, as its functionality caused bugs. Without knowing the full dependency tree, its risky to change. Use "%s" instead', self::class, 'https://github.com/rectorphp/swiss-knife#4-finalize-classes-without-children'));
\sleep(3);
$this->hasWarned = \true;
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ private function refactorAttribute(Expr $expr, PhpDocInfo $phpDocInfo, Property
return null;
}
$fullyQualifiedObjectType = new FullyQualifiedObjectType($targetEntityClassName);
$newVarType = $this->collectionTypeFactory->createType($fullyQualifiedObjectType);
$this->phpDocTypeChanger->changeVarType($property, $phpDocInfo, $newVarType);
$genericObjectType = $this->collectionTypeFactory->createType($fullyQualifiedObjectType);
$this->phpDocTypeChanger->changeVarType($property, $phpDocInfo, $genericObjectType);
return $property;
}
}
Loading

0 comments on commit 9d08250

Please sign in to comment.