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

count after explode should make keys certain #3017

Closed
BackEndTea opened this issue Mar 25, 2020 · 1 comment
Closed

count after explode should make keys certain #3017

BackEndTea opened this issue Mar 25, 2020 · 1 comment

Comments

@BackEndTea
Copy link
Contributor

Bug report

explode will return a list of strings, so i'd expect that if i call count on that list the key information should be more clear to phpstan.

Code snippet that reproduces the problem

https://psalm.dev/r/b608989bd7

Expected output

I'd expect there to be no issue for psalm.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/b608989bd7
<?php declare(strict_types = 1);

function foo(string $input): void
{
	$out = explode('-', $input);
	if( count($out) === 2) {
		consume($out);
	}
}

/**
 * @param array{0:string, 1: string} $input
 */
function consume(array $input): array{ return $input;}
Psalm output (using commit 4734583):

ERROR: ArgumentTypeCoercion - 7:11 - Argument 1 of consume expects array{0: string, 1: string}, parent type non-empty-list<string> provided

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants