Psalm: type of __DIR__ is not inferred in a class constant

Created on 8 May 2020  路  5Comments  路  Source: vimeo/psalm

bug easy problems

All 5 comments

I found these snippets:


https://psalm.dev/r/b73e668896

<?php
class C
{    
    public function foo(): string
    {
        return __DIR__;
    }
}
Psalm output (using commit 4295f95):

No issues!


https://psalm.dev/r/f133ab4d64

<?php

class C 
{
    public const FOO = 'string';

    public function foo(): string
    {
        return self::FOO;
    }
}
Psalm output (using commit 4295f95):

No issues!


https://psalm.dev/r/ce4be3b3b9

<?php

class C
{
    public const FOO = __DIR__;

    public function foo(): string
    {
        return self::FOO;
    }
}
Psalm output (using commit 4295f95):

INFO: MixedReturnStatement - 9:16 - Could not infer a return type

INFO: MixedInferredReturnType - 7:28 - Could not verify return type 'string' for C::foo

Looks like now it fixed, last example produce "No issues!" - https://psalm.dev/r/ce4be3b3b9

I found these snippets:


https://psalm.dev/r/ce4be3b3b9

<?php

class C
{
    public const FOO = __DIR__;

    public function foo(): string
    {
        return self::FOO;
    }
}
Psalm output (using commit 04b6dfd):

No issues!

I believe it's fixed in #3602

Thank you, guys!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tux-rampage picture tux-rampage  路  3Comments

LeSuisse picture LeSuisse  路  3Comments

orklah picture orklah  路  3Comments

greg0ire picture greg0ire  路  3Comments

caugner picture caugner  路  3Comments