Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Jul 24, 2024
2 parents e469021 + 1192b91 commit fd4648f
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 60 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ CONTRIBUTING.md export-ignore

# contributor/development files
tests/ export-ignore
tools/ export-ignore
utils/ export-ignore
.php-cs-fixer.dist.php export-ignore
.php-cs-fixer.no-header.php export-ignore
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ jobs:
run: composer update --ansi --no-interaction

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

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

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

- name: Run lint on `user_guide_src/source/`
run: vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --config=.php-cs-fixer.user-guide.php --using-cache=no --diff
run: utils/vendor/bin/php-cs-fixer fix --verbose --ansi --dry-run --config=.php-cs-fixer.user-guide.php --using-cache=no --diff
4 changes: 2 additions & 2 deletions .github/workflows/test-psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
build:
name: Psalm Analysis
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]')"
if: (! contains(github.event.head_commit.message, '[ci skip]'))

steps:
- name: Checkout
Expand Down Expand Up @@ -68,4 +68,4 @@ jobs:
fi
- name: Run Psalm analysis
run: vendor/bin/psalm
run: utils/vendor/bin/psalm
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
$options = [
'cacheFile' => 'build/.php-cs-fixer.cache',
'finder' => $finder,
'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
'customFixers' => FixerGenerator::create('utils/vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'),
'customRules' => [
NoCodeSeparatorCommentFixer::name() => true,
],
Expand Down
12 changes: 6 additions & 6 deletions admin/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ if [ "$FILES" != "" ]; then
# Run on whole codebase to skip on unnecessary filtering
# Run first on app, admin, public
if [ -d /proc/cygdrive ]; then
./vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php
./utils/vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php
else
php ./vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php
php ./utils/vendor/bin/php-cs-fixer fix --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php
fi

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

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

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

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

if [ $? != 0 ]; then
Expand Down
2 changes: 1 addition & 1 deletion admin/starter/.github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

runs-on: ubuntu-latest

if: "!contains(github.event.head_commit.message, '[ci skip]')"
if: (! contains(github.event.head_commit.message, '[ci skip]'))

steps:
- name: Checkout
Expand Down
40 changes: 18 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,18 @@
"psr/log": "^3.0"
},
"require-dev": {
"codeigniter/coding-standard": "^1.7",
"codeigniter/phpstan-codeigniter": "^1.4",
"ergebnis/composer-normalize": "^2.28",
"fakerphp/faker": "^1.9",
"friendsofphp/php-cs-fixer": "^3.47.1",
"kint-php/kint": "^5.0.4",
"mikey179/vfsstream": "^1.6",
"nexusphp/cs-config": "^3.6",
"nexusphp/tachycardia": "^2.0",
"phpstan/extension-installer": "^1.3",
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^1.11",
"phpstan/phpstan-strict-rules": "^1.6",
"phpunit/phpcov": "^9.0.2",
"phpunit/phpunit": "^10.5.16",
"predis/predis": "^1.1 || ^2.0",
"rector/rector": "1.2.1",
"vimeo/psalm": "^5.0"
"rector/rector": "1.2.1"
},
"replace": {
"codeigniter4/framework": "self.version"
Expand Down Expand Up @@ -72,12 +67,11 @@
"autoload-dev": {
"psr-4": {
"CodeIgniter\\": "tests/system/",
"Utils\\": "utils/"
"Utils\\": "utils/src/"
}
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true,
"phpstan/extension-installer": true
},
"optimize-autoloader": true,
Expand All @@ -91,29 +85,31 @@
},
"scripts": {
"post-update-cmd": [
"CodeIgniter\\ComposerScripts::postUpdate",
"composer update --working-dir=tools/phpmetrics"
"CodeIgniter\\ComposerScripts::postUpdate"
],
"post-autoload-dump": [
"@composer update --working-dir=utils"
],
"analyze": [
"Composer\\Config::disableProcessTimeout",
"bash -c \"XDEBUG_MODE=off phpstan analyse\"",
"rector process --dry-run"
"bash -c \"XDEBUG_MODE=off vendor/bin/phpstan analyse\"",
"vendor/bin/rector process --dry-run"
],
"cs": [
"Composer\\Config::disableProcessTimeout",
"php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.user-guide.php",
"php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php",
"php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.tests.php",
"php-cs-fixer fix --ansi --verbose --dry-run --diff"
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.user-guide.php",
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.no-header.php",
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run --diff --config=.php-cs-fixer.tests.php",
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --dry-run --diff"
],
"cs-fix": [
"Composer\\Config::disableProcessTimeout",
"php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.user-guide.php",
"php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.no-header.php",
"php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.tests.php",
"php-cs-fixer fix --ansi --verbose --diff"
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.user-guide.php",
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.no-header.php",
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --diff --config=.php-cs-fixer.tests.php",
"utils/vendor/bin/php-cs-fixer fix --ansi --verbose --diff"
],
"metrics": "tools/phpmetrics/vendor/bin/phpmetrics --config=phpmetrics.json",
"metrics": "utils/vendor/bin/phpmetrics --config=phpmetrics.json",
"sa": "@analyze",
"style": "@cs-fix",
"test": "phpunit"
Expand Down
6 changes: 0 additions & 6 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -18673,11 +18673,5 @@
'count' => 1,
'path' => __DIR__ . '/tests/system/View/ViewTest.php',
];
$ignoreErrors[] = [
// identifier: method.childParameterType
'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\\(\\)$#',
'count' => 1,
'path' => __DIR__ . '/utils/PHPStan/CheckUseStatementsAfterLicenseRule.php',
];

return ['parameters' => ['ignoreErrors' => $ignoreErrors]];
2 changes: 1 addition & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ parameters:
- app
- system
- tests
- utils/PHPStan
- utils/src/PHPStan
excludePaths:
- app/Views/errors/cli/*
- app/Views/errors/html/*
Expand Down
9 changes: 6 additions & 3 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@
FileCacheStorage::class
)
// paths to refactor; solid alternative to CLI arguments
->withPaths(
[__DIR__ . '/app', __DIR__ . '/system', __DIR__ . '/tests', __DIR__ . '/utils']
)
->withPaths([
__DIR__ . '/app',
__DIR__ . '/system',
__DIR__ . '/tests',
__DIR__ . '/utils/src',
])
// do you need to include constants, class aliases or custom autoloader? files listed will be executed
->withBootstrapFiles([
__DIR__ . '/system/Test/bootstrap.php',
Expand Down
6 changes: 2 additions & 4 deletions system/Database/Postgre/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ class Connection extends BaseConnection
/**
* Connect to the database.
*
* @return false|resource
* @phpstan-return false|PgSqlConnection
* @return false|PgSqlConnection
*/
public function connect(bool $persistent = false)
{
Expand Down Expand Up @@ -197,8 +196,7 @@ public function getVersion(): string
/**
* Executes the query against the database.
*
* @return false|resource
* @phpstan-return false|PgSqlResult
* @return false|PgSqlResult
*/
protected function execute(string $sql)
{
Expand Down
3 changes: 1 addition & 2 deletions system/Database/Postgre/PreparedQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ public function _execute(array $data): bool
/**
* Returns the result object for the prepared query or false on failure.
*
* @return resource|null
* @phpstan-return PgSqlResult|null
* @return PgSqlResult|null
*/
public function _getResult()
{
Expand Down
5 changes: 0 additions & 5 deletions tools/phpmetrics/composer.json

This file was deleted.

2 changes: 1 addition & 1 deletion user_guide_src/source/libraries/user_agent/005.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

if ($agent->isReferral()) {
echo $agent->referrer();
echo $agent->getReferrer();
}
24 changes: 24 additions & 0 deletions utils/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"require": {
"php": "^8.1",
"codeigniter/coding-standard": "^1.7",
"ergebnis/composer-normalize": "^2.28",
"friendsofphp/php-cs-fixer": "^3.47.1",
"nexusphp/cs-config": "^3.6",
"phpmetrics/phpmetrics": "^2.8 || ^3.0rc6",
"vimeo/psalm": "^5.0"
},
"autoload": {
"psr-4": {
"Utils\\": "src/"
}
},
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true
},
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Use_;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\IdentifierRuleError;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;

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

/**
* @param Stmt $node
*
* @return list<IdentifierRuleError>
*/
public function processNode(Node $node, Scope $scope): array
{
Expand All @@ -54,7 +61,11 @@ public function processNode(Node $node, Scope $scope): array

while ($previous) {
if ($previous instanceof Use_) {
return [self::ERROR_MESSAGE];
return [
RuleErrorBuilder::message(self::ERROR_MESSAGE)
->identifier('codeigniter.useStmtAfterLicense')
->build(),
];
}

$previous = $previous->getAttribute('previous');
Expand Down

0 comments on commit fd4648f

Please sign in to comment.