Skip to content

Commit bb2d472

Browse files
committed
Updated Rector to commit f5c7bbd7ce702f280c8a77df25d8b1274207464f
rectorphp/rector-src@f5c7bbd Cleanup (#7731)
1 parent 90e2775 commit bb2d472

File tree

8 files changed

+35
-21
lines changed

8 files changed

+35
-21
lines changed

rules/Privatization/Guard/LaravelModelGuard.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PhpParser\Node\Stmt\ClassMethod;
88
use PHPStan\Reflection\ClassReflection;
99
use PHPStan\Type\ObjectType;
10+
use Rector\Enum\LaravelClassName;
1011
use Rector\NodeNameResolver\NodeNameResolver;
1112
use Rector\NodeTypeResolver\NodeTypeResolver;
1213
use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
@@ -46,7 +47,7 @@ public function __construct(PhpAttributeAnalyzer $phpAttributeAnalyzer, NodeName
4647
}
4748
public function isProtectedMethod(ClassReflection $classReflection, ClassMethod $classMethod): bool
4849
{
49-
if (!$classReflection->is('Illuminate\Database\Eloquent\Model')) {
50+
if (!$classReflection->is(LaravelClassName::MODEL)) {
5051
return \false;
5152
}
5253
$name = (string) $this->nodeNameResolver->getName($classMethod->name);
@@ -63,13 +64,13 @@ private function isAttributeMethod(string $name, ClassMethod $classMethod): bool
6364
if (!$classMethod->returnType instanceof Node) {
6465
return \false;
6566
}
66-
return $this->nodeTypeResolver->isObjectType($classMethod->returnType, new ObjectType('Illuminate\Database\Eloquent\Casts\Attribute'));
67+
return $this->nodeTypeResolver->isObjectType($classMethod->returnType, new ObjectType(LaravelClassName::CAST_ATTRIBUTE));
6768
}
6869
private function isScopeMethod(string $name, ClassMethod $classMethod): bool
6970
{
7071
if (StringUtils::isMatch($name, self::LARAVEL_MODEL_SCOPE_REGEX)) {
7172
return \true;
7273
}
73-
return $this->phpAttributeAnalyzer->hasPhpAttribute($classMethod, 'Illuminate\Database\Eloquent\Attributes\Scope');
74+
return $this->phpAttributeAnalyzer->hasPhpAttribute($classMethod, LaravelClassName::ATTRIBUTES_SCOPE);
7475
}
7576
}

rules/Privatization/Guard/ParentClassMagicCallGuard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
declare (strict_types=1);
44
namespace Rector\Privatization\Guard;
55

6-
use PhpParser\PrettyPrinterAbstract;
76
use PhpParser\Node\Expr;
87
use PhpParser\Node\Expr\MethodCall;
98
use PhpParser\Node\Name;
109
use PhpParser\Node\Stmt\Class_;
1110
use PhpParser\PrettyPrinter\Standard;
11+
use PhpParser\PrettyPrinterAbstract;
1212
use Rector\NodeNameResolver\NodeNameResolver;
1313
use Rector\PhpParser\AstResolver;
1414
use Rector\PhpParser\Node\BetterNodeFinder;

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '4b78d1229d48cb05a472f7c7895d10a2e090f9a6';
22+
public const PACKAGE_VERSION = 'f5c7bbd7ce702f280c8a77df25d8b1274207464f';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2025-12-07 22:08:54';
27+
public const RELEASE_DATE = '2025-12-07 22:45:12';
2828
/**
2929
* @var int
3030
*/

src/Enum/LaravelClassName.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare (strict_types=1);
4+
namespace Rector\Enum;
5+
6+
final class LaravelClassName
7+
{
8+
public const MODEL = 'Illuminate\Database\Eloquent\Model';
9+
public const CAST_ATTRIBUTE = 'Illuminate\Database\Eloquent\Casts\Attribute';
10+
public const ATTRIBUTES_SCOPE = 'Illuminate\Database\Eloquent\Attributes\Scope';
11+
}

src/PostRector/Application/PostFileProcessor.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ private function getPostRectors(): array
109109
}
110110
$isRenamedClassEnabled = $this->renamedClassesDataCollector->getOldToNewClasses() !== [];
111111
$isNameImportingEnabled = SimpleParameterProvider::provideBoolParameter(Option::AUTO_IMPORT_NAMES);
112-
$isDocblockNameImportingEnabled = SimpleParameterProvider::provideBoolParameter(Option::AUTO_IMPORT_DOC_BLOCK_NAMES);
113112
$isRemovingUnusedImportsEnabled = SimpleParameterProvider::provideBoolParameter(Option::REMOVE_UNUSED_IMPORTS);
114113
$postRectors = [];
115114
// sorted by priority, to keep removed imports in order
@@ -119,10 +118,10 @@ private function getPostRectors(): array
119118
// import names
120119
if ($isNameImportingEnabled) {
121120
$postRectors[] = $this->nameImportingPostRector;
122-
}
123-
// import docblocks
124-
if ($isNameImportingEnabled && $isDocblockNameImportingEnabled) {
125-
$postRectors[] = $this->docblockNameImportingPostRector;
121+
// import docblocks
122+
if (SimpleParameterProvider::provideBoolParameter(Option::AUTO_IMPORT_DOC_BLOCK_NAMES)) {
123+
$postRectors[] = $this->docblockNameImportingPostRector;
124+
}
126125
}
127126
$postRectors[] = $this->useAddingPostRector;
128127
if ($isRemovingUnusedImportsEnabled) {

src/Testing/TestingParser/TestingParser.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,30 @@ public function __construct(RectorParser $rectorParser, NodeScopeAndMetadataDeco
4040
}
4141
public function parseFilePathToFile(string $filePath): File
4242
{
43-
// needed for PHPStan reflection, as it caches the last processed file
44-
$this->dynamicSourceLocatorProvider->setFilePath($filePath);
45-
$fileContent = FileSystem::read($filePath);
46-
$file = new File($filePath, $fileContent);
47-
$stmts = $this->rectorParser->parseString($fileContent);
48-
$stmts = $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($filePath, $stmts);
49-
$file->hydrateStmtsAndTokens($stmts, $stmts, []);
50-
$this->currentFileProvider->setFile($file);
43+
[$file, $stmts] = $this->parseToFileAndStmts($filePath);
5144
return $file;
5245
}
5346
/**
5447
* @return Node[]
5548
*/
5649
public function parseFileToDecoratedNodes(string $filePath): array
50+
{
51+
[$file, $stmts] = $this->parseToFileAndStmts($filePath);
52+
return $stmts;
53+
}
54+
/**
55+
* @return array{0: File, 1: Node[]}
56+
*/
57+
private function parseToFileAndStmts(string $filePath): array
5758
{
5859
// needed for PHPStan reflection, as it caches the last processed file
5960
$this->dynamicSourceLocatorProvider->setFilePath($filePath);
6061
$fileContent = FileSystem::read($filePath);
61-
$stmts = $this->rectorParser->parseString($fileContent);
6262
$file = new File($filePath, $fileContent);
63+
$stmts = $this->rectorParser->parseString($fileContent);
6364
$stmts = $this->nodeScopeAndMetadataDecorator->decorateNodesFromFile($filePath, $stmts);
6465
$file->hydrateStmtsAndTokens($stmts, $stmts, []);
6566
$this->currentFileProvider->setFile($file);
66-
return $stmts;
67+
return [$file, $stmts];
6768
}
6869
}

vendor/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,7 @@
16971697
'Rector\\Enum\\ClassName' => $baseDir . '/src/Enum/ClassName.php',
16981698
'Rector\\Enum\\Config\\Defaults' => $baseDir . '/src/Enum/Config/Defaults.php',
16991699
'Rector\\Enum\\JsonConstant' => $vendorDir . '/rector/rector-downgrade-php/src/Enum/JsonConstant.php',
1700+
'Rector\\Enum\\LaravelClassName' => $baseDir . '/src/Enum/LaravelClassName.php',
17001701
'Rector\\Enum\\ObjectReference' => $baseDir . '/src/Enum/ObjectReference.php',
17011702
'Rector\\Exception\\Cache\\CachingException' => $baseDir . '/src/Exception/Cache/CachingException.php',
17021703
'Rector\\Exception\\Configuration\\InvalidConfigurationException' => $baseDir . '/src/Exception/Configuration/InvalidConfigurationException.php',

vendor/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,7 @@ class ComposerStaticInit9382e835eeb0e1e0bafb04fcb204a42a
19571957
'Rector\\Enum\\ClassName' => __DIR__ . '/../..' . '/src/Enum/ClassName.php',
19581958
'Rector\\Enum\\Config\\Defaults' => __DIR__ . '/../..' . '/src/Enum/Config/Defaults.php',
19591959
'Rector\\Enum\\JsonConstant' => __DIR__ . '/..' . '/rector/rector-downgrade-php/src/Enum/JsonConstant.php',
1960+
'Rector\\Enum\\LaravelClassName' => __DIR__ . '/../..' . '/src/Enum/LaravelClassName.php',
19601961
'Rector\\Enum\\ObjectReference' => __DIR__ . '/../..' . '/src/Enum/ObjectReference.php',
19611962
'Rector\\Exception\\Cache\\CachingException' => __DIR__ . '/../..' . '/src/Exception/Cache/CachingException.php',
19621963
'Rector\\Exception\\Configuration\\InvalidConfigurationException' => __DIR__ . '/../..' . '/src/Exception/Configuration/InvalidConfigurationException.php',

0 commit comments

Comments
 (0)