if ($groupFolderStorage === null) { | if ($groupFolderStorage === null) { | ||||
throw new \LogicException('Should not happen: Storage is instance of GroupFolderStorage but no group folder storage found while unwrapping.'); | throw new \LogicException('Should not happen: Storage is instance of GroupFolderStorage but no group folder storage found while unwrapping.'); | ||||
} | } | ||||
/** @psalm-suppress UndefinedMethod */ | |||||
/** | |||||
* @psalm-suppress UndefinedDocblockClass | |||||
* @psalm-suppress UndefinedInterfaceMethod | |||||
*/ | |||||
$cacheId = $cache->getNumericStorageId() . '/' . $groupFolderStorage->getFolderId(); | $cacheId = $cache->getNumericStorageId() . '/' . $groupFolderStorage->getFolderId(); | ||||
} else { | } else { | ||||
$cacheId = $cache->getNumericStorageId(); | $cacheId = $cache->getNumericStorageId(); |
} | } | ||||
/** | /** | ||||
* @template T of IStorage | |||||
* @param class-string<T> $class | |||||
* @return ?T | |||||
* @psalm-template T of IStorage | |||||
* @psalm-param class-string<T> $class | |||||
* @psalm-return T|null | |||||
*/ | */ | ||||
public function getInstanceOfStorage(string $class): ?IStorage { | |||||
public function getInstanceOfStorage(string $class) { | |||||
$storage = $this; | $storage = $this; | ||||
while ($storage->instanceOfStorage(Wrapper::class)) { | |||||
while ($storage instanceof Wrapper) { | |||||
if ($storage instanceof $class) { | if ($storage instanceof $class) { | ||||
break; | break; | ||||
} | } | ||||
$storage = $storage->getWrapperStorage(); | $storage = $storage->getWrapperStorage(); | ||||
} | } | ||||
if (!is_a($storage, $class)) { | |||||
if (!($storage instanceof $class)) { | |||||
return null; | return null; | ||||
} | } | ||||
return $storage; | return $storage; |