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

infer non-empty-list/array after isset($arr[$i]) #4441

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

Draft
staabm wants to merge 7 commits into phpstan:2.1.x
base: 2.1.x
Choose a base branch
Loading
from staabm:narr

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Oct 15, 2025

analog #4440 but for isset($arr[$i])

closes phpstan/phpstan#13674

$types = $types->unionWith(
$this->create(
$var->var,
new NonEmptyArrayType(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm interessting.. for some reason this operation makes array loose their template type.

3) PHPStan\Rules\Methods\ReturnTypeRuleTest::testBug7511
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'
+'48: Method Bug7511\HelloWorld::computeForFrontByPosition() should return array<T of Bug7511\PositionEntityInterface&Bug7511\TgEntityInterface> but returns array<Bug7511\PositionEntityInterface&Bug7511\TgEntityInterface>.
 '
/Users/m.staab/dvl/phpstan-src/src/Testing/RuleTestCase.php:179
/Users/m.staab/dvl/phpstan-src/tests/PHPStan/Rules/Methods/ReturnTypeRuleTest.php:759

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the root cause of this errors is, that setExistingOffset on a array<TemplateIntersectionType> leads to a array<IntersectionType> in

grafik

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.

infer non-empty-list after isset($list[$i])

1 participant

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