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 T as Configurable
|
||||||
* @template-typeof T $configurableClass
|
* @template-typeof T $className
|
||||||
* @param class-string<Configurable> $configurableClass
|
* @param class-string<T> $className
|
||||||
* @return T
|
* @return T
|
||||||
*/
|
*/
|
||||||
public function get($configurableClass)
|
public function get($className)
|
||||||
{
|
{
|
||||||
if (isset($this->state[$configurableClass])) {
|
/** @var T */
|
||||||
return $this->state[$configurableClass];
|
return (
|
||||||
}
|
$this->state[$className]
|
||||||
|
?? self::$initialCache[$className]
|
||||||
if (! isset(self::$initialCache[$configurableClass])) {
|
?? self::$initialCache[$className] = $className::initial()
|
||||||
self::$initialCache[$configurableClass] = $configurableClass::initial();
|
);
|
||||||
}
|
|
||||||
|
|
||||||
return self::$initialCache[$configurableClass];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user