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

InvalidPropertyAssignmentValue for enum class properties #5308

Closed
Patrick-Remy opened this issue Mar 2, 2021 · 3 comments
Closed

InvalidPropertyAssignmentValue for enum class properties #5308

Patrick-Remy opened this issue Mar 2, 2021 · 3 comments
Labels

Comments

@Patrick-Remy
Copy link
Contributor

It seems that enum types for magic-properties are not supported, and only for params and var declarations.

/**
 * @property self::TYPE_* $magicPropType
 */
class Foo {
  const TYPE_FOO = 'foo';

  
  // Required parse magic properties
  public function __set() {}
}


$foo = new Foo();
$foo->magicPropType = Foo::TYPE_FOO;
ERROR: InvalidPropertyAssignmentValue - 20:23 - $foo->magicPropType with declared type 'self::TYPE_*' cannot be assigned type '"foo"'

https://psalm.dev/r/873cbfdc08

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/873cbfdc08
<?php

/**
 * @property self::TYPE_* $magicPropType
 */
class Foo {
  const TYPE_FOO = 'foo';
  
  /** @var self::TYPE_* */
  public $varPropType = self::TYPE_FOO;
    
  /** @param self::TYPE_* $type */
  public function foo($type): void {}

  // Required parse magic properties
  public function __set() {}
}

$foo = new Foo();
$foo->magicPropType = Foo::TYPE_FOO;
$foo->varPropType = Foo::TYPE_FOO;
$foo->foo(Foo::TYPE_FOO);
Psalm output (using commit 594ef4f):

ERROR: InvalidPropertyAssignmentValue - 20:23 - $foo->magicPropType with declared type 'self::TYPE_*' cannot be assigned type '"foo"'

@flaviovs
Copy link

This looks like a dup of #4344

@orklah
Copy link
Collaborator

orklah commented Jul 10, 2021

Indeed

@orklah orklah closed this as completed Jul 10, 2021
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

4 participants