Lewati ke konten
PHP Ecosystem
Explore

Testing

Konten ini belum tersedia dalam bahasa Anda.

Install the development dependencies in a source checkout and record the installed versions:

Terminal window
composer install
composer validate --strict
composer audit
composer show yiisoft/yii2
vendor/bin/phpstan --version

The library’s lockfile is ignored; CI resolves dependencies for Yii 2.0.55 and Yii 22 on PHP 8.3, 8.4 and 8.5. Static analysis targets PHP 8.3 and runs on PHP 8.3 and 8.5 in CI.

Terminal window
composer tests
composer static
vendor/bin/phpstan analyse -c phpstan-console.neon --memory-limit=1G
composer check-dependencies
vendor/bin/ecs check

PHPUnit compares inferred types through PHPStan\Testing\TypeInferenceTestCase, including configuration and cache dependency cases. Both static configurations matter because Yii::$app has one configured application type per analysis. composer ecs applies fixes and composer rector refactors files; use them only for intentional changes and inspect their diffs.

The logger resolver looks up the optional Yii 22 yii\log\PsrMessage class by name and checks for it through reflection before including it. The test bootstrap defines the expected payload type for the installed Yii version, so PHPUnit and direct static checks validate the same fixture on Yii 2.0.55 and Yii 22. Retain the existence guard and both sets of expectations when changing logger inference.

When checking an isolated consumer, preserve its composer.json and configured vendor directory together. PHPStan uses that manifest to recognize dependency stubs; copying only the vendor tree can trigger project-stub validation.

Adapt the usage recipes to the application and inspect the affected types. Run both Web and console analyses when relevant, and verify runtime behavior attachments or database/HTTP integration when they change.

The pinned reusable workflow in .github/workflows/quality.yml runs Prettier 3.8.4, EditorConfig Checker 3.7.0 and Markdownlint CLI2 0.22.1. Use its repository configurations together:

Terminal window
npx prettier@3.8.4 --check --config .prettierrc.json --ignore-path .prettierignore '**/*.md' '**/*.{yml,yaml}'
editorconfig-checker -config .github/linters/.editorconfig-checker.json
npx markdownlint-cli2@0.22.1 --config .github/linters/.markdown-lint.yml '**/*.md' '#vendor/**' '#runtime/**'

Check changed files and relative links. Use headings or bullets when numbered-list continuations conflict with EditorConfig indentation. For client discovery and activation, see AI assistance.