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();
|
||||
|
||||
// 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([
|
||||
|
@ -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
|
||||
|
@ -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 <admin@codeigniter\.com>/m';
|
||||
|
||||
public function getNodeType(): string
|
||||
|
@ -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<file>[^:]+):(?P<line>[0-9]+):(?P<code>.+)$/', $line, $matches);
|
||||
preg_match('/^(?P<file>[^:]+):(?P<line>\d+):(?P<code>.+)$/', $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),
|
||||
)),
|
||||
|
Loading…
x
Reference in New Issue
Block a user