Skip to content

Fix non regression test#5444

Merged
VincentLanglet merged 1 commit intophpstan:2.1.xfrom
VincentLanglet:fix1429
Apr 12, 2026
Merged

Fix non regression test#5444
VincentLanglet merged 1 commit intophpstan:2.1.xfrom
VincentLanglet:fix1429

Conversation

@VincentLanglet
Copy link
Copy Markdown
Contributor

While working on #5386 I understood why the fix seemed to introduce a regression on bug-14249 file.

It's because the test

function doTemplated(): void {
	$f1 = assertIfTemplated(...);
	$f2 = 'Bug14249\assertIfTemplated';

	$v = getMixed();
	assertIfTemplated($v, true);
	assertType('true', $v);

	$v = getMixed();
	$f1($v, true);
	assertType('true', $v);

	$v = getMixed();
	$f2($v, true);
	assertType('true', $v);

	$v = getMixed();
	assertIfTemplated($v, false);
	assertType('false', $v);

	$v = getMixed();
	$f1($v, false);
	assertType('false', $v);

	$v = getMixed();
	$f2($v, false);
	assertType('false', $v);
}

is basically wrong.

Since getMixed is considered pure by default, it will return the same value.
If you call assertIfTemplated($v, true); the first time, it's expected to consider that getMixed will allway return a truthy value.

Then assertIfTemplated($v, false); would gives NEVER.

@phpstan-bot
Copy link
Copy Markdown
Collaborator

You've opened the pull request against the latest branch 2.2.x. PHPStan 2.2 is not going to be released for months. If your code is relevant on 2.1.x and you want it to be released sooner, please rebase your pull request and change its target to 2.1.x.

@VincentLanglet VincentLanglet changed the base branch from 2.2.x to 2.1.x April 11, 2026 22:42
@VincentLanglet VincentLanglet marked this pull request as ready for review April 11, 2026 22:56
@phpstan-bot
Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

@VincentLanglet VincentLanglet requested a review from staabm April 11, 2026 22:57
@VincentLanglet VincentLanglet merged commit baa12d1 into phpstan:2.1.x Apr 12, 2026
432 of 434 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants