Skip to content

Commit 1d767fd

Browse files
authored
Merge pull request #6225 from samsonasik/apply-rector-run-on-utils
[Rector] Apply Rector run on utils/ directory
2 parents 7439b6e + 7284998 commit 1d767fd

File tree

4 files changed

+15
-27
lines changed

4 files changed

+15
-27
lines changed

rector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
$rectorConfig->parallel();
6565

6666
// paths to refactor; solid alternative to CLI arguments
67-
$rectorConfig->paths([__DIR__ . '/app', __DIR__ . '/system', __DIR__ . '/tests', __DIR__ . '/utils/Rector']);
67+
$rectorConfig->paths([__DIR__ . '/app', __DIR__ . '/system', __DIR__ . '/tests', __DIR__ . '/utils']);
6868

6969
// do you need to include constants, class aliases or custom autoloader? files listed will be executed
7070
$rectorConfig->bootstrapFiles([

utils/PHPStan/CheckFrameworkExceptionInstantiationViaNamedConstructorRule.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222

2323
final class CheckFrameworkExceptionInstantiationViaNamedConstructorRule implements Rule
2424
{
25-
/**
26-
* @var string
27-
*/
2825
private const ERROR_MESSAGE = 'FrameworkException instance creation via new expression is not allowed, use its named constructor instead';
2926

3027
public function getNodeType(): string

utils/PHPStan/CheckUseStatementsAfterLicenseRule.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,7 @@
2222

2323
final class CheckUseStatementsAfterLicenseRule implements Rule
2424
{
25-
/**
26-
* @var string
27-
*/
28-
private const ERROR_MESSAGE = 'Use statement must be located after license docblock';
29-
30-
/**
31-
* @var string
32-
*/
25+
private const ERROR_MESSAGE = 'Use statement must be located after license docblock';
3326
private const COPYRIGHT_REGEX = '/\* \(c\) CodeIgniter Foundation <admin@codeigniter\.com>/m';
3427

3528
public function getNodeType(): string

utils/check_tabs_in_rst.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@
1111
* the LICENSE file that was distributed with this source code.
1212
*/
1313

14+
namespace Utils;
15+
1416
require __DIR__ . '/../system/Test/bootstrap.php';
1517

1618
use CodeIgniter\CLI\CLI;
1719

1820
$rstFilesWithTabs = (string) shell_exec('git grep -EIPn "\t" -- "*.rst"');
1921
$rstFilesWithTabs = explode("\n", $rstFilesWithTabs);
2022
$rstFilesWithTabs = array_map(static function (string $line): array {
21-
preg_match('/^(?P<file>[^:]+):(?P<line>[0-9]+):(?P<code>.+)$/', $line, $matches);
23+
preg_match('/^(?P<file>[^:]+):(?P<line>\d+):(?P<code>.+)$/', $line, $matches);
2224

2325
return [
2426
'file' => $matches['file'],
@@ -44,20 +46,16 @@
4446
"%s\n\n%s\n",
4547
CLI::color('Tabs in RST files were detected:', 'light_gray', 'red'),
4648
implode("\n", array_map(
47-
static function (string $file, array $parts): string {
48-
return sprintf(
49-
"%s%s\n%s\n",
50-
CLI::color('* in ', 'light_red'),
51-
CLI::color($file, 'yellow'),
52-
implode("\n", array_map(static function (array $line): string {
53-
return sprintf(
54-
'%s | %s',
55-
str_pad($line['line'], 4, ' ', STR_PAD_LEFT),
56-
str_replace("\t", CLI::color('....', 'light_gray', 'red'), $line['code']),
57-
);
58-
}, $parts)),
59-
);
60-
},
49+
static fn (string $file, array $parts): string => sprintf(
50+
"%s%s\n%s\n",
51+
CLI::color('* in ', 'light_red'),
52+
CLI::color($file, 'yellow'),
53+
implode("\n", array_map(static fn (array $line): string => sprintf(
54+
'%s | %s',
55+
str_pad($line['line'], 4, ' ', STR_PAD_LEFT),
56+
str_replace("\t", CLI::color('....', 'light_gray', 'red'), $line['code']),
57+
), $parts)),
58+
),
6159
array_keys($normalizedRstFilesWithTabs),
6260
array_values($normalizedRstFilesWithTabs),
6361
)),

0 commit comments

Comments
 (0)