Skip to content

Commit 240587c

Browse files
committed
Updated Rector to commit 4997962de1f53c449dadbef7025bffe5ca41e63c
rectorphp/rector-src@4997962 Bump PHPStan to 2.1.38 (#7879)
1 parent b248cd1 commit 240587c

File tree

9 files changed

+145
-17
lines changed

9 files changed

+145
-17
lines changed

vendor/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,6 +1957,7 @@
19571957
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\EntityDocumentCreateMockToDirectNewRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/EntityDocumentCreateMockToDirectNewRector.php',
19581958
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\NoSetupWithParentCallOverrideRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/NoSetupWithParentCallOverrideRector.php',
19591959
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\RemoveEmptyTestMethodRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/RemoveEmptyTestMethodRector.php',
1960+
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\RemoveStandaloneCreateMockRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/RemoveStandaloneCreateMockRector.php',
19601961
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\ReplaceTestAnnotationWithPrefixedFunctionRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/ReplaceTestAnnotationWithPrefixedFunctionRector.php',
19611962
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\ReplaceTestFunctionPrefixWithAttributeRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/ReplaceTestFunctionPrefixWithAttributeRector.php',
19621963
'Rector\\PHPUnit\\CodeQuality\\Rector\\Class_\\AddParamTypeFromDependsRector' => $vendorDir . '/rector/rector-phpunit/rules/CodeQuality/Rector/Class_/AddParamTypeFromDependsRector.php',

vendor/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,6 +2217,7 @@ class ComposerStaticInit6374fd21a3f525a40760d79e3596b56b
22172217
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\EntityDocumentCreateMockToDirectNewRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/EntityDocumentCreateMockToDirectNewRector.php',
22182218
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\NoSetupWithParentCallOverrideRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/NoSetupWithParentCallOverrideRector.php',
22192219
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\RemoveEmptyTestMethodRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/RemoveEmptyTestMethodRector.php',
2220+
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\RemoveStandaloneCreateMockRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/RemoveStandaloneCreateMockRector.php',
22202221
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\ReplaceTestAnnotationWithPrefixedFunctionRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/ReplaceTestAnnotationWithPrefixedFunctionRector.php',
22212222
'Rector\\PHPUnit\\CodeQuality\\Rector\\ClassMethod\\ReplaceTestFunctionPrefixWithAttributeRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/ReplaceTestFunctionPrefixWithAttributeRector.php',
22222223
'Rector\\PHPUnit\\CodeQuality\\Rector\\Class_\\AddParamTypeFromDependsRector' => __DIR__ . '/..' . '/rector/rector-phpunit/rules/CodeQuality/Rector/Class_/AddParamTypeFromDependsRector.php',

vendor/composer/installed.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -574,25 +574,25 @@
574574
},
575575
{
576576
"name": "illuminate\/contracts",
577-
"version": "v12.49.0",
578-
"version_normalized": "12.49.0.0",
577+
"version": "v12.50.0",
578+
"version_normalized": "12.50.0.0",
579579
"source": {
580580
"type": "git",
581581
"url": "https:\/\/github.com\/illuminate\/contracts.git",
582-
"reference": "2c0015e16b40f32c41e49810b6a0acf61204ea3d"
582+
"reference": "3d4eeab332c04a9eaea90968c19a66f78745e47a"
583583
},
584584
"dist": {
585585
"type": "zip",
586-
"url": "https:\/\/api.github.com\/repos\/illuminate\/contracts\/zipball\/2c0015e16b40f32c41e49810b6a0acf61204ea3d",
587-
"reference": "2c0015e16b40f32c41e49810b6a0acf61204ea3d",
586+
"url": "https:\/\/api.github.com\/repos\/illuminate\/contracts\/zipball\/3d4eeab332c04a9eaea90968c19a66f78745e47a",
587+
"reference": "3d4eeab332c04a9eaea90968c19a66f78745e47a",
588588
"shasum": ""
589589
},
590590
"require": {
591591
"php": "^8.2",
592592
"psr\/container": "^1.1.1|^2.0.1",
593593
"psr\/simple-cache": "^1.0|^2.0|^3.0"
594594
},
595-
"time": "2026-01-07T14:57:06+00:00",
595+
"time": "2026-01-28T15:26:27+00:00",
596596
"type": "library",
597597
"extra": {
598598
"branch-alias": {
@@ -1818,12 +1818,12 @@
18181818
"source": {
18191819
"type": "git",
18201820
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
1821-
"reference": "9cae00eeabb9c529b8cfa76a048146b568dae063"
1821+
"reference": "5617724ec57b4d5d51c5fa412d6b2aa6d06c05e2"
18221822
},
18231823
"dist": {
18241824
"type": "zip",
1825-
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/9cae00eeabb9c529b8cfa76a048146b568dae063",
1826-
"reference": "9cae00eeabb9c529b8cfa76a048146b568dae063",
1825+
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/5617724ec57b4d5d51c5fa412d6b2aa6d06c05e2",
1826+
"reference": "5617724ec57b4d5d51c5fa412d6b2aa6d06c05e2",
18271827
"shasum": ""
18281828
},
18291829
"require": {
@@ -1850,7 +1850,7 @@
18501850
"tomasvotruba\/unused-public": "^2.2",
18511851
"tracy\/tracy": "^2.11"
18521852
},
1853-
"time": "2026-02-04T17:50:27+00:00",
1853+
"time": "2026-02-04T21:49:54+00:00",
18541854
"default-branch": true,
18551855
"type": "rector-extension",
18561856
"extra": {

vendor/composer/installed.php

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

vendor/illuminate/contracts/Database/ModelIdentifier.php

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
namespace RectorPrefix202602\Illuminate\Contracts\Database;
44

5+
use RectorPrefix202602\Illuminate\Database\Eloquent\Relations\Relation;
56
class ModelIdentifier
67
{
8+
/**
9+
* Use the Relation morphMap for a Model's name when serializing.
10+
*/
11+
protected static bool $useMorphMap = \false;
712
/**
813
* The class name of the model.
914
*
10-
* @var class-string<\Illuminate\Database\Eloquent\Model>
15+
* @var class-string<\Illuminate\Database\Eloquent\Model>|string|null
1116
*/
1217
public $class;
1318
/**
@@ -39,15 +44,18 @@ class ModelIdentifier
3944
/**
4045
* Create a new model identifier.
4146
*
42-
* @param class-string<\Illuminate\Database\Eloquent\Model> $class
47+
* @param class-string<\Illuminate\Database\Eloquent\Model>|null $class
4348
* @param mixed $id
4449
* @param array $relations
4550
* @param mixed $connection
4651
*/
4752
public function __construct($class, $id, array $relations, $connection)
4853
{
49-
$this->id = $id;
54+
if ($class !== null && self::$useMorphMap) {
55+
$class = Relation::getMorphAlias($class);
56+
}
5057
$this->class = $class;
58+
$this->id = $id;
5159
$this->relations = $relations;
5260
$this->connection = $connection;
5361
}
@@ -62,4 +70,23 @@ public function useCollectionClass(?string $collectionClass)
6270
$this->collectionClass = $collectionClass;
6371
return $this;
6472
}
73+
/**
74+
* Get the fully-qualified class name of the Model.
75+
*
76+
* @return class-string<\Illuminate\Database\Eloquent\Model>|null
77+
*/
78+
public function getClass(): ?string
79+
{
80+
if ($this->class === null) {
81+
return null;
82+
}
83+
return Relation::getMorphedModel($this->class) ?? $this->class;
84+
}
85+
/**
86+
* Indicate whether to use the relational morph-map when serializing Models.
87+
*/
88+
public static function useMorphMap(bool $useMorphMap = \true): void
89+
{
90+
static::$useMorphMap = $useMorphMap;
91+
}
6592
}

vendor/rector/extension-installer/src/GeneratedConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
final class GeneratedConfig
1111
{
12-
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 46e4f77'), '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 a110e2f'), '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 9cae00e'), '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 eadb590'));
12+
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 46e4f77'), '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 a110e2f'), '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 5617724'), '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 eadb590'));
1313
private function __construct()
1414
{
1515
}

vendor/rector/rector-phpunit/config/sets/phpunit-code-quality.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
use Rector\PHPUnit\CodeQuality\Rector\Class_\TestWithToDataProviderRector;
1717
use Rector\PHPUnit\CodeQuality\Rector\Class_\TypeWillReturnCallableArrowFunctionRector;
1818
use Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector;
19+
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableArgumentRector;
1920
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableInstanceRector;
2021
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\BareCreateMockAssignToDirectUseRector;
2122
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\DataProviderArrayItemsNewLinedRector;
2223
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\EntityDocumentCreateMockToDirectNewRector;
2324
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\NoSetupWithParentCallOverrideRector;
2425
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\RemoveEmptyTestMethodRector;
26+
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\RemoveStandaloneCreateMockRector;
2527
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\ReplaceTestAnnotationWithPrefixedFunctionRector;
2628
use Rector\PHPUnit\CodeQuality\Rector\Expression\AssertArrayCastedObjectToAssertSameRector;
2729
use Rector\PHPUnit\CodeQuality\Rector\Foreach_\SimplifyForeachInstanceOfRector;
@@ -102,7 +104,7 @@
102104
// avoid call on nullable object
103105
AddInstanceofAssertForNullableInstanceRector::class,
104106
// enable next after testing
105-
// \Rector\PHPUnit\CodeQuality\Rector\ClassMethod\AddInstanceofAssertForNullableArgumentRector::class,
107+
AddInstanceofAssertForNullableArgumentRector::class,
106108
AssertArrayCastedObjectToAssertSameRector::class,
107109
/**
108110
* Improve direct testing of your code, without mock creep. Make it simple, clear and easy to maintain:
@@ -134,7 +136,9 @@
134136
EntityDocumentCreateMockToDirectNewRector::class,
135137
ReplaceAtMethodWithDesiredMatcherRector::class,
136138
BareCreateMockAssignToDirectUseRector::class,
139+
// dead code
137140
RemoveNeverUsedMockPropertyRector::class,
141+
RemoveStandaloneCreateMockRector::class,
138142
// readability
139143
NoSetupWithParentCallOverrideRector::class,
140144
]);
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
3+
declare (strict_types=1);
4+
namespace Rector\PHPUnit\CodeQuality\Rector\ClassMethod;
5+
6+
use PhpParser\Node;
7+
use PhpParser\Node\Expr\MethodCall;
8+
use PhpParser\Node\Stmt\ClassMethod;
9+
use PhpParser\Node\Stmt\Expression;
10+
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;
11+
use Rector\Rector\AbstractRector;
12+
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
13+
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
14+
/**
15+
* @see \Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\RemoveStandaloneCreateMockRector\RemoveStandaloneCreateMockRectorTest
16+
*/
17+
final class RemoveStandaloneCreateMockRector extends AbstractRector
18+
{
19+
/**
20+
* @readonly
21+
*/
22+
private TestsNodeAnalyzer $testsNodeAnalyzer;
23+
public function __construct(TestsNodeAnalyzer $testsNodeAnalyzer)
24+
{
25+
$this->testsNodeAnalyzer = $testsNodeAnalyzer;
26+
}
27+
public function getRuleDefinition(): RuleDefinition
28+
{
29+
return new RuleDefinition('Remove standalone method calls with no effect', [new CodeSample(<<<'CODE_SAMPLE'
30+
use PHPUnit\Framework\TestCase;
31+
32+
final class SomeTest extends TestCase
33+
{
34+
public function test()
35+
{
36+
$this->createMock('SomeClass');
37+
}
38+
}
39+
CODE_SAMPLE
40+
, <<<'CODE_SAMPLE'
41+
use PHPUnit\Framework\TestCase;
42+
43+
final class SomeTest extends TestCase
44+
{
45+
public function test()
46+
{
47+
}
48+
}
49+
CODE_SAMPLE
50+
)]);
51+
}
52+
/**
53+
* @return array<class-string<Node>>
54+
*/
55+
public function getNodeTypes(): array
56+
{
57+
return [ClassMethod::class];
58+
}
59+
/**
60+
* @param ClassMethod $node
61+
*/
62+
public function refactor(Node $node): ?Node
63+
{
64+
if (!$this->testsNodeAnalyzer->isInTestClass($node)) {
65+
return null;
66+
}
67+
$hasChanged = \false;
68+
foreach ((array) $node->stmts as $key => $stmt) {
69+
if (!$stmt instanceof Expression) {
70+
continue;
71+
}
72+
if (!$stmt->expr instanceof MethodCall) {
73+
continue;
74+
}
75+
$topmostCall = $this->resolveTopmostCall($stmt->expr);
76+
if (!$this->isName($topmostCall->name, 'createMock')) {
77+
continue;
78+
}
79+
unset($node->stmts[$key]);
80+
$hasChanged = \true;
81+
}
82+
if ($hasChanged) {
83+
return $node;
84+
}
85+
return null;
86+
}
87+
private function resolveTopmostCall(MethodCall $methodCall): MethodCall
88+
{
89+
$currentMethodCall = $methodCall;
90+
while ($currentMethodCall->var instanceof MethodCall) {
91+
$currentMethodCall = $currentMethodCall->var;
92+
}
93+
return $currentMethodCall;
94+
}
95+
}

vendor/rector/rector-phpunit/rules/PHPUnit120/Rector/MethodCall/ExplicitMockExpectsCallRector.php

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

6-
use PhpParser\Node\Stmt\ClassMethod;
76
use PhpParser\Node;
87
use PhpParser\Node\Arg;
98
use PhpParser\Node\Expr\MethodCall;
109
use PhpParser\Node\Expr\Variable;
10+
use PhpParser\Node\Stmt\ClassMethod;
1111
use PHPStan\Type\ObjectType;
1212
use Rector\PHPUnit\Enum\PHPUnitClassName;
1313
use Rector\PHPUnit\NodeAnalyzer\TestsNodeAnalyzer;

0 commit comments

Comments
 (0)