Skip to content

Commit 9406698

Browse files
committed
Updated Rector to commit 6ab5370e332a3eee88b0625d984aea9112f9a1ad
rectorphp/rector-src@6ab5370 [CodingStyle] Deprecate EnumCaseToPascalCaseRector as risky change (#8095)
1 parent ee0052b commit 9406698

7 files changed

Lines changed: 13 additions & 145 deletions

File tree

vendor/composer/autoload_classmap.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2069,7 +2069,6 @@
20692069
'Rector\\PHPUnit\\Enum\\PHPUnitAttribute' => $vendorDir . '/rector/rector-phpunit/src/Enum/PHPUnitAttribute.php',
20702070
'Rector\\PHPUnit\\Enum\\PHPUnitClassName' => $vendorDir . '/rector/rector-phpunit/src/Enum/PHPUnitClassName.php',
20712071
'Rector\\PHPUnit\\Enum\\ProphecyClassName' => $vendorDir . '/rector/rector-phpunit/src/Enum/ProphecyClassName.php',
2072-
'Rector\\PHPUnit\\Enum\\WebmozartClassName' => $vendorDir . '/rector/rector-phpunit/src/Enum/WebmozartClassName.php',
20732072
'Rector\\PHPUnit\\MethodCallRemover' => $vendorDir . '/rector/rector-phpunit/src/MethodCallRemover.php',
20742073
'Rector\\PHPUnit\\Naming\\TestClassNameResolver' => $vendorDir . '/rector/rector-phpunit/src/Naming/TestClassNameResolver.php',
20752074
'Rector\\PHPUnit\\NodeAnalyzer\\ArgumentMover' => $vendorDir . '/rector/rector-phpunit/src/NodeAnalyzer/ArgumentMover.php',

vendor/composer/autoload_static.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2334,7 +2334,6 @@ class ComposerStaticInite7732782e781a0db6ef2f014a417d492
23342334
'Rector\\PHPUnit\\Enum\\PHPUnitAttribute' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Enum/PHPUnitAttribute.php',
23352335
'Rector\\PHPUnit\\Enum\\PHPUnitClassName' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Enum/PHPUnitClassName.php',
23362336
'Rector\\PHPUnit\\Enum\\ProphecyClassName' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Enum/ProphecyClassName.php',
2337-
'Rector\\PHPUnit\\Enum\\WebmozartClassName' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Enum/WebmozartClassName.php',
23382337
'Rector\\PHPUnit\\MethodCallRemover' => __DIR__ . '/..' . '/rector/rector-phpunit/src/MethodCallRemover.php',
23392338
'Rector\\PHPUnit\\Naming\\TestClassNameResolver' => __DIR__ . '/..' . '/rector/rector-phpunit/src/Naming/TestClassNameResolver.php',
23402339
'Rector\\PHPUnit\\NodeAnalyzer\\ArgumentMover' => __DIR__ . '/..' . '/rector/rector-phpunit/src/NodeAnalyzer/ArgumentMover.php',

vendor/composer/installed.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,12 +1802,12 @@
18021802
"source": {
18031803
"type": "git",
18041804
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
1805-
"reference": "b1f6d13de124aa4eb58923440e5a793cdb91d7f1"
1805+
"reference": "191ed98195c62df0fd02755966caff7aa3d49a9d"
18061806
},
18071807
"dist": {
18081808
"type": "zip",
1809-
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/b1f6d13de124aa4eb58923440e5a793cdb91d7f1",
1810-
"reference": "b1f6d13de124aa4eb58923440e5a793cdb91d7f1",
1809+
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/191ed98195c62df0fd02755966caff7aa3d49a9d",
1810+
"reference": "191ed98195c62df0fd02755966caff7aa3d49a9d",
18111811
"shasum": ""
18121812
},
18131813
"require": {
@@ -1835,7 +1835,7 @@
18351835
"tomasvotruba\/unused-public": "^2.2",
18361836
"tracy\/tracy": "^2.11"
18371837
},
1838-
"time": "2026-06-26T16:13:06+00:00",
1838+
"time": "2026-06-28T13:10:54+00:00",
18391839
"default-branch": true,
18401840
"type": "rector-extension",
18411841
"extra": {

vendor/composer/installed.php

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

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 2ad3644'), '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 391a44d'), '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 b1f6d13'), '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 77cc62b'));
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 2ad3644'), '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 391a44d'), '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 191ed98'), '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 77cc62b'));
1313
private function __construct()
1414
{
1515
}

vendor/rector/rector-phpunit/rules/CodeQuality/Rector/ClassMethod/BehatPHPUnitAssertToWebmozartRector.php

Lines changed: 7 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -4,93 +4,17 @@
44
namespace Rector\PHPUnit\CodeQuality\Rector\ClassMethod;
55

66
use PhpParser\Node;
7-
use PhpParser\Node\Expr\StaticCall;
8-
use PhpParser\Node\Identifier;
9-
use PhpParser\Node\Name\FullyQualified;
107
use PhpParser\Node\Stmt\ClassMethod;
11-
use PHPStan\Reflection\ReflectionProvider;
12-
use Rector\PHPStan\ScopeFetcher;
13-
use Rector\PHPUnit\Enum\BehatClassName;
14-
use Rector\PHPUnit\Enum\PHPUnitClassName;
15-
use Rector\PHPUnit\Enum\WebmozartClassName;
8+
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
9+
use Rector\Exception\ShouldNotHappenException;
1610
use Rector\Rector\AbstractRector;
1711
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
1812
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
1913
/**
20-
* @see \Rector\PHPUnit\Tests\CodeQuality\Rector\ClassMethod\BehatPHPUnitAssertToWebmozartRector\BehatPHPUnitAssertToWebmozartRectorTest
14+
* @deprecated This rule is deprecated as too narrow, it only targets Behat context files. Implement it as a custom rule instead.
2115
*/
22-
final class BehatPHPUnitAssertToWebmozartRector extends AbstractRector
16+
final class BehatPHPUnitAssertToWebmozartRector extends AbstractRector implements DeprecatedInterface
2317
{
24-
/**
25-
* @readonly
26-
*/
27-
private ReflectionProvider $reflectionProvider;
28-
/**
29-
* @var array<string, string>
30-
*/
31-
private const PHPUNIT_TO_WEBMOZART_METHODS = [
32-
// Boolean
33-
'assertTrue' => 'true',
34-
'assertFalse' => 'false',
35-
// Null / empty
36-
'assertNull' => 'null',
37-
'assertNotNull' => 'notNull',
38-
'assertEmpty' => 'isEmpty',
39-
'assertNotEmpty' => 'notEmpty',
40-
// Type checks
41-
'assertIsString' => 'string',
42-
'assertIsInt' => 'integer',
43-
'assertIsFloat' => 'float',
44-
'assertIsBool' => 'boolean',
45-
'assertIsArray' => 'isArray',
46-
'assertIsObject' => 'object',
47-
'assertIsCallable' => 'isCallable',
48-
'assertIsResource' => 'resource',
49-
'assertIsIterable' => 'isIterable',
50-
'assertInstanceOf' => 'isInstanceOf',
51-
// array
52-
'assertContains' => 'oneOf',
53-
'assertNotContains' => 'notOneOf',
54-
// Comparison / equality
55-
'assertSame' => 'same',
56-
'assertNotSame' => 'notSame',
57-
'assertEquals' => 'eq',
58-
'assertNotEquals' => 'notEq',
59-
'assertGreaterThan' => 'greaterThan',
60-
'assertGreaterThanOrEqual' => 'greaterThanEq',
61-
'assertLessThan' => 'lessThan',
62-
'assertLessThanOrEqual' => 'lessThanEq',
63-
// Strings
64-
'assertStringContainsString' => 'contains',
65-
'assertStringNotContainsString' => 'notContains',
66-
'assertStringStartsWith' => 'startsWith',
67-
'assertStringStartsNotWith' => 'notStartsWith',
68-
'assertStringEndsWith' => 'endsWith',
69-
'assertStringEndsNotWith' => 'notEndsWith',
70-
'assertMatchesRegularExpression' => 'regex',
71-
'assertDoesNotMatchRegularExpression' => 'notRegex',
72-
// Bool
73-
'assertNotTrue' => 'false',
74-
'assertNotFalse' => 'true',
75-
// Arrays / count
76-
'assertCount' => 'count',
77-
'assertArrayHasKey' => 'keyExists',
78-
'assertArrayNotHasKey' => 'keyNotExists',
79-
// Misc / less direct
80-
'assertFileExists' => 'fileExists',
81-
'assertFileIsReadable' => 'readable',
82-
'assertDirectoryExists' => 'directory',
83-
// Instance of
84-
'assertNotInstanceOf' => 'notInstanceOf',
85-
];
86-
/**
87-
* @var string[]
88-
*/
89-
private const FLIPPED_ARGS = ['assertSame', 'assertNotSame', 'assertEquals', 'assertNotEquals', 'assertGreaterThan', 'assertGreaterThanOrEqual', 'assertLessThan', 'assertLessThanOrEqual', 'assertCount', 'assertInstanceOf', 'assertNotInstanceOf', 'assertArrayHasKey', 'assertArrayNotHasKey', 'assertStringContainsString', 'assertStringStartsWith', 'assertMatchesRegularExpression', 'assertDoesNotMatchRegularExpression'];
90-
public function __construct(ReflectionProvider $reflectionProvider)
91-
{
92-
$this->reflectionProvider = $reflectionProvider;
93-
}
9418
public function getRuleDefinition(): RuleDefinition
9519
{
9620
return new RuleDefinition('Change PHPUnit assert in Behat context files to Webmozart Assert, as first require a TestCase instance', [new CodeSample(<<<'CODE_SAMPLE'
@@ -120,7 +44,7 @@ public function someMethod()
12044
)]);
12145
}
12246
/**
123-
* @return array<class-string>
47+
* @return array<class-string<Node>>
12448
*/
12549
public function getNodeTypes(): array
12650
{
@@ -129,50 +53,8 @@ public function getNodeTypes(): array
12953
/**
13054
* @param ClassMethod $node
13155
*/
132-
public function refactor(Node $node): ?ClassMethod
56+
public function refactor(Node $node): ?Node
13357
{
134-
$scope = ScopeFetcher::fetch($node);
135-
if (!$scope->isInClass()) {
136-
return null;
137-
}
138-
$classReflection = $scope->getClassReflection();
139-
if (!$classReflection->is(BehatClassName::CONTEXT)) {
140-
return null;
141-
}
142-
if (!$this->reflectionProvider->hasClass(WebmozartClassName::ASSERT)) {
143-
return null;
144-
}
145-
$hasChanged = \false;
146-
$this->traverseNodesWithCallable($node, function (Node $node) use (&$hasChanged): ?StaticCall {
147-
if (!$node instanceof StaticCall) {
148-
return null;
149-
}
150-
if (!$this->isName($node->class, PHPUnitClassName::ASSERT)) {
151-
return null;
152-
}
153-
$phpunitMethodName = $this->getName($node->name);
154-
if ($phpunitMethodName === null) {
155-
return null;
156-
}
157-
// changed method name
158-
$webmozartMethodName = self::PHPUNIT_TO_WEBMOZART_METHODS[$phpunitMethodName] ?? null;
159-
if ($webmozartMethodName === null) {
160-
return null;
161-
}
162-
if (in_array($phpunitMethodName, self::FLIPPED_ARGS, \true) && count($node->args) >= 2) {
163-
// flip first 2 args
164-
$temp = $node->args[0];
165-
$node->args[0] = $node->args[1];
166-
$node->args[1] = $temp;
167-
}
168-
$node->class = new FullyQualified(WebmozartClassName::ASSERT);
169-
$node->name = new Identifier($webmozartMethodName);
170-
$hasChanged = \true;
171-
return $node;
172-
});
173-
if (!$hasChanged) {
174-
return null;
175-
}
176-
return $node;
58+
throw new ShouldNotHappenException(sprintf('"%s" is deprecated as too narrow. Implement it as a custom rule instead.', self::class));
17759
}
17860
}

vendor/rector/rector-phpunit/src/Enum/WebmozartClassName.php

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)