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

Constant resolving from phpdoc doesn't work properly #5639

Closed
SCIF opened this issue Apr 18, 2021 · 1 comment · Fixed by #6133
Closed

Constant resolving from phpdoc doesn't work properly #5639

SCIF opened this issue Apr 18, 2021 · 1 comment · Fixed by #6133

Comments

@SCIF
Copy link
Contributor

SCIF commented Apr 18, 2021

https://psalm.dev/r/65c1a5a247

I added a real property to check whether the syntax working. Union syntax does't work either

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/65c1a5a247
<?php


/**
* @property self::A_* $state
* @property self::A_c|self::A_b $state3
*/
class A {
    private const A_b = '2'; 
    private const A_c = '3';
    
    /** @var self::A_* $state2 */
    private string $state2;
   
    public function __construct() {
        $this->state2 = self::A_b;
    }
      
    public function foo(string $val): bool {
        return $this->state === self::A_b;
    }

    public function bar(string $val): bool {
        return $this->state2 === self::A_b;
    }

    public function baz(string $val): bool {
        return $this->state3 === self::A_b;
    }
    
    private function __get() {}
}
Psalm output (using commit ee778e9):

ERROR: DocblockTypeContradiction - 20:16 - "2" does not contain self::A_*

ERROR: DocblockTypeContradiction - 28:16 - "2" does not contain self::A_b|self::A_c

weirdan added a commit to weirdan/psalm that referenced this issue Jul 18, 2021
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