mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
[Rector] Apply Rector run on utils/ directory
This commit is contained in:
parent
7439b6ec51
commit
728499822f
@ -64,7 +64,7 @@ return static function (RectorConfig $rectorConfig): void {
|
|||||||
$rectorConfig->parallel();
|
$rectorConfig->parallel();
|
||||||
|
|
||||||
// paths to refactor; solid alternative to CLI arguments
|
// 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
|
// do you need to include constants, class aliases or custom autoloader? files listed will be executed
|
||||||
$rectorConfig->bootstrapFiles([
|
$rectorConfig->bootstrapFiles([
|
||||||
|
@ -22,9 +22,6 @@ use PHPStan\Rules\Rule;
|
|||||||
|
|
||||||
final class CheckFrameworkExceptionInstantiationViaNamedConstructorRule implements 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';
|
private const ERROR_MESSAGE = 'FrameworkException instance creation via new expression is not allowed, use its named constructor instead';
|
||||||
|
|
||||||
public function getNodeType(): string
|
public function getNodeType(): string
|
||||||
|
@ -22,14 +22,7 @@ use PHPStan\Rules\Rule;
|
|||||||
|
|
||||||
final class CheckUseStatementsAfterLicenseRule implements Rule
|
final class CheckUseStatementsAfterLicenseRule implements Rule
|
||||||
{
|
{
|
||||||
/**
|
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';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private const COPYRIGHT_REGEX = '/\* \(c\) CodeIgniter Foundation <admin@codeigniter\.com>/m';
|
private const COPYRIGHT_REGEX = '/\* \(c\) CodeIgniter Foundation <admin@codeigniter\.com>/m';
|
||||||
|
|
||||||
public function getNodeType(): string
|
public function getNodeType(): string
|
||||||
|
@ -11,6 +11,8 @@ declare(strict_types=1);
|
|||||||
* the LICENSE file that was distributed with this source code.
|
* the LICENSE file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace Utils;
|
||||||
|
|
||||||
require __DIR__ . '/../system/Test/bootstrap.php';
|
require __DIR__ . '/../system/Test/bootstrap.php';
|
||||||
|
|
||||||
use CodeIgniter\CLI\CLI;
|
use CodeIgniter\CLI\CLI;
|
||||||
@ -18,7 +20,7 @@ use CodeIgniter\CLI\CLI;
|
|||||||
$rstFilesWithTabs = (string) shell_exec('git grep -EIPn "\t" -- "*.rst"');
|
$rstFilesWithTabs = (string) shell_exec('git grep -EIPn "\t" -- "*.rst"');
|
||||||
$rstFilesWithTabs = explode("\n", $rstFilesWithTabs);
|
$rstFilesWithTabs = explode("\n", $rstFilesWithTabs);
|
||||||
$rstFilesWithTabs = array_map(static function (string $line): array {
|
$rstFilesWithTabs = array_map(static function (string $line): array {
|
||||||
preg_match('/^(?P<file>[^:]+):(?P<line>[0-9]+):(?P<code>.+)$/', $line, $matches);
|
preg_match('/^(?P<file>[^:]+):(?P<line>\d+):(?P<code>.+)$/', $line, $matches);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'file' => $matches['file'],
|
'file' => $matches['file'],
|
||||||
@ -44,20 +46,16 @@ if ($normalizedRstFilesWithTabs !== []) {
|
|||||||
"%s\n\n%s\n",
|
"%s\n\n%s\n",
|
||||||
CLI::color('Tabs in RST files were detected:', 'light_gray', 'red'),
|
CLI::color('Tabs in RST files were detected:', 'light_gray', 'red'),
|
||||||
implode("\n", array_map(
|
implode("\n", array_map(
|
||||||
static function (string $file, array $parts): string {
|
static fn (string $file, array $parts): string => sprintf(
|
||||||
return sprintf(
|
"%s%s\n%s\n",
|
||||||
"%s%s\n%s\n",
|
CLI::color('* in ', 'light_red'),
|
||||||
CLI::color('* in ', 'light_red'),
|
CLI::color($file, 'yellow'),
|
||||||
CLI::color($file, 'yellow'),
|
implode("\n", array_map(static fn (array $line): string => sprintf(
|
||||||
implode("\n", array_map(static function (array $line): string {
|
'%s | %s',
|
||||||
return sprintf(
|
str_pad($line['line'], 4, ' ', STR_PAD_LEFT),
|
||||||
'%s | %s',
|
str_replace("\t", CLI::color('....', 'light_gray', 'red'), $line['code']),
|
||||||
str_pad($line['line'], 4, ' ', STR_PAD_LEFT),
|
), $parts)),
|
||||||
str_replace("\t", CLI::color('....', 'light_gray', 'red'), $line['code']),
|
),
|
||||||
);
|
|
||||||
}, $parts)),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
array_keys($normalizedRstFilesWithTabs),
|
array_keys($normalizedRstFilesWithTabs),
|
||||||
array_values($normalizedRstFilesWithTabs),
|
array_values($normalizedRstFilesWithTabs),
|
||||||
)),
|
)),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user