diff --git a/rector.php b/rector.php index 9631fd97fd..5ee5b69f72 100644 --- a/rector.php +++ b/rector.php @@ -64,7 +64,7 @@ return static function (RectorConfig $rectorConfig): void { $rectorConfig->parallel(); // paths to refactor; solid alternative to CLI arguments - $rectorConfig->paths([__DIR__ . '/app', __DIR__ . '/system', __DIR__ . '/tests', __DIR__ . '/utils/Rector']); + $rectorConfig->paths([__DIR__ . '/app', __DIR__ . '/system', __DIR__ . '/tests', __DIR__ . '/utils']); // do you need to include constants, class aliases or custom autoloader? files listed will be executed $rectorConfig->bootstrapFiles([ diff --git a/utils/PHPStan/CheckFrameworkExceptionInstantiationViaNamedConstructorRule.php b/utils/PHPStan/CheckFrameworkExceptionInstantiationViaNamedConstructorRule.php index a2cefaddfd..5cca5ec8f4 100644 --- a/utils/PHPStan/CheckFrameworkExceptionInstantiationViaNamedConstructorRule.php +++ b/utils/PHPStan/CheckFrameworkExceptionInstantiationViaNamedConstructorRule.php @@ -22,9 +22,6 @@ use PHPStan\Rules\Rule; final class CheckFrameworkExceptionInstantiationViaNamedConstructorRule implements Rule { - /** - * @var string - */ private const ERROR_MESSAGE = 'FrameworkException instance creation via new expression is not allowed, use its named constructor instead'; public function getNodeType(): string diff --git a/utils/PHPStan/CheckUseStatementsAfterLicenseRule.php b/utils/PHPStan/CheckUseStatementsAfterLicenseRule.php index 2bcd0e20f9..a3ccaf215d 100644 --- a/utils/PHPStan/CheckUseStatementsAfterLicenseRule.php +++ b/utils/PHPStan/CheckUseStatementsAfterLicenseRule.php @@ -22,14 +22,7 @@ use PHPStan\Rules\Rule; final class CheckUseStatementsAfterLicenseRule implements Rule { - /** - * @var string - */ - private const ERROR_MESSAGE = 'Use statement must be located after license docblock'; - - /** - * @var string - */ + private const ERROR_MESSAGE = 'Use statement must be located after license docblock'; private const COPYRIGHT_REGEX = '/\* \(c\) CodeIgniter Foundation /m'; public function getNodeType(): string diff --git a/utils/check_tabs_in_rst.php b/utils/check_tabs_in_rst.php index a660aebcdc..e99d08bf76 100644 --- a/utils/check_tabs_in_rst.php +++ b/utils/check_tabs_in_rst.php @@ -11,6 +11,8 @@ declare(strict_types=1); * the LICENSE file that was distributed with this source code. */ +namespace Utils; + require __DIR__ . '/../system/Test/bootstrap.php'; use CodeIgniter\CLI\CLI; @@ -18,7 +20,7 @@ use CodeIgniter\CLI\CLI; $rstFilesWithTabs = (string) shell_exec('git grep -EIPn "\t" -- "*.rst"'); $rstFilesWithTabs = explode("\n", $rstFilesWithTabs); $rstFilesWithTabs = array_map(static function (string $line): array { - preg_match('/^(?P[^:]+):(?P[0-9]+):(?P.+)$/', $line, $matches); + preg_match('/^(?P[^:]+):(?P\d+):(?P.+)$/', $line, $matches); return [ 'file' => $matches['file'], @@ -44,20 +46,16 @@ if ($normalizedRstFilesWithTabs !== []) { "%s\n\n%s\n", CLI::color('Tabs in RST files were detected:', 'light_gray', 'red'), implode("\n", array_map( - static function (string $file, array $parts): string { - return sprintf( - "%s%s\n%s\n", - CLI::color('* in ', 'light_red'), - CLI::color($file, 'yellow'), - implode("\n", array_map(static function (array $line): string { - return sprintf( - '%s | %s', - str_pad($line['line'], 4, ' ', STR_PAD_LEFT), - str_replace("\t", CLI::color('....', 'light_gray', 'red'), $line['code']), - ); - }, $parts)), - ); - }, + static fn (string $file, array $parts): string => sprintf( + "%s%s\n%s\n", + CLI::color('* in ', 'light_red'), + CLI::color($file, 'yellow'), + implode("\n", array_map(static fn (array $line): string => sprintf( + '%s | %s', + str_pad($line['line'], 4, ' ', STR_PAD_LEFT), + str_replace("\t", CLI::color('....', 'light_gray', 'red'), $line['code']), + ), $parts)), + ), array_keys($normalizedRstFilesWithTabs), array_values($normalizedRstFilesWithTabs), )),