apply on self

This commit is contained in:
Tomas Votruba 2019-10-17 18:46:23 +02:00
parent 42e4454b48
commit 495ace61c6
6 changed files with 14 additions and 7 deletions

View File

@ -94,7 +94,11 @@ PHP
} }
// is suffix in the same category, e.g. "Exception/SomeException.php" // is suffix in the same category, e.g. "Exception/SomeException.php"
$expectedLocationFilePattern = sprintf('#\/%s\/.+%s#', preg_quote($groupName), preg_quote($suffixPattern)); $expectedLocationFilePattern = sprintf(
'#\/%s\/.+%s#',
preg_quote($groupName, '#'),
preg_quote($suffixPattern, '#')
);
if (Strings::match($smartFileInfo->getRealPath(), $expectedLocationFilePattern)) { if (Strings::match($smartFileInfo->getRealPath(), $expectedLocationFilePattern)) {
continue; continue;
} }

View File

@ -36,7 +36,7 @@ final class ClassAnnotationMatcher
private function isUseMatchingName(string $tag, UseUse $useUse): bool private function isUseMatchingName(string $tag, UseUse $useUse): bool
{ {
$shortName = $useUse->alias ? $useUse->alias->name : $useUse->name->getLast(); $shortName = $useUse->alias ? $useUse->alias->name : $useUse->name->getLast();
$shortNamePattern = preg_quote($shortName); $shortNamePattern = preg_quote($shortName, '#');
return (bool) Strings::match($tag, '#' . $shortNamePattern . '(\\\\[\w]+)?#i'); return (bool) Strings::match($tag, '#' . $shortNamePattern . '(\\\\[\w]+)?#i');
} }

View File

@ -5,7 +5,9 @@ declare(strict_types=1);
namespace Rector\CodeQuality\Rector\FuncCall; namespace Rector\CodeQuality\Rector\FuncCall;
use PhpParser\Node; use PhpParser\Node;
use PhpParser\Node\Arg;
use PhpParser\Node\Expr\FuncCall; use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Scalar\String_;
use Rector\Rector\AbstractRector; use Rector\Rector\AbstractRector;
use Rector\RectorDefinition\CodeSample; use Rector\RectorDefinition\CodeSample;
use Rector\RectorDefinition\RectorDefinition; use Rector\RectorDefinition\RectorDefinition;
@ -65,7 +67,7 @@ PHP
return null; return null;
} }
$node->args[1] = new Node\Arg(new Node\Scalar\String_('#')); $node->args[1] = new Arg(new String_('#'));
return $node; return $node;
} }

View File

@ -197,8 +197,8 @@ final class DocBlockNameImporter
// short with space " Type"| fqn // short with space " Type"| fqn
$shortNameOrFullyQualifiedNamePattern = sprintf( $shortNameOrFullyQualifiedNamePattern = sprintf(
'#(\s%s\b|\b%s\b)#', '#(\s%s\b|\b%s\b)#',
preg_quote($shortenedObjectType->getShortName()), preg_quote($shortenedObjectType->getShortName(), '#'),
preg_quote($fullyQualifiedName) preg_quote($fullyQualifiedName, '#')
); );
$isShortClassUsed = (bool) Strings::match($printedClass, $shortNameOrFullyQualifiedNamePattern); $isShortClassUsed = (bool) Strings::match($printedClass, $shortNameOrFullyQualifiedNamePattern);

View File

@ -248,7 +248,7 @@ PHP
if ($methodCall->args[0]->value instanceof String_) { if ($methodCall->args[0]->value instanceof String_) {
/** @var String_ $oldString */ /** @var String_ $oldString */
$oldString = $methodCall->args[0]->value; $oldString = $methodCall->args[0]->value;
$methodCall->args[0]->value = new String_('#' . preg_quote($oldString->value) . '#'); $methodCall->args[0]->value = new String_('#' . preg_quote($oldString->value, '#') . '#');
} }
$this->newExpressions[] = $expression; $this->newExpressions[] = $expression;

View File

@ -18,4 +18,5 @@ parameters:
php_version_features: '7.1' php_version_features: '7.1'
services: services:
Rector\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector: ~ Rector\CodeQuality\Rector\FuncCall\AddPregQuoteDelimiterRector: ~
# Rector\PHPUnit\Rector\ClassMethod\AddDoesNotPerformAssertionToNonAssertingTestRector: ~