Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#8200 - improve inferring the "final"
static
type when calling stat…
…ic methods inside a different class differentiate between `static` defined in a class which CALLS a given static method, and `static` defined in the method which IS CALLED.
- Loading branch information
1 parent
b156892
commit 470885e
Showing
2 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace Psalm\Tests\Template; | ||
|
||
use Psalm\Tests\TestCase; | ||
use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait; | ||
|
||
class Issue8200Test extends TestCase | ||
{ | ||
use ValidCodeAnalysisTestTrait; | ||
|
||
/** | ||
* @return iterable<string,array{string,assertions?:array<string,string>,error_levels?:string[]}> | ||
*/ | ||
public function providerValidCodeParse(): iterable | ||
{ | ||
return [ | ||
'return TemplatedClass<static>' => [ | ||
'<?php | ||
/** | ||
* @template-covariant A | ||
* @psalm-immutable | ||
*/ | ||
final class Maybe | ||
{ | ||
/** | ||
* @param null|A $value | ||
*/ | ||
public function __construct(private $value = null) {} | ||
/** | ||
* @template B | ||
* @param B $value | ||
* @return Maybe<B> | ||
* | ||
* @psalm-pure | ||
*/ | ||
public static function just($value): self | ||
{ | ||
return new self($value); | ||
} | ||
} | ||
abstract class Test | ||
{ | ||
final private function __construct() {} | ||
/** @return Maybe<static> */ | ||
final public static function create(): Maybe | ||
{ | ||
return Maybe::just(new static()); | ||
} | ||
}', | ||
], | ||
]; | ||
} | ||
} |