Skip to content

Commit 3f8ffe0

Browse files
authored
Merge pull request #123 from Codeception/php-cs-fixer-per2
Php cs fixer per2
2 parents a1703d0 + d8111f0 commit 3f8ffe0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+557
-527
lines changed

.github/workflows/main.yml renamed to .github/workflows/prs.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
name: CI
2-
3-
on: [push, pull_request]
4-
2+
on:
3+
pull_request:
54
jobs:
65
tests:
76
runs-on: ubuntu-latest
8-
97
strategy:
108
matrix:
119
php: [8.3, 8.4]
12-
1310
steps:
1411
- name: Checkout code
1512
uses: actions/checkout@v4
@@ -20,12 +17,12 @@ jobs:
2017
php-version: ${{ matrix.php }}
2118
extensions: pdo, sqlite, imagick
2219
coverage: none
23-
2420
- name: Validate composer.json and composer.lock
2521
run: composer validate
26-
2722
- name: Install dependencies
2823
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
24+
- name: Run ECS
25+
run: php vendor/bin/ecs
2926
- name: Run test suite
3027
run: |
3128
php vendor/bin/codecept build

.github/workflows/release.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Automated release
2+
on:
3+
push:
4+
branches:
5+
- master
6+
jobs:
7+
static_analysis:
8+
name: Static Analysis
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Setup PHP with PECL extension
13+
uses: shivammathur/setup-php@v2
14+
with:
15+
php-version: '8.4'
16+
- uses: ramsey/composer-install@v3
17+
- name: Initialize cache
18+
uses: actions/cache@v4
19+
with:
20+
key: phpstan
21+
path: .phpstan-cache
22+
- name: Run PHPStan
23+
run: vendor/bin/phpstan
24+
- name: Run ECS
25+
run: php vendor/bin/ecs
26+
tests:
27+
runs-on: ubuntu-latest
28+
strategy:
29+
matrix:
30+
php: [8.3, 8.4]
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v4
34+
35+
- name: Setup PHP
36+
uses: shivammathur/setup-php@v2
37+
with:
38+
php-version: ${{ matrix.php }}
39+
extensions: pdo, sqlite, imagick
40+
coverage: none
41+
- uses: ramsey/composer-install@v3
42+
- name: Run test suite
43+
run: |
44+
php vendor/bin/codecept build
45+
php vendor/bin/codecept run
46+
release:
47+
name: Automated release
48+
needs:
49+
- static_analysis
50+
- tests
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v4
54+
with:
55+
persist-credentials: false
56+
- uses: actions/setup-node@v4
57+
with:
58+
node-version: 22
59+
- run: >
60+
npx
61+
-p "@semantic-release/commit-analyzer"
62+
-p "@semantic-release/release-notes-generator"
63+
-p conventional-changelog-conventionalcommits
64+
-p semantic-release
65+
-- semantic-release --dry-run
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
permissions:
69+
packages: write
70+
contents: write
71+
pull-requests: write

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
tests/_support
66
tests/_output
77
tests/cases/yii2-app-advanced/_data/db.sqlite
8+
.php-cs-fixer.cache
9+
.ecs-cache

.releaserc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"branches": ["master"],
3+
"plugins": [
4+
["@semantic-release/commit-analyzer", {
5+
"preset": "conventionalcommits",
6+
"presetConfig": {}
7+
}],
8+
"@semantic-release/github",
9+
"@semantic-release/release-notes-generator"]
10+
}

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
"yiisoft/yii2": "dev-master",
2727
"yiisoft/yii2-app-advanced": "dev-master",
2828
"codeception/verify": "^3.0",
29-
"codemix/yii2-localeurls": "^1.7",
3029
"codeception/module-asserts": ">= 3.0",
3130
"codeception/module-filesystem": "> 3.0",
3231
"phpstan/phpstan": "^2",
33-
"rector/rector": "^2"
32+
"symplify/easy-coding-standard": "^12.5"
3433
},
3534
"autoload":{
3635
"classmap": ["src/"]

ecs.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
// ecs.php
6+
use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff;
7+
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
8+
use PhpCsFixer\Fixer\ClassNotation\FinalInternalClassFixer;
9+
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
10+
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
11+
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
12+
use PhpCsFixer\Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer;
13+
use PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer;
14+
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
15+
use PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer;
16+
use Symplify\EasyCodingStandard\Config\ECSConfig;
17+
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
18+
19+
return static function (ECSConfig $ecsConfig): void {
20+
// Parallel
21+
$ecsConfig->parallel();
22+
23+
$ecsConfig->cacheDirectory('.ecs-cache');
24+
// Paths
25+
$ecsConfig->paths([
26+
__DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/ecs.php'
27+
]);
28+
29+
// A. full sets
30+
$ecsConfig->sets([SetList::PSR_12, SetList::SPACES, SetList::STRICT, SetList::DOCBLOCK]);
31+
32+
$ecsConfig->rule(NotOperatorWithSuccessorSpaceFixer::class);
33+
$ecsConfig->rule(ArraySyntaxFixer::class);
34+
$ecsConfig->ruleWithConfiguration(GeneralPhpdocAnnotationRemoveFixer::class, [
35+
'annotations' => ['author', 'inheritdoc', 'package']
36+
]);
37+
$ecsConfig->rule(NoBlankLinesAfterPhpdocFixer::class);
38+
$ecsConfig->ruleWithConfiguration(NoSuperfluousPhpdocTagsFixer::class, [
39+
'allow_mixed' => true
40+
]);
41+
$ecsConfig->rule(NoEmptyPhpdocFixer::class);
42+
$ecsConfig->rule(NoUnusedImportsFixer::class);
43+
$ecsConfig->ruleWithConfiguration(FinalInternalClassFixer::class, [
44+
'annotation_exclude' => ['@not-fix', '@internal'],
45+
'annotation_include' => [],
46+
'consider_absent_docblock_as_internal_class' => true
47+
]);
48+
$ecsConfig->ruleWithConfiguration(ForbiddenFunctionsSniff::class, [
49+
'forbiddenFunctions' => [
50+
'passthru' => null,
51+
'var_dump' => null,
52+
]
53+
]);
54+
$ecsConfig->rule(PhpdocIndentFixer::class);
55+
$ecsConfig->rule(\PhpCsFixer\Fixer\Phpdoc\AlignMultilineCommentFixer::class);
56+
57+
$ecsConfig->skip([
58+
ForbiddenFunctionsSniff::class => [
59+
'tests/**',
60+
'console/**'
61+
]
62+
]);
63+
64+
// $ecsConfig->skip([
65+
// FinalClassFixer::class => [
66+
// 'tests/**'
67+
// ]
68+
// ]);
69+
};

phpstan-baseline.neon

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,84 +1704,6 @@ parameters:
17041704
count: 1
17051705
path: tests/cases/events/functional/ResponseCest.php
17061706

1707-
-
1708-
message: '#^Cannot call method getComponents\(\) on object\|null\.$#'
1709-
identifier: method.nonObject
1710-
count: 1
1711-
path: tests/cases/locale-urls/config.php
1712-
1713-
-
1714-
message: '#^Cannot call method has\(\) on object\|null\.$#'
1715-
identifier: method.nonObject
1716-
count: 1
1717-
path: tests/cases/locale-urls/config.php
1718-
1719-
-
1720-
message: '#^Cannot call method set\(\) on object\|null\.$#'
1721-
identifier: method.nonObject
1722-
count: 1
1723-
path: tests/cases/locale-urls/config.php
1724-
1725-
-
1726-
message: '#^Access to an undefined property yii\\console\\Request\|yii\\web\\Request\:\:\$bodyParams\.$#'
1727-
identifier: property.notFound
1728-
count: 1
1729-
path: tests/cases/locale-urls/controllers/SiteController.php
1730-
1731-
-
1732-
message: '#^Access to an undefined property yii\\console\\Response\|yii\\web\\Response\:\:\$statusCode\.$#'
1733-
identifier: property.notFound
1734-
count: 1
1735-
path: tests/cases/locale-urls/controllers/SiteController.php
1736-
1737-
-
1738-
message: '#^Cannot access property \$request on yii\\base\\Application\|null\.$#'
1739-
identifier: property.nonObject
1740-
count: 1
1741-
path: tests/cases/locale-urls/controllers/SiteController.php
1742-
1743-
-
1744-
message: '#^Cannot access property \$response on yii\\base\\Application\|null\.$#'
1745-
identifier: property.nonObject
1746-
count: 1
1747-
path: tests/cases/locale-urls/controllers/SiteController.php
1748-
1749-
-
1750-
message: '#^Method app\\localeurls\\controllers\\SiteController\:\:actionForm\(\) has no return type specified\.$#'
1751-
identifier: missingType.return
1752-
count: 1
1753-
path: tests/cases/locale-urls/controllers/SiteController.php
1754-
1755-
-
1756-
message: '#^Method app\\localeurls\\controllers\\SiteController\:\:actionPost\(\) has no return type specified\.$#'
1757-
identifier: missingType.return
1758-
count: 1
1759-
path: tests/cases/locale-urls/controllers/SiteController.php
1760-
1761-
-
1762-
message: '#^Method tests\\LocaleUrlCest\:\:testFormSubmit\(\) has no return type specified\.$#'
1763-
identifier: missingType.return
1764-
count: 1
1765-
path: tests/cases/locale-urls/functional/LocaleUrlCest.php
1766-
1767-
-
1768-
message: '#^Method tests\\LocaleUrlCest\:\:testFormSubmit2\(\) has no return type specified\.$#'
1769-
identifier: missingType.return
1770-
count: 1
1771-
path: tests/cases/locale-urls/functional/LocaleUrlCest.php
1772-
1773-
-
1774-
message: '#^Method tests\\LocaleUrlCest\:\:testInstantiation\(\) has no return type specified\.$#'
1775-
identifier: missingType.return
1776-
count: 1
1777-
path: tests/cases/locale-urls/functional/LocaleUrlCest.php
1778-
1779-
-
1780-
message: '#^Method tests\\LocaleUrlCest\:\:testMultipleGet\(\) has no return type specified\.$#'
1781-
identifier: missingType.return
1782-
count: 1
1783-
path: tests/cases/locale-urls/functional/LocaleUrlCest.php
1784-
17851707
-
17861708
message: '#^Cannot access property \$mailer on yii\\base\\Application\|null\.$#'
17871709
identifier: property.nonObject
@@ -2034,12 +1956,6 @@ parameters:
20341956
count: 1
20351957
path: tests/cases/simple/helpers/EmptyString.php
20361958

2037-
-
2038-
message: '#^Parameter \#1 \$directory of function tempnam expects string, null given\.$#'
2039-
identifier: argument.type
2040-
count: 3
2041-
path: tests/cases/sqlite/config.php
2042-
20431959
-
20441960
message: '#^Cannot call method get\(\) on yii\\base\\Application\|null\.$#'
20451961
identifier: method.nonObject

phpstan.neon

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
includes:
22
- phpstan-baseline.neon
33
parameters:
4+
exceptions:
5+
check:
6+
missingCheckedExceptionInThrows: false
7+
reportUncheckedExceptionDeadCatch: false
48
reportUnmatchedIgnoredErrors: true
9+
editorUrl: "phpstorm://open?file=%%file%%&line=%%line%%"
510
dynamicConstantNames:
611
- CONSOLE
712
- YII_DEBUG
@@ -10,10 +15,11 @@ parameters:
1015
- src
1116
- tests
1217
checkMaybeUndefinedVariables: true
18+
treatPhpDocTypesAsCertain: false
1319
ignoreErrors:
14-
# All Yii setters accept `null` but their phpdoc is incorrect.
15-
- message: '~^Parameter #1 \$(.+) of method yii\\web\\Request::set(.+)\(\) expects (.+), null given.$~'
16-
path: 'src/'
20+
- identifier: return.type
21+
path: tests/_support/_generated/FunctionalTesterActions.php
22+
message: "# but returns mixed.$#"
1723
# If you want to ignore missing generics errors in the future, you can add:
1824
# - identifier: missingType.generics
1925
stubFiles:

0 commit comments

Comments
 (0)