Skip to content

Remove wrong specification#5445

Merged
staabm merged 2 commits intophpstan:2.1.xfrom
VincentLanglet:fixTypeSpecifier
Apr 12, 2026
Merged

Remove wrong specification#5445
staabm merged 2 commits intophpstan:2.1.xfrom
VincentLanglet:fixTypeSpecifier

Conversation

@VincentLanglet
Copy link
Copy Markdown
Contributor

@VincentLanglet VincentLanglet commented Apr 12, 2026

@VincentLanglet VincentLanglet marked this pull request as ready for review April 12, 2026 08:42
@VincentLanglet VincentLanglet requested a review from staabm April 12, 2026 08:42
@phpstan-bot
Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

@@ -0,0 +1,22 @@
<?php
Copy link
Copy Markdown
Contributor

@staabm staabm Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should log a regular bug for this example and use the bug number as file-name.

having a test file named type-specifier might come in our way with autocompletion or other IDE features when searching for the TypeSpecifier class while doing regular development on the codebase

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed it Pr5445, there is no need to open a issue when it's already described in the pr

{
if (empty($aggregation['field']) && $type !== 'filter') {
return;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add 2 more assertions directly after the IF

	assertType("array<string, mixed>", $aggregation);
	assertType('non-falsy-string', $type);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

continue;
}

$scopeType = $scope->getType($expr);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need a similar fix in processBooleanNotSureConditionalTypes?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but I didn't yet succeed finding a non regression test for processBooleanNotSureConditionalTypes, so I thought about letting this to another PR.

processBooleanNotSureConditionalTypes use intersect rather than remove so it's kinda different.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do agree your example is a bug but the similar changes in processBooleanNotSureConditionalTypes

$scopeType = $scope->getType($expr);
			$conditionType = TypeCombinator::intersect($scopeType, $type);
			if ($scopeType->equals($conditionType)) {
				continue;
			}

			$conditionExpressionTypes[$exprString] = ExpressionTypeHolder::createYes(
				$expr,
				$conditionType,
			);

Does not solve this issue.

I would prefer open an issue about it an run the bot to find a dedicated fix.

This Pr will unlock #5386 which closes ~7 issues

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok - opened a new bug phpstan/phpstan#14455

@VincentLanglet VincentLanglet requested a review from staabm April 12, 2026 09:31
@staabm staabm merged commit 2d99669 into phpstan:2.1.x Apr 12, 2026
660 of 661 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