Pular para o conteúdo
PHP Ecosystem
Explore

Testing

Este conteúdo não está disponível em sua língua ainda.

This package provides a consistent set of Composer scripts for local validation.

Tool references:

Run Rector to apply automated code refactoring. This command modifies files.

Terminal window
composer rector

Preview the refactoring without modifying files.

Terminal window
composer rector-check

Check coding standards without modifying files.

Terminal window
composer ecs-check

Apply coding standard fixes. Review the changes before keeping them.

Terminal window
composer ecs

Verify that runtime dependencies are correctly declared in composer.json.

Terminal window
composer check-dependencies

CI runs actionlint, codespell, EditorConfig Checker, markdownlint-cli2, Prettier and yamllint through the shared yii2-framework/actions quality workflow. The repository’s formatting rules stay in .editorconfig.

Make actionlint and ShellCheck available on PATH to lint workflows locally.

Terminal window
composer actionlint

Run static analysis with the Web application configuration (phpstan.neon).

Terminal window
composer static

Run static analysis with the console application configuration (phpstan-console.neon), matching the second CI job.

Terminal window
composer static-console

Static analysis targets PHP 8.3 and runs on PHP 8.3, 8.4, 8.5 and 8.6 in CI, with both configurations.

Run the full type inference suite. The script runs PHPUnit through ParaTest, one worker process per CPU core, without a PHP memory limit.

Terminal window
composer tests

Limit the number of worker processes when needed.

Terminal window
composer tests -- --processes=4

Run a single test file with PHPUnit directly.

Terminal window
vendor/bin/phpunit tests/ServiceMapTest.php

CI runs zizmor and Gitleaks through the shared security workflow. Gitleaks uses its default rules and the allowlist in .github/linters/.gitleaks.toml. The Gitleaks scan requires GITLEAKS_LICENSE in the workflow.

Make zizmor available on PATH to audit the workflows locally with the same pedantic persona.

Terminal window
composer zizmor

Zizmor needs GitHub API access for its online audits. Use the offline flag to run without API access.

Terminal window
composer zizmor -- --offline

Report hosted CI execution and its PHP/OS matrix separately from these local commands. Keep generated reports in ignored internal/.

Composer scripts support forwarding additional arguments using --.

Run the suite with code coverage report generation.

Terminal window
composer tests -- --coverage-html internal/coverage

Run PHPStan with a different memory limit.

Terminal window
composer static -- --memory-limit=512M

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, 8.5 and 8.6. Only the PHP 8.6 jobs pass --ignore-platform-reqs to Composer.

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, so run both composer static and composer static-console.

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.

For client discovery and activation, see AI assistance.

Back to documentation