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 constants with constant values from another class #2624

Closed
simitter opened this issue Jan 15, 2020 · 1 comment
Closed

Array constants with constant values from another class #2624

simitter opened this issue Jan 15, 2020 · 1 comment
Labels

Comments

@simitter
Copy link

Hi

followup to #2621

The InvalidArgument is still triggered if the constant array consists of constants defined in another class.

Demo:
https://psalm.dev/r/9d3ee9ba8f

kind regards

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/9d3ee9ba8f
<?php
class Credentials
{
  public const ALL  = 'all';
  public const OWN  = 'own';
  public const NONE = 'none';
}
  
class Test
{
  public const VALUES = [
    Credentials::ALL,
    Credentials::OWN
  ];
}
  
/**
 * @psalm-param 'all'|'own'|'none'|list<'all'|'own'|'none'> $value
 */
function test($value): void {
  print_r($value);
}

$array = [
  Credentials::ALL,
  Credentials::OWN
];

test(Credentials::ALL);
test([Credentials::ALL, Credentials::OWN]);
test($array);
test(Test::VALUES);
Psalm output (using commit 389af1b):

ERROR: InvalidArgument - 32:6 - Argument 1 of test expects list<string(all)|string(none)|string(own)>|string(all)|string(none)|string(own), array{0: string(all), 1: string(own)} provided

@muglug muglug added the bug label Jan 15, 2020
@muglug muglug closed this as completed in d434f7f Jan 15, 2020
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