mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-20 14:36:57 +00:00
minor #3541 Implement template annotation for getExtension (mitelg)
This PR was merged into the 3.x branch.
Discussion
----------
Implement template annotation for `getExtension`
Hello there 🙂 👋
my first PR here 😉
This change would help to improve static analysis with tools like PHPStan and Psalm.
Commits
-------
110871d1 Implement template annotation for `getExtension` and `getRuntime`
This commit is contained in:
+11
-2
@@ -557,6 +557,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);
|
||||
@@ -565,9 +572,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