Repository navigation
Analyse tests with PHPStan - #137
Merged
Merged
Conversation
Add the tests/ folder to PHPStan's paths and scan the wp-cli-tests TestCase so PHPStan knows the base class and its polyfilled assertions. Fix the errors this reports: narrow the items yielded by RecursiveIteratorIterator to SplFileInfo with assertInstanceOf() before calling getPathname(). Also switch the setUp()/tearDown() overrides to the Yoast polyfill set_up()/tear_down() fixtures provided by WP_CLI\Tests\TestCase. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UWTd5n3ZupvgHr4fEBJCGp
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Member
Author
|
The failing Behat jobs are all on PHP 8.6, and they fail on the environment rather than on anything this PR changes. It only touches
The last run on Generated by Claude Code |
This was referenced Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PHPStan now analyses the
tests/folder in addition tosrc/anddist-archive-command.php.Changes
phpstan.neon.dist: addteststopaths, and addvendor/wp-cli/wp-cli-tests/tests/includes/TestCase.phptoscanFiles, sinceWP_CLI\Tests\TestCaseis loaded by the wp-cli-tests bootstrap rather than autoloaded.tests/Distignore_Filter_Iterator_Test.php:method.nonObjecterrors: the items yielded byRecursiveIteratorIteratoraremixed, so the test now checks them withassertInstanceOf( SplFileInfo::class, $item )before callinggetPathname().WP_CLI\Tests\TestCase. ItssetUp(): void/tearDown(): voidoverrides are now the Yoast polyfillset_up()/tear_down()fixtures, calling the matching parent methods.No ignores, baseline entries or level changes were added.
Testing
composer phpstan: no errorscomposer phpunit: 10 tests pass. The one PHPUnit deprecation (deprecated XML config schema) was already there before this change.composer phpcs: cleanGenerated by Claude Code
Summary by CodeRabbit