Skip to content

Commit 6f9c1b0

Browse files
authored
Merge pull request #53 from sserbin/fix-twig-312-undefined-function
fix twig 3.12 compat with failing to detect default function
2 parents 0b7cc4d + 4dcd506 commit 6f9c1b0

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/StubEnvironment.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,12 @@ public function getFilter($name): ?TwigFilter
4141
public function getFunction($name): ?TwigFunction
4242
{
4343
/**
44-
* @var string[]
4544
* @psalm-suppress InternalMethod
4645
*/
47-
$defaultFunctions = array_keys(parent::getFunctions());
48-
$isDefault = isset($defaultFunctions[$name]);
46+
$defaultFunction = parent::getFunction($name);
4947

50-
if ($isDefault) { // don't attempt to stub twig's builtin function
51-
/** @psalm-suppress InternalMethod */
52-
return parent::getFunction($name) ?: null;
48+
if ($defaultFunction) { // don't attempt to stub twig's builtin function
49+
return $defaultFunction;
5350
}
5451

5552
return new TwigFunction((string)$name, $this->noop(), [

0 commit comments

Comments
 (0)