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

Adding element to array/list should promote it to non-empty #4016

Closed
b1rdex opened this issue Oct 28, 2020 · 2 comments
Closed

Adding element to array/list should promote it to non-empty #4016

b1rdex opened this issue Oct 28, 2020 · 2 comments

Comments

@b1rdex
Copy link
Contributor

b1rdex commented Oct 28, 2020

https://phpstan.org/r/25383d75-a004-43d6-83cf-df864f99c806

<?php declare(strict_types = 1);

/** @param non-empty-list<mixed> $foo */
function sayHello($foo): void
{
}

/** @return list<int> */
function getList(): array {
	return [];
}

$a = getList();
$a[] = 1;
sayHello($a);

I'm not sure if it's possible in the current PHPStan... Just wondering. It'd be great to detect this.

@ondrejmirtes
Copy link
Member

The beginning was easy but then I had to fix all the subsequent bugs... Fixed: phpstan/phpstan-src@d67dae3

@github-actions
Copy link

github-actions bot commented May 9, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants