Fix phpstan/phpstan#14443: bisect command#5431
Merged
ondrejmirtes merged 3 commits intophpstan:2.1.xfrom Apr 8, 2026
Merged
Conversation
- New `phpstan bisect` command that performs binary search between two releases - Downloads phpstan.phar for each tested commit from the phpstan/phpstan repo - Queries GitHub API (Compare endpoint) for commit list between releases - Reads GitHub token from GITHUB_TOKEN/GH_TOKEN env vars or ~/.composer/auth.json - Runs analysis with downloaded phar and asks user if result is good or bad - Reports first bad commit with phpstan-src commit links from commit description - Tests for command configuration, token reading, and argument building
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
Implements a new
phpstan bisectcommand that performs a git-bisect-like binary search over PHPStan releases to find the first commit that introduced a regression. This is useful for debugging regressions that are only reproducible with complex project configurations where using phpstan-src directly isn't feasible.Changes
src/Command/BisectCommand.php— new Symfony Console command implementing the bisect workflowbin/phpstanto register the newBisectCommandtests/PHPStan/Command/BisectCommandTest.phpwith tests for command configuration, GitHub token resolution, argument building, and non-interactive error handlingHow it works
phpstan bisectand provides a "good" (working) and "bad" (broken) release version, either via--good/--badoptions or interactivelyphpstan/phpstanphpstan.pharfrom raw.githubusercontent.com, runs analysis, and asks the user whether the result is "good" or "bad"Key design decisions
GITHUB_TOKEN/GH_TOKENenv vars (CI-friendly) or~/.composer/auth.json(developer-friendly)sys_get_temp_dir()/phpstan-bisect/to avoid re-downloading on repeated bisect runs-c,-l,-a,--memory-limit, paths) to the downloaded pharCommandHelper::begin()or the DI container since it runs external phar processesTest
BisectCommandTestverifies:--good/--badare missingbuildAnalyseArgscorrectly builds the command-line string from input optionsFixes phpstan/phpstan#14443