diff --git a/composer.json b/composer.json index 9242423..87d66a1 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,7 @@ "friendsofphp/php-cs-fixer": ">=3.59.3" }, "require-dev": { + "friendsofphp/php-cs-fixer": "^3.60", "phpspec/phpspec": "^7.0", "sebastian/diff": "^4.0", "twig/twig": "^3.3", diff --git a/src/PedroTroller/CS/Fixer/AbstractFixer.php b/src/PedroTroller/CS/Fixer/AbstractFixer.php index d2d8b74..eecec51 100644 --- a/src/PedroTroller/CS/Fixer/AbstractFixer.php +++ b/src/PedroTroller/CS/Fixer/AbstractFixer.php @@ -23,7 +23,7 @@ public function isCandidate(Tokens $tokens): bool public function getName(): string { - return sprintf('PedroTroller/%s', parent::getName()); + return \sprintf('PedroTroller/%s', parent::getName()); } /** diff --git a/src/PedroTroller/CS/Fixer/ClassNotation/OrderedWithGetterAndSetterFirstFixer.php b/src/PedroTroller/CS/Fixer/ClassNotation/OrderedWithGetterAndSetterFirstFixer.php index 10552ea..dca0e9a 100644 --- a/src/PedroTroller/CS/Fixer/ClassNotation/OrderedWithGetterAndSetterFirstFixer.php +++ b/src/PedroTroller/CS/Fixer/ClassNotation/OrderedWithGetterAndSetterFirstFixer.php @@ -152,11 +152,11 @@ private function getMethodsNames(array $elements): array $methods = []; foreach ($this->getPropertiesNames($elements) as $name) { - $methods[] = sprintf('get%s', ucfirst($name)); - $methods[] = sprintf('is%s', ucfirst($name)); - $methods[] = sprintf('has%s', ucfirst($name)); + $methods[] = \sprintf('get%s', ucfirst($name)); + $methods[] = \sprintf('is%s', ucfirst($name)); + $methods[] = \sprintf('has%s', ucfirst($name)); $methods[] = lcfirst($name); - $methods[] = sprintf('set%s', ucfirst($name)); + $methods[] = \sprintf('set%s', ucfirst($name)); } return $methods; diff --git a/src/PedroTroller/CS/Fixer/CodingStyle/ExceptionsPunctuationFixer.php b/src/PedroTroller/CS/Fixer/CodingStyle/ExceptionsPunctuationFixer.php index c2a0add..a8c447e 100644 --- a/src/PedroTroller/CS/Fixer/CodingStyle/ExceptionsPunctuationFixer.php +++ b/src/PedroTroller/CS/Fixer/CodingStyle/ExceptionsPunctuationFixer.php @@ -152,6 +152,6 @@ private function cleanupMessage(Token $token): Token return $token; } - return new Token([T_CONSTANT_ENCAPSED_STRING, sprintf('%s%s.%s', $quotes, implode('', $chars), $quotes)]); + return new Token([T_CONSTANT_ENCAPSED_STRING, \sprintf('%s%s.%s', $quotes, implode('', $chars), $quotes)]); } } diff --git a/src/PedroTroller/CS/Fixer/CodingStyle/ForbiddenFunctionsFixer.php b/src/PedroTroller/CS/Fixer/CodingStyle/ForbiddenFunctionsFixer.php index c0113ce..868b89e 100644 --- a/src/PedroTroller/CS/Fixer/CodingStyle/ForbiddenFunctionsFixer.php +++ b/src/PedroTroller/CS/Fixer/CodingStyle/ForbiddenFunctionsFixer.php @@ -89,7 +89,7 @@ protected function applyFix(SplFileInfo $file, Tokens $tokens): void if (\in_array($token->getContent(), $this->configuration['functions'], true)) { $end = $this->analyze($tokens)->getEndOfTheLine($index); - $tokens[$end] = new Token([T_WHITESPACE, sprintf(' // %s%s', $this->configuration['comment'], $tokens[$end]->getContent())]); + $tokens[$end] = new Token([T_WHITESPACE, \sprintf(' // %s%s', $this->configuration['comment'], $tokens[$end]->getContent())]); } } } diff --git a/src/PedroTroller/CS/Fixer/Comment/CommentLineToPhpdocBlockFixer.php b/src/PedroTroller/CS/Fixer/Comment/CommentLineToPhpdocBlockFixer.php index 5e0cf3a..cedd462 100644 --- a/src/PedroTroller/CS/Fixer/Comment/CommentLineToPhpdocBlockFixer.php +++ b/src/PedroTroller/CS/Fixer/Comment/CommentLineToPhpdocBlockFixer.php @@ -153,6 +153,6 @@ private function formatComments(array $comments, string $indentation): string $comments = implode("\n", $comments); $comments = trim($comments, " \n"); - return sprintf("/**\n%s %s\n%s */", $indentation, $comments, $indentation); + return \sprintf("/**\n%s %s\n%s */", $indentation, $comments, $indentation); } } diff --git a/src/PedroTroller/CS/Fixer/DoctrineMigrationsFixer.php b/src/PedroTroller/CS/Fixer/DoctrineMigrationsFixer.php index 814756c..92b9545 100644 --- a/src/PedroTroller/CS/Fixer/DoctrineMigrationsFixer.php +++ b/src/PedroTroller/CS/Fixer/DoctrineMigrationsFixer.php @@ -19,7 +19,7 @@ final class DoctrineMigrationsFixer extends AbstractFixer implements ConfigurableFixerInterface { use ConfigurableFixerTrait; - + /** * @var string[] */ diff --git a/src/PedroTroller/CS/Fixer/PhpspecFixer.php b/src/PedroTroller/CS/Fixer/PhpspecFixer.php index 3f481a4..07ad383 100644 --- a/src/PedroTroller/CS/Fixer/PhpspecFixer.php +++ b/src/PedroTroller/CS/Fixer/PhpspecFixer.php @@ -265,7 +265,7 @@ private function filterElementsByMethodName(string $regex, array $elements): arr $filter = []; foreach ($this->filterElementsByType('method', $elements) as $index => $method) { - if (0 !== preg_match(sprintf('/^%s$/', $regex), $method['methodName'])) { + if (0 !== preg_match(\sprintf('/^%s$/', $regex), $method['methodName'])) { $filter[$index] = $method; } } diff --git a/src/PedroTroller/CS/Fixer/TokensAnalyzer.php b/src/PedroTroller/CS/Fixer/TokensAnalyzer.php index f356f96..d80b50b 100644 --- a/src/PedroTroller/CS/Fixer/TokensAnalyzer.php +++ b/src/PedroTroller/CS/Fixer/TokensAnalyzer.php @@ -186,7 +186,7 @@ public function getNextSemiColon($index) public function getReturnedType($index) { if (false === $this->tokens[$index]->isGivenKind(T_FUNCTION)) { - throw new Exception(sprintf('Expected token: T_FUNCTION Token %d id contains %s.', $index, $this->tokens[$index]->getContent())); + throw new Exception(\sprintf('Expected token: T_FUNCTION Token %d id contains %s.', $index, $this->tokens[$index]->getContent())); } $methodName = $this->tokens->getNextMeaningfulToken($index); @@ -317,7 +317,7 @@ public function endOfTheStatement(int $index): ?int public function getClosingParenthesis($index) { if ('(' !== $this->tokens[$index]->getContent()) { - throw new Exception(sprintf('Expected token: (. Token %d id contains %s.', $index, $this->tokens[$index]->getContent())); + throw new Exception(\sprintf('Expected token: (. Token %d id contains %s.', $index, $this->tokens[$index]->getContent())); } for ($i = $index + 1; $i < $this->tokens->count(); ++$i) { @@ -345,7 +345,7 @@ public function getClosingParenthesis($index) public function getClosingBracket($index) { if ('[' !== $this->tokens[$index]->getContent()) { - throw new Exception(sprintf('Expected token: [. Token %d id contains %s.', $index, $this->tokens[$index]->getContent())); + throw new Exception(\sprintf('Expected token: [. Token %d id contains %s.', $index, $this->tokens[$index]->getContent())); } for ($i = $index + 1; $i < $this->tokens->count(); ++$i) { @@ -373,7 +373,7 @@ public function getClosingBracket($index) public function getClosingCurlyBracket($index) { if ('{' !== $this->tokens[$index]->getContent()) { - throw new Exception(sprintf('Expected token: {. Token %d id contains %s.', $index, $this->tokens[$index]->getContent())); + throw new Exception(\sprintf('Expected token: {. Token %d id contains %s.', $index, $this->tokens[$index]->getContent())); } for ($i = $index + 1; $i < $this->tokens->count(); ++$i) { @@ -401,7 +401,7 @@ public function getClosingCurlyBracket($index) public function getClosingAttribute($index) { if (false === $this->tokens[$index]->isGivenKind(T_ATTRIBUTE)) { - throw new Exception(sprintf('Expected token: T_ATTRIBUTE Token %d id contains %s.', $index, $this->tokens[$index]->getContent())); + throw new Exception(\sprintf('Expected token: T_ATTRIBUTE Token %d id contains %s.', $index, $this->tokens[$index]->getContent())); } for ($i = $index + 1; $i < $this->tokens->count(); ++$i) { diff --git a/tests/Orchestra.php b/tests/Orchestra.php index a92f807..154ee38 100644 --- a/tests/Orchestra.php +++ b/tests/Orchestra.php @@ -65,7 +65,7 @@ public static function assert(FixerInterface $fixer) */ public function before(FixerInterface $other) { - echo sprintf("\nRun %s before %s\n", $this->fixer->getName(), $other->getName()); + echo \sprintf("\nRun %s before %s\n", $this->fixer->getName(), $other->getName()); Assert::greaterThan( $this->fixer->getPriority(), @@ -80,7 +80,7 @@ public function before(FixerInterface $other) */ public function after(FixerInterface $other) { - echo sprintf("\nRun %s after %s\n", $this->fixer->getName(), $other->getName()); + echo \sprintf("\nRun %s after %s\n", $this->fixer->getName(), $other->getName()); Assert::lessThan( $this->fixer->getPriority(), diff --git a/tests/Runner.php b/tests/Runner.php index e8da806..39b5e26 100644 --- a/tests/Runner.php +++ b/tests/Runner.php @@ -19,7 +19,7 @@ public static function run(): void set_error_handler( static function ($type, $message, $file, $line) use (&$deprecations): void { - $deprecations[$message][] = sprintf('%s at line %d', $file, $line); + $deprecations[$message][] = \sprintf('%s at line %d', $file, $line); $deprecations[$message] = array_unique($deprecations[$message]); sort($deprecations[$message]); @@ -35,12 +35,12 @@ static function ($type, $message, $file, $line) use (&$deprecations): void { if (false === empty($deprecations)) { ksort($deprecations); - $message = sprintf( + $message = \sprintf( "Deprecations : \n\n%s", implode( "\n\n", array_map( - static fn ($message, array $files) => sprintf("%s\n%s", $message, implode("\n", $files)), + static fn ($message, array $files) => \sprintf("%s\n%s", $message, implode("\n", $files)), array_keys($deprecations), $deprecations ) @@ -53,7 +53,7 @@ static function ($type, $message, $file, $line) use (&$deprecations): void { private static function runUseCases(): void { - $directory = sprintf('%s/UseCase', __DIR__); + $directory = \sprintf('%s/UseCase', __DIR__); $finder = new Finder(); $finder @@ -100,7 +100,7 @@ private static function runUseCases(): void private static function runAnalyzerIntegrations(): void { - $directory = sprintf('%s/TokensAnalyzerIntegration', __DIR__); + $directory = \sprintf('%s/TokensAnalyzerIntegration', __DIR__); $finder = new Finder(); $finder diff --git a/tests/TokensAnalyzerIntegration.php b/tests/TokensAnalyzerIntegration.php index 0423e15..f36c8ba 100644 --- a/tests/TokensAnalyzerIntegration.php +++ b/tests/TokensAnalyzerIntegration.php @@ -53,7 +53,7 @@ protected function tokensContaining(Tokens $tokens, $content) } if (empty($indexes)) { - throw new Exception(sprintf('There is no token containing %s.', $content)); + throw new Exception(\sprintf('There is no token containing %s.', $content)); } return $indexes; diff --git a/tests/UseCase/LineBreakBetweenMethods/Regression/Case1.php b/tests/UseCase/LineBreakBetweenMethods/Regression/Case1.php index 33d64fd..ec4f5fd 100644 --- a/tests/UseCase/LineBreakBetweenMethods/Regression/Case1.php +++ b/tests/UseCase/LineBreakBetweenMethods/Regression/Case1.php @@ -23,12 +23,12 @@ public function getFixers(): iterable public function getRawScript(): string { - return file_get_contents(sprintf('%s/Case1/CamelizeNamingStrategy.php.text', __DIR__)); + return file_get_contents(\sprintf('%s/Case1/CamelizeNamingStrategy.php.text', __DIR__)); } public function getExpectation(): string { - return file_get_contents(sprintf('%s/Case1/CamelizeNamingStrategy.php.text', __DIR__)); + return file_get_contents(\sprintf('%s/Case1/CamelizeNamingStrategy.php.text', __DIR__)); } public function getMinSupportedPhpVersion(): int diff --git a/tests/UseCase/Phpspec/Regression/Case1.php b/tests/UseCase/Phpspec/Regression/Case1.php index 946586a..bfeb45d 100644 --- a/tests/UseCase/Phpspec/Regression/Case1.php +++ b/tests/UseCase/Phpspec/Regression/Case1.php @@ -22,12 +22,12 @@ public function getFixers(): iterable public function getRawScript(): string { - return file_get_contents(sprintf('%s/Case1/file.php.txt', __DIR__)); + return file_get_contents(\sprintf('%s/Case1/file.php.txt', __DIR__)); } public function getExpectation(): string { - return file_get_contents(sprintf('%s/Case1/file.php.txt', __DIR__)); + return file_get_contents(\sprintf('%s/Case1/file.php.txt', __DIR__)); } public function getMinSupportedPhpVersion(): int diff --git a/tests/UseCase/Phpspec/Regression/Case2.php b/tests/UseCase/Phpspec/Regression/Case2.php index 782c697..5a03634 100644 --- a/tests/UseCase/Phpspec/Regression/Case2.php +++ b/tests/UseCase/Phpspec/Regression/Case2.php @@ -16,12 +16,12 @@ public function getFixers(): iterable public function getRawScript(): string { - return file_get_contents(sprintf('%s/Case2/file.php.txt', __DIR__)); + return file_get_contents(\sprintf('%s/Case2/file.php.txt', __DIR__)); } public function getExpectation(): string { - return file_get_contents(sprintf('%s/Case2/file.php.txt', __DIR__)); + return file_get_contents(\sprintf('%s/Case2/file.php.txt', __DIR__)); } public function getMinSupportedPhpVersion(): int