mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Force return type to T
It's currently not a planned feature to allow Psalm to understand the type relationship of class-name => class-instance as the array here is constructed. Ref: https://github.com/vimeo/psalm/issues/1969
This commit is contained in:
parent
f51dd8878a
commit
54f7719a08
@ -50,21 +50,18 @@ final class State implements StateBearer
|
||||
|
||||
/**
|
||||
* @template T as Configurable
|
||||
* @template-typeof T $configurableClass
|
||||
* @param class-string<Configurable> $configurableClass
|
||||
* @template-typeof T $className
|
||||
* @param class-string<T> $className
|
||||
* @return T
|
||||
*/
|
||||
public function get($configurableClass)
|
||||
public function get($className)
|
||||
{
|
||||
if (isset($this->state[$configurableClass])) {
|
||||
return $this->state[$configurableClass];
|
||||
}
|
||||
|
||||
if (! isset(self::$initialCache[$configurableClass])) {
|
||||
self::$initialCache[$configurableClass] = $configurableClass::initial();
|
||||
}
|
||||
|
||||
return self::$initialCache[$configurableClass];
|
||||
/** @var T */
|
||||
return (
|
||||
$this->state[$className]
|
||||
?? self::$initialCache[$className]
|
||||
?? self::$initialCache[$className] = $className::initial()
|
||||
);
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
|
Loading…
x
Reference in New Issue
Block a user