Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions .github/workflows/main.yml → .github/workflows/prs.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
name: CI

on: [push, pull_request]

on:
pull_request:
jobs:
tests:
runs-on: ubuntu-latest

strategy:
matrix:
php: [8.3, 8.4]

steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -20,12 +17,12 @@ jobs:
php-version: ${{ matrix.php }}
extensions: pdo, sqlite, imagick
coverage: none

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
- name: Run ECS
run: php vendor/bin/ecs
- name: Run test suite
run: |
php vendor/bin/codecept build
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Automated release
on:
push:
branches:
- master
jobs:
static_analysis:
name: Static Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
- uses: ramsey/composer-install@v3
- name: Initialize cache
uses: actions/cache@v4
with:
key: phpstan
path: .phpstan-cache
- name: Run PHPStan
run: vendor/bin/phpstan
- name: Run ECS
run: php vendor/bin/ecs
tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: [8.3, 8.4]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: pdo, sqlite, imagick
coverage: none
- uses: ramsey/composer-install@v3
- name: Run test suite
run: |
php vendor/bin/codecept build
php vendor/bin/codecept run
release:
name: Automated release
needs:
- static_analysis
- tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 22
- run: >
npx
-p "@semantic-release/commit-analyzer"
-p "@semantic-release/release-notes-generator"
-p conventional-changelog-conventionalcommits
-p semantic-release
-- semantic-release --dry-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
packages: write
contents: write
pull-requests: write
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
tests/_support
tests/_output
tests/cases/yii2-app-advanced/_data/db.sqlite
.php-cs-fixer.cache
.ecs-cache
10 changes: 10 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"branches": ["master"],
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "conventionalcommits",
"presetConfig": {}
}],
"@semantic-release/github",
"@semantic-release/release-notes-generator"]
}
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@
"yiisoft/yii2": "dev-master",
"yiisoft/yii2-app-advanced": "dev-master",
"codeception/verify": "^3.0",
"codemix/yii2-localeurls": "^1.7",
"codeception/module-asserts": ">= 3.0",
"codeception/module-filesystem": "> 3.0",
"phpstan/phpstan": "^2",
"rector/rector": "^2"
"symplify/easy-coding-standard": "^12.5"
},
"autoload":{
"classmap": ["src/"]
Expand Down
69 changes: 69 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

declare(strict_types=1);

// ecs.php
use PHP_CodeSniffer\Standards\Generic\Sniffs\PHP\ForbiddenFunctionsSniff;
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
use PhpCsFixer\Fixer\ClassNotation\FinalInternalClassFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
use PhpCsFixer\Fixer\Phpdoc\NoBlankLinesAfterPhpdocFixer;
use PhpCsFixer\Fixer\Phpdoc\NoEmptyPhpdocFixer;
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ecsConfig): void {
// Parallel
$ecsConfig->parallel();

$ecsConfig->cacheDirectory('.ecs-cache');
// Paths
$ecsConfig->paths([
__DIR__ . '/src', __DIR__ . '/tests', __DIR__ . '/ecs.php'
]);

// A. full sets
$ecsConfig->sets([SetList::PSR_12, SetList::SPACES, SetList::STRICT, SetList::DOCBLOCK]);

$ecsConfig->rule(NotOperatorWithSuccessorSpaceFixer::class);
$ecsConfig->rule(ArraySyntaxFixer::class);
$ecsConfig->ruleWithConfiguration(GeneralPhpdocAnnotationRemoveFixer::class, [
'annotations' => ['author', 'inheritdoc', 'package']
]);
$ecsConfig->rule(NoBlankLinesAfterPhpdocFixer::class);
$ecsConfig->ruleWithConfiguration(NoSuperfluousPhpdocTagsFixer::class, [
'allow_mixed' => true
]);
$ecsConfig->rule(NoEmptyPhpdocFixer::class);
$ecsConfig->rule(NoUnusedImportsFixer::class);
$ecsConfig->ruleWithConfiguration(FinalInternalClassFixer::class, [
'annotation_exclude' => ['@not-fix', '@internal'],
'annotation_include' => [],
'consider_absent_docblock_as_internal_class' => true
]);
$ecsConfig->ruleWithConfiguration(ForbiddenFunctionsSniff::class, [
'forbiddenFunctions' => [
'passthru' => null,
'var_dump' => null,
]
]);
$ecsConfig->rule(PhpdocIndentFixer::class);
$ecsConfig->rule(\PhpCsFixer\Fixer\Phpdoc\AlignMultilineCommentFixer::class);

$ecsConfig->skip([
ForbiddenFunctionsSniff::class => [
'tests/**',
'console/**'
]
]);

// $ecsConfig->skip([
// FinalClassFixer::class => [
// 'tests/**'
// ]
// ]);
};
84 changes: 0 additions & 84 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -1704,84 +1704,6 @@ parameters:
count: 1
path: tests/cases/events/functional/ResponseCest.php

-
message: '#^Cannot call method getComponents\(\) on object\|null\.$#'
identifier: method.nonObject
count: 1
path: tests/cases/locale-urls/config.php

-
message: '#^Cannot call method has\(\) on object\|null\.$#'
identifier: method.nonObject
count: 1
path: tests/cases/locale-urls/config.php

-
message: '#^Cannot call method set\(\) on object\|null\.$#'
identifier: method.nonObject
count: 1
path: tests/cases/locale-urls/config.php

-
message: '#^Access to an undefined property yii\\console\\Request\|yii\\web\\Request\:\:\$bodyParams\.$#'
identifier: property.notFound
count: 1
path: tests/cases/locale-urls/controllers/SiteController.php

-
message: '#^Access to an undefined property yii\\console\\Response\|yii\\web\\Response\:\:\$statusCode\.$#'
identifier: property.notFound
count: 1
path: tests/cases/locale-urls/controllers/SiteController.php

-
message: '#^Cannot access property \$request on yii\\base\\Application\|null\.$#'
identifier: property.nonObject
count: 1
path: tests/cases/locale-urls/controllers/SiteController.php

-
message: '#^Cannot access property \$response on yii\\base\\Application\|null\.$#'
identifier: property.nonObject
count: 1
path: tests/cases/locale-urls/controllers/SiteController.php

-
message: '#^Method app\\localeurls\\controllers\\SiteController\:\:actionForm\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/cases/locale-urls/controllers/SiteController.php

-
message: '#^Method app\\localeurls\\controllers\\SiteController\:\:actionPost\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/cases/locale-urls/controllers/SiteController.php

-
message: '#^Method tests\\LocaleUrlCest\:\:testFormSubmit\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/cases/locale-urls/functional/LocaleUrlCest.php

-
message: '#^Method tests\\LocaleUrlCest\:\:testFormSubmit2\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/cases/locale-urls/functional/LocaleUrlCest.php

-
message: '#^Method tests\\LocaleUrlCest\:\:testInstantiation\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/cases/locale-urls/functional/LocaleUrlCest.php

-
message: '#^Method tests\\LocaleUrlCest\:\:testMultipleGet\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: tests/cases/locale-urls/functional/LocaleUrlCest.php

-
message: '#^Cannot access property \$mailer on yii\\base\\Application\|null\.$#'
identifier: property.nonObject
Expand Down Expand Up @@ -2034,12 +1956,6 @@ parameters:
count: 1
path: tests/cases/simple/helpers/EmptyString.php

-
message: '#^Parameter \#1 \$directory of function tempnam expects string, null given\.$#'
identifier: argument.type
count: 3
path: tests/cases/sqlite/config.php

-
message: '#^Cannot call method get\(\) on yii\\base\\Application\|null\.$#'
identifier: method.nonObject
Expand Down
12 changes: 9 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
includes:
- phpstan-baseline.neon
parameters:
exceptions:
check:
missingCheckedExceptionInThrows: false
reportUncheckedExceptionDeadCatch: false
reportUnmatchedIgnoredErrors: true
editorUrl: "phpstorm://open?file=%%file%%&line=%%line%%"
dynamicConstantNames:
- CONSOLE
- YII_DEBUG
Expand All @@ -10,10 +15,11 @@ parameters:
- src
- tests
checkMaybeUndefinedVariables: true
treatPhpDocTypesAsCertain: false
ignoreErrors:
# All Yii setters accept `null` but their phpdoc is incorrect.
- message: '~^Parameter #1 \$(.+) of method yii\\web\\Request::set(.+)\(\) expects (.+), null given.$~'
path: 'src/'
- identifier: return.type
path: tests/_support/_generated/FunctionalTesterActions.php
message: "# but returns mixed.$#"
# If you want to ignore missing generics errors in the future, you can add:
# - identifier: missingType.generics
stubFiles:
Expand Down
Loading