Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MatchExpressionRule - ignore reportAlwaysTrueInLastCondition #4319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
ondrejmirtes merged 1 commit into phpstan:2.1.x from vrana:match
Sep 12, 2025

Conversation

Copy link
Contributor

@vrana vrana commented Sep 11, 2025

There are other cases where this rule is harmful, I show them in tests.

Doc: phpstan/phpstan#13489

Copy link
Member

Hi, I've said in the past that reportAlwaysTrueInLastCondition has been added for completeness and to match how PHPStan behaved by default in the past, but personally I think no one should use it.

What's your reason to enable it? Where do you see the benefit?

Copy link
Contributor Author

vrana commented Sep 11, 2025

The example from the test seems reasonable to me:

	public function doFoo(int $i, \stdClass $std)
	{
		if ($i) {
		} elseif ($std) { // error only with reportAlwaysTrueInLastCondition
		}
	}

@ondrejmirtes ondrejmirtes merged commit 9c6cabc into phpstan:2.1.x Sep 12, 2025
446 of 457 checks passed
Copy link
Member

Thank you.

@vrana vrana deleted the match branch September 12, 2025 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /