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

array_replace_recursive() return type #2925

Closed
shira-374 opened this issue Mar 6, 2020 · 1 comment
Closed

array_replace_recursive() return type #2925

shira-374 opened this issue Mar 6, 2020 · 1 comment
Labels

Comments

@shira-374
Copy link

Both array_replace() and array_replace_recursive() are documented to return NULL "if an error occurs", but Psalm treats them differently:

https://psalm.dev/r/35615780e3

I'd expect no errors since this should be covered by ignoreInternalFunctionNullReturn.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/35615780e3
<?php
  
function example(): array
{
	return array_replace_recursive([], []);
}

function example2(): array
{
	return array_replace([], []);
}
Psalm output (using commit 7ea06c7):

ERROR: NullableReturnStatement - 5:9 - The declared return type 'array<array-key, mixed>' for example is not nullable, but the function returns 'array<array-key, mixed>|null'

ERROR: InvalidNullableReturnType - 3:21 - The declared return type 'array<array-key, mixed>' for example is not nullable, but 'array<array-key, mixed>|null' contains null

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

No branches or pull requests

2 participants