mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 12:06:56 +00:00
Implement template annotation for getExtension and getRuntime
Improves static analysis for caller of this methods
This commit is contained in:
committed by
Michael Telgmann
parent
b8cd4d4032
commit
110871d1de
+11
-2
@@ -548,6 +548,13 @@ class Environment
|
||||
$this->runtimeLoaders[] = $loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template TExtension of ExtensionInterface
|
||||
*
|
||||
* @param class-string<TExtension> $class
|
||||
*
|
||||
* @return TExtension
|
||||
*/
|
||||
public function getExtension(string $class): ExtensionInterface
|
||||
{
|
||||
return $this->extensionSet->getExtension($class);
|
||||
@@ -556,9 +563,11 @@ class Environment
|
||||
/**
|
||||
* Returns the runtime implementation of a Twig element (filter/function/tag/test).
|
||||
*
|
||||
* @param string $class A runtime class name
|
||||
* @template TRuntime of object
|
||||
*
|
||||
* @return object The runtime implementation
|
||||
* @param class-string<TRuntime> $class A runtime class name
|
||||
*
|
||||
* @return TRuntime The runtime implementation
|
||||
*
|
||||
* @throws RuntimeError When the template cannot be found
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user