Skip to content
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

fix counting array properties when some are Never #6971

Merged
merged 1 commit into from Nov 23, 2021

Conversation

orklah
Copy link
Collaborator

@orklah orklah commented Nov 22, 2021

This should fix #6969

There are still weird behaviours in here, for example in https://psalm.dev/r/522d483a64, removing the standalone if(rand(0,1)) condition mask the issue, so I guess Psalm perform some simplifications in arrays shapes when closing a condition or something like that.

However, this change is not dirty nor harmful and will improve the situation, so it should not be an issue

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/522d483a64
<?php

/** @var non-empty-array $report_data */
$report_data = [];
if ( array_key_exists( 'A', $report_data ) ) {
} elseif ( !empty( $report_data[0]['type'] ) && rand(0,1) ) {
    if ( rand(0,1) ) {}

    if ( count( $report_data ) === 1 ) {
    }
}
Psalm output (using commit 9943efb):

ERROR: TypeDoesNotContainType - 9:10 - int<2, max> cannot be identical to 1

@orklah orklah added the release:fix The PR will be included in 'Fixes' section of the release notes label Nov 22, 2021
@orklah orklah merged commit b42c281 into vimeo:master Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix The PR will be included in 'Fixes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weird TypeDoesNotContainType
1 participant