Updated Rector to commit c97e4ffb0534d388b5f51508491916f54d3f342a

c97e4ffb05 [Naming] Remove matchesStringName() check completely from NodeNameResolver, including endsWith() method - use getName() and compare directly instead (#4954)
This commit is contained in:
Tomas Votruba 2023-09-09 22:49:40 +00:00
parent 5ab2aa34fb
commit f73bcd4ef8
23 changed files with 77 additions and 112 deletions

View File

@ -14,17 +14,10 @@ use PHPStan\Analyser\Scope;
use Rector\CodingStyle\Naming\ClassNaming;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\NodeAnalyzer\CallAnalyzer;
use Rector\Core\Util\StringUtils;
use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
use Rector\NodeNameResolver\Regex\RegexPatternDetector;
use Rector\NodeTypeResolver\Node\AttributeKey;
final class NodeNameResolver
{
/**
* @readonly
* @var \Rector\NodeNameResolver\Regex\RegexPatternDetector
*/
private $regexPatternDetector;
/**
* @readonly
* @var \Rector\CodingStyle\Naming\ClassNaming
@ -47,9 +40,8 @@ final class NodeNameResolver
/**
* @param NodeNameResolverInterface[] $nodeNameResolvers
*/
public function __construct(RegexPatternDetector $regexPatternDetector, ClassNaming $classNaming, CallAnalyzer $callAnalyzer, iterable $nodeNameResolvers = [])
public function __construct(ClassNaming $classNaming, CallAnalyzer $callAnalyzer, iterable $nodeNameResolvers = [])
{
$this->regexPatternDetector = $regexPatternDetector;
$this->classNaming = $classNaming;
$this->callAnalyzer = $callAnalyzer;
$this->nodeNameResolvers = $nodeNameResolvers;
@ -163,23 +155,6 @@ final class NodeNameResolver
}
return $names;
}
/**
* Ends with ucname
* Starts with adjective, e.g. (Post $firstPost, Post $secondPost)
*/
public function endsWith(string $currentName, string $expectedName) : bool
{
$suffixNamePattern = '#\\w+' . \ucfirst($expectedName) . '#';
return StringUtils::isMatch($currentName, $suffixNamePattern);
}
public function startsWith(Node $node, string $prefix) : bool
{
$name = $this->getName($node);
if (!\is_string($name)) {
return \false;
}
return \strncmp($name, $prefix, \strlen($prefix)) === 0;
}
/**
* @param string|\PhpParser\Node\Name|\PhpParser\Node\Identifier|\PhpParser\Node\Stmt\ClassLike $name
*/
@ -198,21 +173,6 @@ final class NodeNameResolver
}
return \strcasecmp($resolvedName, $desiredName) === 0;
}
/**
* @param string|\PhpParser\Node\Identifier $resolvedName
*/
public function matchesStringName($resolvedName, string $desiredNamePattern) : bool
{
if ($resolvedName instanceof Identifier) {
$resolvedName = $resolvedName->toString();
}
// is probably regex pattern
if ($this->regexPatternDetector->isRegexPattern($desiredNamePattern)) {
return StringUtils::isMatch($resolvedName, $desiredNamePattern);
}
// is probably fnmatch
return \fnmatch($desiredNamePattern, $resolvedName, \FNM_NOESCAPE);
}
/**
* @param \PhpParser\Node\Expr|\PhpParser\Node\Identifier $node
*/

View File

@ -135,23 +135,23 @@ CODE_SAMPLE
}
return !$if->cond instanceof NotIdentical;
}
private function processReturnTrue(If_ $if, Return_ $nextReturnNode) : Return_
private function processReturnTrue(If_ $if, Return_ $nextReturn) : Return_
{
if ($if->cond instanceof BooleanNot && $nextReturnNode->expr instanceof Expr && $this->valueResolver->isTrue($nextReturnNode->expr)) {
if ($if->cond instanceof BooleanNot && $nextReturn->expr instanceof Expr && $this->valueResolver->isTrue($nextReturn->expr)) {
return new Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($if->cond->expr));
}
return new Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($if->cond));
}
private function processReturnFalse(If_ $if, Return_ $nextReturnNode) : ?Return_
private function processReturnFalse(If_ $if, Return_ $nextReturn) : ?Return_
{
if ($if->cond instanceof Identical) {
$notIdentical = new NotIdentical($if->cond->left, $if->cond->right);
return new Return_($this->exprBoolCaster->boolCastOrNullCompareIfNeeded($notIdentical));
}
if (!$nextReturnNode->expr instanceof Expr) {
if (!$nextReturn->expr instanceof Expr) {
return null;
}
if (!$this->valueResolver->isTrue($nextReturnNode->expr)) {
if (!$this->valueResolver->isTrue($nextReturn->expr)) {
return null;
}
if ($if->cond instanceof BooleanNot) {

View File

@ -46,6 +46,10 @@ final class ControllerClassMethodManipulator
if (!$class->extends instanceof Name) {
return \false;
}
return $this->nodeNameResolver->matchesStringName($class->extends->toString(), '#(Controller|Presenter)$#');
$parentClassName = $this->nodeNameResolver->getName($class->extends);
if (\substr_compare($parentClassName, 'Controller', -\strlen('Controller')) === 0) {
return \true;
}
return \substr_compare($parentClassName, 'Presenter', -\strlen('Presenter')) === 0;
}
}

View File

@ -32,15 +32,15 @@ final class InvertedIfFactory
* @param Expr[] $conditions
* @return If_[]
*/
public function createFromConditions(If_ $if, array $conditions, Return_ $return, ?Stmt $ifNextReturn) : array
public function createFromConditions(If_ $if, array $conditions, Return_ $return, ?Stmt $ifNextReturnStmt) : array
{
$ifs = [];
$stmt = $this->contextAnalyzer->isInLoop($if) && !$ifNextReturn instanceof Return_ ? [new Continue_()] : [$return];
if ($ifNextReturn instanceof Return_) {
$stmt[0]->setAttribute(AttributeKey::COMMENTS, $ifNextReturn->getAttribute(AttributeKey::COMMENTS));
$stmt = $this->contextAnalyzer->isInLoop($if) && !$ifNextReturnStmt instanceof Return_ ? [new Continue_()] : [$return];
if ($ifNextReturnStmt instanceof Return_) {
$stmt[0]->setAttribute(AttributeKey::COMMENTS, $ifNextReturnStmt->getAttribute(AttributeKey::COMMENTS));
}
if ($ifNextReturn instanceof Return_ && $ifNextReturn->expr instanceof Expr) {
$return->expr = $ifNextReturn->expr;
if ($ifNextReturnStmt instanceof Return_ && $ifNextReturnStmt->expr instanceof Expr) {
$return->expr = $ifNextReturnStmt->expr;
}
foreach ($conditions as $condition) {
$invertedCondition = $this->conditionInverter->createInvertedCondition($condition);

View File

@ -123,9 +123,9 @@ CODE_SAMPLE
}
return $foreach;
}
private function addInvertedIfStmtWithContinue(If_ $nestedIfWithOnlyReturn, Foreach_ $foreach) : void
private function addInvertedIfStmtWithContinue(If_ $onlyReturnIf, Foreach_ $foreach) : void
{
$invertedCondExpr = $this->conditionInverter->createInvertedCondition($nestedIfWithOnlyReturn->cond);
$invertedCondExpr = $this->conditionInverter->createInvertedCondition($onlyReturnIf->cond);
// special case
if ($invertedCondExpr instanceof BooleanNot && $invertedCondExpr->expr instanceof BooleanAnd) {
$leftExpr = $this->negateOrDeNegate($invertedCondExpr->expr->left);
@ -135,14 +135,14 @@ CODE_SAMPLE
return;
}
// should skip for weak inversion
if ($this->isBooleanOrWithWeakComparison($nestedIfWithOnlyReturn->cond)) {
$foreach->stmts[] = $nestedIfWithOnlyReturn;
if ($this->isBooleanOrWithWeakComparison($onlyReturnIf->cond)) {
$foreach->stmts[] = $onlyReturnIf;
return;
}
$nestedIfWithOnlyReturn->setAttribute(AttributeKey::ORIGINAL_NODE, null);
$nestedIfWithOnlyReturn->cond = $invertedCondExpr;
$nestedIfWithOnlyReturn->stmts = [new Continue_()];
$foreach->stmts[] = $nestedIfWithOnlyReturn;
$onlyReturnIf->setAttribute(AttributeKey::ORIGINAL_NODE, null);
$onlyReturnIf->cond = $invertedCondExpr;
$onlyReturnIf->stmts = [new Continue_()];
$foreach->stmts[] = $onlyReturnIf;
}
/**
* Matches:

View File

@ -178,21 +178,21 @@ CODE_SAMPLE
* @param Stmt[] $afters
* @return Stmt[]
*/
private function processReplaceIfs(If_ $if, array $conditions, Return_ $ifNextReturnClone, array $afters, ?Stmt $nextStmt) : array
private function processReplaceIfs(If_ $if, array $conditions, Return_ $ifNextReturn, array $afters, ?Stmt $nextStmt) : array
{
$ifs = $this->invertedIfFactory->createFromConditions($if, $conditions, $ifNextReturnClone, $nextStmt);
$ifs = $this->invertedIfFactory->createFromConditions($if, $conditions, $ifNextReturn, $nextStmt);
$this->mirrorComments($ifs[0], $if);
$result = \array_merge($ifs, $afters);
if ($if->stmts[0] instanceof Return_) {
return $result;
}
if (!$ifNextReturnClone->expr instanceof Expr) {
if (!$ifNextReturn->expr instanceof Expr) {
return $result;
}
if ($this->contextAnalyzer->isInLoop($if)) {
return $result;
}
return \array_merge($result, [$ifNextReturnClone]);
return \array_merge($result, [$ifNextReturn]);
}
private function shouldSkip(If_ $if, ?Stmt $nexStmt) : bool
{

View File

@ -129,9 +129,9 @@ CODE_SAMPLE
/**
* @return If_[]
*/
private function createStandaloneIfsWithReturn(If_ $nestedIfWithOnlyReturn, Return_ $return) : array
private function createStandaloneIfsWithReturn(If_ $onlyReturnIf, Return_ $return) : array
{
$invertedCondExpr = $this->conditionInverter->createInvertedCondition($nestedIfWithOnlyReturn->cond);
$invertedCondExpr = $this->conditionInverter->createInvertedCondition($onlyReturnIf->cond);
// special case
if ($invertedCondExpr instanceof BooleanNot && $invertedCondExpr->expr instanceof BooleanAnd) {
$booleanNotPartIf = new If_(new BooleanNot($invertedCondExpr->expr->left));
@ -140,8 +140,8 @@ CODE_SAMPLE
$secondBooleanNotPartIf->stmts = [clone $return];
return [$booleanNotPartIf, $secondBooleanNotPartIf];
}
$nestedIfWithOnlyReturn->cond = $invertedCondExpr;
$nestedIfWithOnlyReturn->stmts = [$return];
return [$nestedIfWithOnlyReturn];
$onlyReturnIf->cond = $invertedCondExpr;
$onlyReturnIf->stmts = [$return];
return [$onlyReturnIf];
}
}

View File

@ -75,9 +75,9 @@ final class MatchPropertyTypeExpectedNameResolver
if (!$expectedName instanceof ExpectedName) {
return null;
}
$propertyName = $this->nodeNameResolver->getName($property);
// skip if already has suffix
$currentName = $this->nodeNameResolver->getName($property);
if ($this->nodeNameResolver->endsWith($currentName, $expectedName->getName())) {
if (\substr_compare($propertyName, $expectedName->getName(), -\strlen($expectedName->getName())) === 0 || \substr_compare($propertyName, \ucfirst($expectedName->getName()), -\strlen(\ucfirst($expectedName->getName()))) === 0) {
return null;
}
return $expectedName->getName();

View File

@ -62,10 +62,7 @@ final class ExpectedNameResolver
}
/** @var string $currentName */
$currentName = $this->nodeNameResolver->getName($param->var);
if ($currentName === $expectedName) {
return null;
}
if ($this->nodeNameResolver->endsWith($currentName, $expectedName)) {
if ($currentName === $expectedName || \substr_compare($currentName, \ucfirst($expectedName), -\strlen(\ucfirst($expectedName))) === 0) {
return null;
}
return $expectedName;

View File

@ -153,7 +153,7 @@ CODE_SAMPLE
if ($this->nodeNameResolver->isStringName($classLikeName, $classToSkip)) {
return \true;
}
if ($this->nodeNameResolver->matchesStringName($classLikeName, $classToSkip)) {
if (\fnmatch($classToSkip, $classLikeName, \FNM_NOESCAPE)) {
return \true;
}
}

View File

@ -104,7 +104,9 @@ CODE_SAMPLE
private function shouldSkipClassMethod(ClassMethod $classMethod) : bool
{
// edge case in nette framework
if ($this->nodeNameResolver->startsWith($classMethod->name, 'createComponent')) {
/** @var string $methodName */
$methodName = $this->getName($classMethod->name);
if (\strncmp($methodName, 'createComponent', \strlen('createComponent')) === 0) {
return \true;
}
return !$classMethod->isProtected();

View File

@ -10,6 +10,7 @@ use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Interface_;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ClassReflection;
@ -164,7 +165,7 @@ CODE_SAMPLE
/**
* @param \PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Interface_ $classOrInterface
*/
private function shouldSkipRename(string $methodName, Node\Stmt\ClassMethod $classMethod, MethodCallRenameInterface $methodCallRename, ClassReflection $classReflection, $classOrInterface) : bool
private function shouldSkipRename(string $methodName, ClassMethod $classMethod, MethodCallRenameInterface $methodCallRename, ClassReflection $classReflection, $classOrInterface) : bool
{
if (!$this->nodeNameResolver->isStringName($methodName, $methodCallRename->getOldMethod())) {
return \true;
@ -175,10 +176,7 @@ CODE_SAMPLE
if ($this->shouldKeepForParentInterface($methodCallRename, $classReflection)) {
return \true;
}
if ($this->hasClassNewClassMethod($classOrInterface, $methodCallRename)) {
return \true;
}
return \false;
return $this->hasClassNewClassMethod($classOrInterface, $methodCallRename);
}
/**
* @param \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall $call

View File

@ -135,7 +135,7 @@ CODE_SAMPLE
if ($this->nodeNameResolver->isStringName($className, $transformOnNamespace)) {
continue;
}
if (!$this->nodeNameResolver->matchesStringName($className, $transformOnNamespace)) {
if (!\fnmatch($transformOnNamespace, $className, \FNM_NOESCAPE)) {
return \true;
}
}

View File

@ -208,9 +208,9 @@ CODE_SAMPLE
/**
* @return \PHPStan\Type\MixedType|\PHPStan\Type\Constant\ConstantArrayType
*/
private function getTypeFromClassMethodYield(Array_ $classMethodYieldArrayNode)
private function getTypeFromClassMethodYield(Array_ $classMethodYieldArray)
{
$arrayType = $this->nodeTypeResolver->getType($classMethodYieldArrayNode);
$arrayType = $this->nodeTypeResolver->getType($classMethodYieldArray);
// impossible to resolve
if (!$arrayType instanceof ConstantArrayType) {
return new MixedType();

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '416e52ad9e2164bc7d8e11518e3c0165862cb1b3';
public const PACKAGE_VERSION = 'c97e4ffb0534d388b5f51508491916f54d3f342a';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-09-10 01:18:37';
public const RELEASE_DATE = '2023-09-09 22:47:06';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

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

View File

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

View File

@ -1872,12 +1872,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
"reference": "f07d7f02e44488a9b022c561623686c460e62002"
"reference": "d163fa907e8f2c48656565bcb1647403a3368141"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/f07d7f02e44488a9b022c561623686c460e62002",
"reference": "f07d7f02e44488a9b022c561623686c460e62002",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/d163fa907e8f2c48656565bcb1647403a3368141",
"reference": "d163fa907e8f2c48656565bcb1647403a3368141",
"shasum": ""
},
"require": {
@ -1907,7 +1907,7 @@
"tomasvotruba\/unused-public": "^0.3",
"tracy\/tracy": "^2.10"
},
"time": "2023-09-09T14:19:47+00:00",
"time": "2023-09-09T22:25:34+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {
@ -1943,12 +1943,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "b9303b57a4076721d9f83f1ab75e3949c66e7fad"
"reference": "d4f8c9dd6750fe31362d2f93412ed53bd0ff726c"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/b9303b57a4076721d9f83f1ab75e3949c66e7fad",
"reference": "b9303b57a4076721d9f83f1ab75e3949c66e7fad",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/d4f8c9dd6750fe31362d2f93412ed53bd0ff726c",
"reference": "d4f8c9dd6750fe31362d2f93412ed53bd0ff726c",
"shasum": ""
},
"require": {
@ -1981,7 +1981,7 @@
"tomasvotruba\/unused-public": "^0.2",
"tracy\/tracy": "^2.10"
},
"time": "2023-09-09T14:18:29+00:00",
"time": "2023-09-09T22:24:42+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' => NULL, 'version' => 'dev-main aecc9c7'), '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' => NULL, 'version' => 'dev-main fa41cc7'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main f07d7f0'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main b9303b5'));
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' => NULL, 'version' => 'dev-main aecc9c7'), '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' => NULL, 'version' => 'dev-main fa41cc7'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main d163fa9'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main d4f8c9d'));
private function __construct()
{
}

View File

@ -82,7 +82,7 @@ CODE_SAMPLE
if (!$this->isObjectType($node->var, new ObjectType('PHPUnit\\Framework\\TestCase'))) {
return null;
}
if (!$this->nodeNameResolver->startsWith($node->name, 'assert')) {
if (\strncmp($methodName, 'assert', \strlen('assert')) !== 0) {
return null;
}
$hasChanged = \true;

View File

@ -100,13 +100,17 @@ CODE_SAMPLE
}
private function processMethodCall(MethodCall $methodCall) : ?\PhpParser\Node\Expr\CallLike
{
if ($this->nodeNameResolver->startsWith($methodCall->name, 'assert')) {
$methodCallName = $this->nodeNameResolver->getName($methodCall->name);
if (!\is_string($methodCallName)) {
return null;
}
if (\strncmp($methodCallName, 'assert', \strlen('assert')) === 0) {
return $this->processAssertMethodCall($methodCall);
}
if ($this->isName($methodCall->name, 'redirect')) {
if ($methodCallName === 'redirect') {
return $this->processRedirectMethodCall($methodCall);
}
if (!$this->isName($methodCall->name, 'setStatusCode')) {
if ($methodCallName !== 'setStatusCode') {
return null;
}
if (!$this->isObjectType($methodCall->var, $this->responseObjectType)) {