Skip to content

Commit

Permalink
run fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Apr 23, 2024
1 parent efb309d commit 8fe7f1d
Show file tree
Hide file tree
Showing 74 changed files with 219 additions and 219 deletions.
2 changes: 1 addition & 1 deletion src/AbstractPhpdocToTypeDeclarationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
abstract class AbstractPhpdocToTypeDeclarationFixer extends AbstractFixer implements ConfigurableFixerInterface
{
private const REGEX_CLASS = '(?:\\\\?+'.TypeExpression::REGEX_IDENTIFIER
private const REGEX_CLASS = '(?:\\\?+'.TypeExpression::REGEX_IDENTIFIER
.'(\\\\'.TypeExpression::REGEX_IDENTIFIER.')*+)';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Report/FixReport/ReporterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function registerBuiltInReporters(): self
foreach (SymfonyFinder::create()->files()->name('*Reporter.php')->in(__DIR__) as $file) {
$relativeNamespace = $file->getRelativePath();
$builtInReporters[] = sprintf(
'%s\\%s%s',
'%s\%s%s',
__NAMESPACE__,
'' !== $relativeNamespace ? $relativeNamespace.'\\' : '',
$file->getBasename('.php')
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Report/ListSetsReport/ReporterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function registerBuiltInReporters(): self
foreach (SymfonyFinder::create()->files()->name('*Reporter.php')->in(__DIR__) as $file) {
$relativeNamespace = $file->getRelativePath();
$builtInReporters[] = sprintf(
'%s\\%s%s',
'%s\%s%s',
__NAMESPACE__,
'' !== $relativeNamespace ? $relativeNamespace.'\\' : '',
$file->getBasename('.php')
Expand Down
4 changes: 2 additions & 2 deletions src/DocBlock/Line.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getContent(): string
*/
public function containsUsefulContent(): bool
{
return Preg::match('/\\*\s*\S+/', $this->content) && '' !== trim(str_replace(['/', '*'], ' ', $this->content));
return Preg::match('/\*\s*\S+/', $this->content) && '' !== trim(str_replace(['/', '*'], ' ', $this->content));
}

/**
Expand All @@ -69,7 +69,7 @@ public function containsUsefulContent(): bool
*/
public function containsATag(): bool
{
return Preg::match('/\\*\s*@/', $this->content);
return Preg::match('/\*\s*@/', $this->content);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/DocBlock/TypeExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ final class TypeExpression
(?:\.(?&constant_digits)|(?<=\d)\.)?+
(?:e[+-]?(?&constant_digits))?+
)
| \'(?:[^\'\\\\]|\\\\.)*+\'
| "(?:[^"\\\\]|\\\\.)*+"
| \'(?:[^\'\\\]|\\\.)*+\'
| "(?:[^"\\\]|\\\.)*+"
(?-i)
)
|
Expand All @@ -159,7 +159,7 @@ final class TypeExpression
)
|
(?<name> # full name, e.g.: `int`, `\DateTime`, `\Foo\Bar`, `positive-int`
\\\\?+
\\\?+
(?<identifier>'.self::REGEX_IDENTIFIER.')
(?:[\\\\\-](?&identifier))*+
)
Expand Down
4 changes: 2 additions & 2 deletions src/Doctrine/Annotation/Tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public function insertAt(int $index, Token $token): void
public function offsetSet($index, $token): void
{
if (null === $token) {
throw new \InvalidArgumentException('Token must be an instance of PhpCsFixer\\Doctrine\\Annotation\\Token, "null" given.');
throw new \InvalidArgumentException('Token must be an instance of PhpCsFixer\Doctrine\Annotation\Token, "null" given.');
}

if (!$token instanceof Token) {
Expand All @@ -256,7 +256,7 @@ public function offsetSet($index, $token): void
$type = \get_class($token);
}

throw new \InvalidArgumentException(sprintf('Token must be an instance of PhpCsFixer\\Doctrine\\Annotation\\Token, "%s" given.', $type));
throw new \InvalidArgumentException(sprintf('Token must be an instance of PhpCsFixer\Doctrine\Annotation\Token, "%s" given.', $type));
}

parent::offsetSet($index, $token);
Expand Down
2 changes: 1 addition & 1 deletion src/Documentation/DocumentationLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getFixersDocumentationIndexFilePath(): string
public function getFixerDocumentationFilePath(FixerInterface $fixer): string
{
return $this->getFixersDocumentationDirectoryPath().'/'.Preg::replaceCallback(
'/^.*\\\\(.+)\\\\(.+)Fixer$/',
'/^.*\\\(.+)\\\(.+)Fixer$/',
static fn (array $matches): string => Utils::camelCaseToUnderscore($matches[1]).'/'.Utils::camelCaseToUnderscore($matches[2]),
\get_class($fixer)
).'.rst';
Expand Down
4 changes: 2 additions & 2 deletions src/Documentation/FixerDocumentGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public function generateFixerDocumentation(FixerInterface $fixer): string
$fileName = "`{$className} <./../../../{$fileName}>`_";

$testFileName = Preg::replace('~.*\K/src/(?=Fixer/)~', '/tests/', $fileName);
$testFileName = Preg::replace('~PhpCsFixer\\\\\\\\\K(?=Fixer\\\\\\\\)~', 'Tests\\\\\\\\', $testFileName);
$testFileName = Preg::replace('~PhpCsFixer\\\\\\\\\K(?=Fixer\\\\\\\)~', 'Tests\\\\\\\\', $testFileName);
$testFileName = Preg::replace('~(?= <|\.php>)~', 'Test', $testFileName);

$doc .= <<<RST
Expand Down Expand Up @@ -317,7 +317,7 @@ public function generateFixersDocumentationIndex(array $fixers): string
$currentGroup = null;

foreach ($fixers as $fixer) {
$namespace = Preg::replace('/^.*\\\\(.+)\\\\.+Fixer$/', '$1', \get_class($fixer));
$namespace = Preg::replace('/^.*\\\(.+)\\\.+Fixer$/', '$1', \get_class($fixer));
$group = $overrideGroups[$namespace] ?? Preg::replace('/(?<=[[:lower:]])(?=[[:upper:]])/', ' ', $namespace);

if ($group !== $currentGroup) {
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Basic/NonPrintableCharacterFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
}

if ($stringTypeChanged) {
$content = Preg::replace('/(\\\\{1,2})/', '\\\\\\\\', $content);
$content = Preg::replace('/(\\\{1,2})/', '\\\\\\\\', $content);
$content = str_replace('$', '\$', $content);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Basic/PsrAutoloadingFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function supports(\SplFileInfo $file): bool
}

// ignore stubs/fixtures, since they typically contain invalid files for various reasons
return !Preg::match('{[/\\\\](stub|fixture)s?[/\\\\]}i', $file->getRealPath());
return !Preg::match('{[/\\\](stub|fixture)s?[/\\\]}i', $file->getRealPath());
}

protected function createConfigurationDefinition(): FixerConfigurationResolverInterface
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/ClassNotation/OrderedTypesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ private function collectUnionOrIntersectionTypes(string $type): array
*/
private function runTypesThroughSortingAlgorithm(array $types): array
{
$normalizeType = static fn (string $type): string => Preg::replace('/^\\\\?/', '', $type);
$normalizeType = static fn (string $type): string => Preg::replace('/^\\\?/', '', $type);

usort($types, function ($a, $b) use ($normalizeType): int {
if (\is_array($a)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/ClassNotation/SelfAccessorFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private function getClassStart(Tokens $tokens, int $index, string $namespace): ?
{
$namespace = ('' !== $namespace ? '\\'.$namespace : '').'\\';

foreach (array_reverse(Preg::split('/(\\\\)/', $namespace, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)) as $piece) {
foreach (array_reverse(Preg::split('/(\\\)/', $namespace, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)) as $piece) {

Check warning on line 187 in src/Fixer/ClassNotation/SelfAccessorFixer.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 mutation tests

Escaped Mutant for Mutator "IncrementInteger": --- Original +++ New @@ @@ private function getClassStart(Tokens $tokens, int $index, string $namespace) : ?int { $namespace = ('' !== $namespace ? '\\' . $namespace : '') . '\\'; - foreach (array_reverse(Preg::split('/(\\\\)/', $namespace, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)) as $piece) { + foreach (array_reverse(Preg::split('/(\\\\)/', $namespace, -0, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)) as $piece) { $index = $tokens->getPrevMeaningfulToken($index); if ('\\' === $piece) { if (!$tokens[$index]->isGivenKind(T_NS_SEPARATOR)) {
$index = $tokens->getPrevMeaningfulToken($index);
if ('\\' === $piece) {
if (!$tokens[$index]->isGivenKind(T_NS_SEPARATOR)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Comment/CommentToPhpdocFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function (bool $carry, int $index) use ($tokens): bool {
if ($carry) {
return true;
}
if (!Preg::match('~(?:#|//|/\*+|\R(?:\s*\*)?)\s*\@([a-zA-Z0-9_\\\\-]+)(?=\s|\(|$)~', $tokens[$index]->getContent(), $matches)) {
if (!Preg::match('~(?:#|//|/\*+|\R(?:\s*\*)?)\s*\@([a-zA-Z0-9_\\\-]+)(?=\s|\(|$)~', $tokens[$index]->getContent(), $matches)) {
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/Comment/MultilineCommentOpeningClosingFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void

// Fix opening
if ($token->isGivenKind(T_COMMENT)) {
$newContent = Preg::replace('/^\\/\\*{2,}(?!\\/)/', '/*', $newContent);
$newContent = Preg::replace('/^\/\*{2,}(?!\/)/', '/*', $newContent);
}

// Fix closing
$newContent = Preg::replace('/(?<!\\/)\\*{2,}\\/$/', '*/', $newContent);
$newContent = Preg::replace('/(?<!\/)\*{2,}\/$/', '*/', $newContent);

if ($newContent !== $originalContent) {
$tokens[$index] = new Token([$token->getId(), $newContent]);
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Import/FullyQualifiedStrictTypesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
final class FullyQualifiedStrictTypesFixer extends AbstractFixer implements ConfigurableFixerInterface, WhitespacesAwareFixerInterface
{
private const REGEX_CLASS = '(?:\\\\?+'.TypeExpression::REGEX_IDENTIFIER
private const REGEX_CLASS = '(?:\\\?+'.TypeExpression::REGEX_IDENTIFIER
.'(\\\\'.TypeExpression::REGEX_IDENTIFIER.')*+)';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Import/NoUnusedImportsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private function isImportUsed(Tokens $tokens, NamespaceAnalysis $namespace, Name

if ($token->isComment()
&& Preg::match(
'/(?<![[:alnum:]\$])(?<!\\\\)'.$import->getShortName().'(?![[:alnum:]])/i',
'/(?<![[:alnum:]\$])(?<!\\\)'.$import->getShortName().'(?![[:alnum:]])/i',
$token->getContent()
)
) {
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/NamespaceNotation/CleanNamespaceFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function getDefinition(): FixerDefinitionInterface
{
$samples = [];

foreach (['namespace Foo \\ Bar;', 'echo foo /* comment */ \\ bar();'] as $sample) {
foreach (['namespace Foo \ Bar;', 'echo foo /* comment */ \ bar();'] as $sample) {

Check warning on line 30 in src/Fixer/NamespaceNotation/CleanNamespaceFixer.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 mutation tests

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ public function getDefinition() : FixerDefinitionInterface { $samples = []; - foreach (['namespace Foo \\ Bar;', 'echo foo /* comment */ \\ bar();'] as $sample) { + foreach (['echo foo /* comment */ \\ bar();'] as $sample) { $samples[] = new VersionSpecificCodeSample("<?php\n" . $sample . "\n", new VersionSpecification(null, 80000 - 1)); } return new FixerDefinition('Namespace must not contain spacing, comments or PHPDoc.', $samples);
$samples[] = new VersionSpecificCodeSample(
"<?php\n".$sample."\n",
new VersionSpecification(null, 8_00_00 - 1)
Expand Down
6 changes: 3 additions & 3 deletions src/Fixer/PhpUnit/PhpUnitAttributesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private static function fixWithoutParameters(Tokens $tokens, int $index, Annotat
private static function fixWithSingleStringValue(Tokens $tokens, int $index, Annotation $annotation): array
{
Preg::match(
sprintf('/@%s\s+(.*\S)(?:\R|\s*\*+\\/$)/', $annotation->getTag()->getName()),
sprintf('/@%s\s+(.*\S)(?:\R|\s*\*+\/$)/', $annotation->getTag()->getName()),
$annotation->getContent(),
$matches,
);
Expand Down Expand Up @@ -427,7 +427,7 @@ private static function fixUses(Tokens $tokens, int $index, Annotation $annotati
if (str_starts_with($matches[1], '::')) {
$attributeName = 'UsesFunction';
$attributeTokens = [self::createEscapedStringToken(substr($matches[1], 2))];
} elseif (Preg::match('/^[a-zA-Z\d\\\\]+$/', $matches[1])) {
} elseif (Preg::match('/^[a-zA-Z\d\\\]+$/', $matches[1])) {
$attributeName = 'UsesClass';
$attributeTokens = self::toClassConstant($matches[1]);
} else {
Expand All @@ -443,7 +443,7 @@ private static function fixUses(Tokens $tokens, int $index, Annotation $annotati
private static function getMatches(Annotation $annotation): array
{
Preg::match(
sprintf('/@%s\s+(\S+)(?:\s+(\S+))?(?:\s+(.+\S))?\s*(?:\R|\*+\\/$)/', $annotation->getTag()->getName()),
sprintf('/@%s\s+(\S+)(?:\s+(\S+))?(?:\s+(.+\S))?\s*(?:\R|\*+\/$)/', $annotation->getTag()->getName()),
$annotation->getContent(),
$matches,
);
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/PhpUnit/PhpUnitFqcnAnnotationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private function fixPhpUnitClass(Tokens $tokens, int $startIndex, int $endIndex)
if ($tokens[$index]->isGivenKind(T_DOC_COMMENT)) {
$tokens[$index] = new Token([T_DOC_COMMENT, Preg::replace(
'~^(\s*\*\s*@(?:expectedException|covers|coversDefaultClass|uses)\h+)(?!(?:self|static)::)(\w.*)$~m',
'$1\\\\$2',
'$1\\\$2',
$tokens[$index]->getContent()
)]);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/PhpUnit/PhpUnitMethodCasingFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ public function getDefinition(): FixerDefinitionInterface
[
new CodeSample(
'<?php
class MyTest extends \\PhpUnit\\FrameWork\\TestCase
class MyTest extends \PhpUnit\FrameWork\TestCase
{
public function test_my_code() {}
}
'
),
new CodeSample(
'<?php
class MyTest extends \\PhpUnit\\FrameWork\\TestCase
class MyTest extends \PhpUnit\FrameWork\TestCase
{
public function testMyCode() {}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/PhpUnit/PhpUnitTestAnnotationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ public function getDefinition(): FixerDefinitionInterface
'Adds or removes @test annotations from tests, following configuration.',
[
new CodeSample('<?php
class Test extends \\PhpUnit\\FrameWork\\TestCase
class Test extends \PhpUnit\FrameWork\TestCase
{
/**
* @test
*/
public function itDoesSomething() {} }'.$this->whitespacesConfig->getLineEnding()),
new CodeSample('<?php
class Test extends \\PhpUnit\\FrameWork\\TestCase
class Test extends \PhpUnit\FrameWork\TestCase
{
public function testItDoesSomething() {}}'.$this->whitespacesConfig->getLineEnding(), ['style' => 'annotation']),
],
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/PhpUnit/PhpUnitTestClassRequiresCoversFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ protected function applyPhpUnitClassFix(Tokens $tokens, int $startIndex, int $en
'coversNothing',
],
[
'phpunit\\framework\\attributes\\coversclass',
'phpunit\\framework\\attributes\\coversnothing',
'phpunit\framework\attributes\coversclass',
'phpunit\framework\attributes\coversnothing',
],
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Phpdoc/PhpdocListTypeFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,6 @@ public function getPriority(): int

protected function normalize(string $type): string
{
return Preg::replace('/array(?=<(?:[^,<]|<[^>]+>)+(>|{|\\())/i', 'list', $type);
return Preg::replace('/array(?=<(?:[^,<]|<[^>]+>)+(>|{|\())/i', 'list', $type);
}
}
2 changes: 1 addition & 1 deletion src/Fixer/Phpdoc/PhpdocSeparationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ private function shouldBeTogether(Annotation $first, Annotation $second, array $

private function tagName(Annotation $annotation): ?string
{
Preg::match('/@([a-zA-Z0-9_\\\\-]+(?=\s|$|\())/', $annotation->getContent(), $matches);
Preg::match('/@([a-zA-Z0-9_\\\-]+(?=\s|$|\())/', $annotation->getContent(), $matches);

return $matches[1] ?? null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Phpdoc/PhpdocToCommentFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
continue;
}

if (0 < Preg::matchAll('~\@([a-zA-Z0-9_\\\\-]+)\b~', $token->getContent(), $matches)) {
if (0 < Preg::matchAll('~\@([a-zA-Z0-9_\\\-]+)\b~', $token->getContent(), $matches)) {

Check warning on line 161 in src/Fixer/Phpdoc/PhpdocToCommentFixer.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 mutation tests

Escaped Mutant for Mutator "LessThan": --- Original +++ New @@ @@ if ($commentsAnalyzer->isBeforeStructuralElement($tokens, $index)) { continue; } - if (0 < Preg::matchAll('~\\@([a-zA-Z0-9_\\\\-]+)\\b~', $token->getContent(), $matches)) { + if (0 <= Preg::matchAll('~\\@([a-zA-Z0-9_\\\\-]+)\\b~', $token->getContent(), $matches)) { foreach ($matches[1] as $match) { if (\in_array(strtolower($match), $this->ignoredTags, true)) { continue 2;
foreach ($matches[1] as $match) {
if (\in_array(strtolower($match), $this->ignoredTags, true)) {
continue 2;
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/StringNotation/HeredocToNowdocFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void

$content = $tokens[$index + 1]->getContent();
// regex: odd number of backslashes, not followed by dollar
if (Preg::match('/(?<!\\\\)(?:\\\\{2})*\\\\(?![$\\\\])/', $content)) {
if (Preg::match('/(?<!\\\)(?:\\\{2})*\\\(?![$\\\])/', $content)) {
continue;
}

$tokens[$index] = $this->convertToNowdoc($token);
$content = str_replace(['\\\\', '\\$'], ['\\', '$'], $content);
$content = str_replace(['\\\\', '\$'], ['\\', '$'], $content);
$tokens[$index + 1] = new Token([
$tokens[$index + 1]->getId(),
$content,
Expand Down
6 changes: 3 additions & 3 deletions src/Fixer/StringNotation/MultilineStringToHeredocFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ private function convertStringToHeredoc(Tokens $tokens, int $stringStartIndex, i
$content = substr($content, 1, -1);

if ($isSingleQuoted) {
$content = Preg::replace('~\\\\([\\\\\'])~', '$1', $content);
$content = Preg::replace('~\\\([\\\\\'])~', '$1', $content);
} else {
$content = Preg::replace('~(\\\\\\\\)|\\\\(")~', '$1$2', $content);
$content = Preg::replace('~(\\\\\\\)|\\\(")~', '$1$2', $content);
}

$constantStringToken = new Token([T_ENCAPSED_AND_WHITESPACE, $content."\n"]);
Expand Down Expand Up @@ -143,7 +143,7 @@ private function convertStringToHeredoc(Tokens $tokens, int $stringStartIndex, i
if ($tokens[$i]->isGivenKind(T_ENCAPSED_AND_WHITESPACE)) {
$tokens[$i] = new Token([
$tokens[$i]->getId(),
Preg::replace('~(\\\\\\\\)|\\\\(")~', '$1$2', $tokens[$i]->getContent()),
Preg::replace('~(\\\\\\\)|\\\(")~', '$1$2', $tokens[$i]->getContent()),
]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
$tokenOfStringBeforeToken = $tokens[$index - 1];
$stringContent = $tokenOfStringBeforeToken->getContent();

if (str_ends_with($stringContent, '$') && !str_ends_with($stringContent, '\\$')) {
$newContent = substr($stringContent, 0, -1).'\\$';
if (str_ends_with($stringContent, '$') && !str_ends_with($stringContent, '\$')) {
$newContent = substr($stringContent, 0, -1).'\$';
$tokenOfStringBeforeToken = new Token([T_ENCAPSED_AND_WHITESPACE, $newContent]);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/StringNotation/SingleQuoteFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
'"' === $content[0]
&& (true === $this->configuration['strings_containing_single_quote_chars'] || !str_contains($content, "'"))
// regex: odd number of backslashes, not followed by double quote or dollar
&& !Preg::match('/(?<!\\\\)(?:\\\\{2})*\\\\(?!["$\\\\])/', $content)
&& !Preg::match('/(?<!\\\)(?:\\\{2})*\\\(?!["$\\\])/', $content)
) {
$content = substr($content, 1, -1);
$content = str_replace(['\\"', '\\$', '\''], ['"', '$', '\\\''], $content);
$content = str_replace(['\"', '\$', '\''], ['"', '$', '\\\''], $content);
$tokens[$index] = new Token([T_CONSTANT_ENCAPSED_STRING, $prefix.'\''.$content.'\'']);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Whitespace/NoTrailingWhitespaceFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
continue;
}

$lines = Preg::split('/(\\R+)/', $token->getContent(), -1, PREG_SPLIT_DELIM_CAPTURE);
$lines = Preg::split('/(\R+)/', $token->getContent(), -1, PREG_SPLIT_DELIM_CAPTURE);

Check warning on line 79 in src/Fixer/Whitespace/NoTrailingWhitespaceFixer.php

View workflow job for this annotation

GitHub Actions / PHP 8.3 mutation tests

Escaped Mutant for Mutator "IncrementInteger": --- Original +++ New @@ @@ if (!$token->isWhitespace()) { continue; } - $lines = Preg::split('/(\\R+)/', $token->getContent(), -1, PREG_SPLIT_DELIM_CAPTURE); + $lines = Preg::split('/(\\R+)/', $token->getContent(), -0, PREG_SPLIT_DELIM_CAPTURE); $linesSize = \count($lines); // fix only multiline whitespaces or singleline whitespaces at the end of file if ($linesSize > 1 || !isset($tokens[$index + 1])) {
$linesSize = \count($lines);

// fix only multiline whitespaces or singleline whitespaces at the end of file
Expand Down
2 changes: 1 addition & 1 deletion src/FixerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function registerBuiltInFixers(): self
/** @var SplFileInfo $file */
foreach (SymfonyFinder::create()->files()->in(__DIR__.'/Fixer')->name('*Fixer.php')->depth(1) as $file) {
$relativeNamespace = $file->getRelativePath();
$fixerClass = 'PhpCsFixer\\Fixer\\'.('' !== $relativeNamespace ? $relativeNamespace.'\\' : '').$file->getBasename('.php');
$fixerClass = 'PhpCsFixer\Fixer\\'.('' !== $relativeNamespace ? $relativeNamespace.'\\' : '').$file->getBasename('.php');
$builtInFixers[] = $fixerClass;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Tokenizer/Analyzer/DataProviderAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
final class DataProviderAnalyzer
{
private const REGEX_CLASS = '(?:\\\\?+'.TypeExpression::REGEX_IDENTIFIER
private const REGEX_CLASS = '(?:\\\?+'.TypeExpression::REGEX_IDENTIFIER
.'(\\\\'.TypeExpression::REGEX_IDENTIFIER.')*+)';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Tokenizer/Transformers.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private function findBuiltInTransformers(): iterable
/** @var SplFileInfo $file */
foreach (Finder::create()->files()->in(__DIR__.'/Transformer') as $file) {
$relativeNamespace = $file->getRelativePath();
$class = __NAMESPACE__.'\\Transformer\\'.('' !== $relativeNamespace ? $relativeNamespace.'\\' : '').$file->getBasename('.php');
$class = __NAMESPACE__.'\Transformer\\'.('' !== $relativeNamespace ? $relativeNamespace.'\\' : '').$file->getBasename('.php');

yield new $class();
}
Expand Down

0 comments on commit 8fe7f1d

Please sign in to comment.