Skip to content

Commit 1192b91

Browse files
authored
Merge pull request #9047 from paulbalandan/reorganise-toolkit
chore: reorganise toolkit
2 parents 854c73f + 90ea5c7 commit 1192b91

15 files changed

+73
-51
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ CONTRIBUTING.md export-ignore
1717

1818
# contributor/development files
1919
tests/ export-ignore
20-
tools/ export-ignore
2120
utils/ export-ignore
2221
.php-cs-fixer.dist.php export-ignore
2322
.php-cs-fixer.no-header.php export-ignore

.github/workflows/test-coding-standards.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ jobs:
5858
run: composer update --ansi --no-interaction
5959

6060
- name: Run lint on `app/`, `admin/`, `public/`
61-
run: vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --config=.php-cs-fixer.no-header.php --using-cache=no --diff
61+
run: utils/vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --config=.php-cs-fixer.no-header.php --using-cache=no --diff
6262

6363
- name: Run lint on `system/`, `utils/`, and root PHP files
64-
run: vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --using-cache=no --diff
64+
run: utils/vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --using-cache=no --diff
6565

6666
- name: Run lint on `tests`
67-
run: vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --config=.php-cs-fixer.tests.php --using-cache=no --diff
67+
run: utils/vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --config=.php-cs-fixer.tests.php --using-cache=no --diff
6868

6969
- name: Run lint on `user_guide_src/source/`
70-
run: vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --config=.php-cs-fixer.user-guide.php --using-cache=no --diff
70+
run: utils/vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --config=.php-cs-fixer.user-guide.php --using-cache=no --diff

.github/workflows/test-psalm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,4 @@ jobs:
6868
fi
6969
7070
- name: Run Psalm analysis
71-
run: vendor/bin/psalm
71+
run: utils/vendor/bin/psalm

.php-cs-fixer.dist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
$options = [
4545
'cacheFile' => 'build/.php-cs-fixer.cache',
4646
'finder' => $finder,
47-
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
47+
'customFixers' => FixerGenerator::create('utils/vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
4848
'customRules' => [
4949
NoCodeSeparatorCommentFixer::name() => true,
5050
],

admin/pre-commit

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ if [ "$FILES" != "" ]; then
2626
# Run on whole codebase to skip on unnecessary filtering
2727
# Run first on app, admin, public
2828
if [ -d /proc/cygdrive ]; then
29-
./vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php
29+
./utils/vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php
3030
else
31-
php ./vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php
31+
php ./utils/vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php
3232
fi
3333

3434
if [ $? != 0 ]; then
@@ -38,9 +38,9 @@ if [ "$FILES" != "" ]; then
3838

3939
# Next, run on system, tests, utils, and root PHP files
4040
if [ -d /proc/cygdrive ]; then
41-
./vendor/bin/php-cs-fixer fix --verbose --dry-run --diff
41+
./utils/vendor/bin/php-cs-fixer fix --verbose --dry-run --diff
4242
else
43-
php ./vendor/bin/php-cs-fixer fix --verbose --dry-run --diff
43+
php ./utils/vendor/bin/php-cs-fixer fix --verbose --dry-run --diff
4444
fi
4545

4646
if [ $? != 0 ]; then
@@ -50,9 +50,9 @@ if [ "$FILES" != "" ]; then
5050

5151
# Next, run on user_guide_src/source PHP files
5252
if [ -d /proc/cygdrive ]; then
53-
./vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.user-guide.php
53+
./utils/vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.user-guide.php
5454
else
55-
php ./vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.user-guide.php
55+
php ./utils/vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.user-guide.php
5656
fi
5757

5858
if [ $? != 0 ]; then

composer.json

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,18 @@
1717
"psr/log": "^3.0"
1818
},
1919
"require-dev": {
20-
"codeigniter/coding-standard": "^1.7",
2120
"codeigniter/phpstan-codeigniter": "^1.4",
22-
"ergebnis/composer-normalize": "^2.28",
2321
"fakerphp/faker": "^1.9",
24-
"friendsofphp/php-cs-fixer": "^3.47.1",
2522
"kint-php/kint": "^5.0.4",
2623
"mikey179/vfsstream": "^1.6",
27-
"nexusphp/cs-config": "^3.6",
2824
"nexusphp/tachycardia": "^2.0",
29-
"phpstan/extension-installer": "^1.3",
25+
"phpstan/extension-installer": "^1.4",
3026
"phpstan/phpstan": "^1.11",
3127
"phpstan/phpstan-strict-rules": "^1.6",
3228
"phpunit/phpcov": "^9.0.2",
3329
"phpunit/phpunit": "^10.5.16",
3430
"predis/predis": "^1.1 || ^2.0",
35-
"rector/rector": "1.2.1",
36-
"vimeo/psalm": "^5.0"
31+
"rector/rector": "1.2.1"
3732
},
3833
"replace": {
3934
"codeigniter4/framework": "self.version"
@@ -72,12 +67,11 @@
7267
"autoload-dev": {
7368
"psr-4": {
7469
"CodeIgniter\\": "tests/system/",
75-
"Utils\\": "utils/"
70+
"Utils\\": "utils/src/"
7671
}
7772
},
7873
"config": {
7974
"allow-plugins": {
80-
"ergebnis/composer-normalize": true,
8175
"phpstan/extension-installer": true
8276
},
8377
"optimize-autoloader": true,
@@ -91,29 +85,31 @@
9185
},
9286
"scripts": {
9387
"post-update-cmd": [
94-
"CodeIgniter\\ComposerScripts::postUpdate",
95-
"composer update --working-dir=tools/phpmetrics"
88+
"CodeIgniter\\ComposerScripts::postUpdate"
89+
],
90+
"post-autoload-dump": [
91+
"@composer update --working-dir=utils"
9692
],
9793
"analyze": [
9894
"Composer\\Config::disableProcessTimeout",
99-
"bash -c \"XDEBUG_MODE=off phpstan analyse\"",
100-
"rector process --dry-run"
95+
"bash -c \"XDEBUG_MODE=off vendor/bin/phpstan analyse\"",
96+
"vendor/bin/rector process --dry-run"
10197
],
10298
"cs": [
10399
"Composer\\Config::disableProcessTimeout",
104-
"php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.user-guide.php",
105-
"php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php",
106-
"php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.tests.php",
107-
"php-cs-fixer fix --ansi --verbose --dry-run --diff"
100+
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.user-guide.php",
101+
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php",
102+
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.tests.php",
103+
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run --diff"
108104
],
109105
"cs-fix": [
110106
"Composer\\Config::disableProcessTimeout",
111-
"php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.user-guide.php",
112-
"php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.no-header.php",
113-
"php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.tests.php",
114-
"php-cs-fixer fix --ansi --verbose --diff"
107+
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.user-guide.php",
108+
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.no-header.php",
109+
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.tests.php",
110+
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --diff"
115111
],
116-
"metrics": "tools/phpmetrics/vendor/bin/phpmetrics --config=phpmetrics.json",
112+
"metrics": "utils/vendor/bin/phpmetrics --config=phpmetrics.json",
117113
"sa": "@analyze",
118114
"style": "@cs-fix",
119115
"test": "phpunit"

phpstan-baseline.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18793,11 +18793,5 @@
1879318793
'count' => 1,
1879418794
'path' => __DIR__ . '/tests/system/View/ViewTest.php',
1879518795
];
18796-
$ignoreErrors[] = [
18797-
// identifier: method.childParameterType
18798-
'message' => '#^Parameter \\#1 \\$node \\(PhpParser\\\\Node\\\\Stmt\\) of method Utils\\\\PHPStan\\\\CheckUseStatementsAfterLicenseRule\\:\\:processNode\\(\\) should be contravariant with parameter \\$node \\(PhpParser\\\\Node\\) of method PHPStan\\\\Rules\\\\Rule\\<PhpParser\\\\Node\\>\\:\\:processNode\\(\\)$#',
18799-
'count' => 1,
18800-
'path' => __DIR__ . '/utils/PHPStan/CheckUseStatementsAfterLicenseRule.php',
18801-
];
1880218796

1880318797
return ['parameters' => ['ignoreErrors' => $ignoreErrors]];

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ parameters:
1818
- app
1919
- system
2020
- tests
21-
- utils/PHPStan
21+
- utils/src/PHPStan
2222
excludePaths:
2323
- app/Views/errors/cli/*
2424
- app/Views/errors/html/*

rector.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@
7373
FileCacheStorage::class
7474
)
7575
// paths to refactor; solid alternative to CLI arguments
76-
->withPaths(
77-
[__DIR__ . '/app', __DIR__ . '/system', __DIR__ . '/tests', __DIR__ . '/utils']
78-
)
76+
->withPaths([
77+
__DIR__ . '/app',
78+
__DIR__ . '/system',
79+
__DIR__ . '/tests',
80+
__DIR__ . '/utils/src',
81+
])
7982
// do you need to include constants, class aliases or custom autoloader? files listed will be executed
8083
->withBootstrapFiles([
8184
__DIR__ . '/system/Test/bootstrap.php',

tools/phpmetrics/composer.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

utils/composer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"require": {
3+
"php": "^8.1",
4+
"codeigniter/coding-standard": "^1.7",
5+
"ergebnis/composer-normalize": "^2.28",
6+
"friendsofphp/php-cs-fixer": "^3.47.1",
7+
"nexusphp/cs-config": "^3.6",
8+
"phpmetrics/phpmetrics": "^2.8 || ^3.0rc6",
9+
"vimeo/psalm": "^5.0"
10+
},
11+
"autoload": {
12+
"psr-4": {
13+
"Utils\\": "src/"
14+
}
15+
},
16+
"config": {
17+
"allow-plugins": {
18+
"ergebnis/composer-normalize": true
19+
},
20+
"optimize-autoloader": true,
21+
"preferred-install": "dist",
22+
"sort-packages": true
23+
}
24+
}

utils/PHPStan/CheckUseStatementsAfterLicenseRule.php renamed to utils/src/PHPStan/CheckUseStatementsAfterLicenseRule.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
use PhpParser\Node\Stmt;
1919
use PhpParser\Node\Stmt\Use_;
2020
use PHPStan\Analyser\Scope;
21+
use PHPStan\Rules\IdentifierRuleError;
2122
use PHPStan\Rules\Rule;
23+
use PHPStan\Rules\RuleErrorBuilder;
2224

25+
/**
26+
* @implements Rule<Node\Stmt>
27+
*/
2328
final class CheckUseStatementsAfterLicenseRule implements Rule
2429
{
2530
private const ERROR_MESSAGE = 'Use statement must be located after license docblock';
@@ -32,6 +37,8 @@ public function getNodeType(): string
3237

3338
/**
3439
* @param Stmt $node
40+
*
41+
* @return list<IdentifierRuleError>
3542
*/
3643
public function processNode(Node $node, Scope $scope): array
3744
{
@@ -54,7 +61,11 @@ public function processNode(Node $node, Scope $scope): array
5461

5562
while ($previous) {
5663
if ($previous instanceof Use_) {
57-
return [self::ERROR_MESSAGE];
64+
return [
65+
RuleErrorBuilder::message(self::ERROR_MESSAGE)
66+
->identifier('codeigniter.useStmtAfterLicense')
67+
->build(),
68+
];
5869
}
5970

6071
$previous = $previous->getAttribute('previous');

0 commit comments

Comments
 (0)