Merge remote-tracking branch 'upstream/develop' into 4.6

This commit is contained in:
kenjis 2024-07-24 09:33:00 +09:00
commit fd4648febe
No known key found for this signature in database
GPG Key ID: BD254878922AF198
19 changed files with 79 additions and 60 deletions

1
.gitattributes vendored
View File

@ -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

View File

@ -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

View File

@ -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
@ -68,4 +68,4 @@ jobs:
fi
- name: Run Psalm analysis
run: vendor/bin/psalm
run: utils/vendor/bin/psalm

View File

@ -44,7 +44,7 @@ $overrides = [];
$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,
],

View File

@ -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
@ -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
@ -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

View File

@ -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

View File

@ -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"
@ -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,
@ -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"

View File

@ -18673,11 +18673,5 @@ $ignoreErrors[] = [
'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]];

View File

@ -18,7 +18,7 @@ parameters:
- app
- system
- tests
- utils/PHPStan
- utils/src/PHPStan
excludePaths:
- app/Views/errors/cli/*
- app/Views/errors/html/*

View File

@ -73,9 +73,12 @@ return RectorConfig::configure()
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',

View File

@ -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)
{
@ -197,8 +196,7 @@ class Connection extends BaseConnection
/**
* Executes the query against the database.
*
* @return false|resource
* @phpstan-return false|PgSqlResult
* @return false|PgSqlResult
*/
protected function execute(string $sql)
{

View File

@ -95,8 +95,7 @@ class PreparedQuery extends BasePreparedQuery
/**
* 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()
{

View File

@ -1,5 +0,0 @@
{
"require-dev": {
"phpmetrics/phpmetrics": "^3.0rc6"
}
}

View File

@ -1,5 +1,5 @@
<?php
if ($agent->isReferral()) {
echo $agent->referrer();
echo $agent->getReferrer();
}

24
utils/composer.json Normal file
View File

@ -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
}
}

View File

@ -18,8 +18,13 @@ use PhpParser\Node;
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';
@ -32,6 +37,8 @@ final class CheckUseStatementsAfterLicenseRule implements Rule
/**
* @param Stmt $node
*
* @return list<IdentifierRuleError>
*/
public function processNode(Node $node, Scope $scope): array
{
@ -54,7 +61,11 @@ final class CheckUseStatementsAfterLicenseRule implements Rule
while ($previous) {
if ($previous instanceof Use_) {
return [self::ERROR_MESSAGE];
return [
RuleErrorBuilder::message(self::ERROR_MESSAGE)
->identifier('codeigniter.useStmtAfterLicense')
->build(),
];
}
$previous = $previous->getAttribute('previous');