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

Mixed Coercion on lists #9049

Closed
orklah opened this issue Jan 3, 2023 · 1 comment · Fixed by #9598
Closed

Mixed Coercion on lists #9049

orklah opened this issue Jan 3, 2023 · 1 comment · Fixed by #9598

Comments

@orklah
Copy link
Collaborator

orklah commented Jan 3, 2023

https://psalm.dev/r/ef00fa13a3
Should raise the same issues as
https://psalm.dev/r/98e1649070

in order to be raised at level 1 instead of level 3

ping @danog

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/ef00fa13a3
<?php

/**
 * @return list<string>
 */
function foo(){
    /**
     * @var list<mixed>
     */
  return [];   
}
Psalm output (using commit 3560ef7):

INFO: LessSpecificReturnStatement - 10:10 - The type 'list<mixed>' is more general than the declared return type 'list<string>' for foo

INFO: MoreSpecificReturnType - 4:12 - The declared return type 'list<string>' for foo is more specific than the inferred return type 'list<mixed>'
https://psalm.dev/r/98e1649070
<?php

/**
 * @return array<string>
 */
function foo(){
    /**
     * @var array<mixed>
     */
  return [];   
}
Psalm output (using commit 3560ef7):

INFO: MixedReturnTypeCoercion - 10:10 - The type 'array<array-key, mixed>' is more general than the declared return type 'array<array-key, string>' for foo

INFO: MixedReturnTypeCoercion - 4:12 - The declared return type 'array<array-key, string>' for foo is more specific than the inferred return type 'array<array-key, mixed>'

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

Successfully merging a pull request may close this issue.

1 participant