Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ parameters:
path: src/Knp/Menu/Twig/MenuExtension.php

-
message: "#^Method Knp\\\\Menu\\\\Twig\\\\MenuRuntimeExtension\\:\\:getBreadcrumbsArray\\(\\) has parameter \\$subItem with no value type specified in iterable type array\\.$#"
message: "#^Method Knp\\\\Menu\\\\Twig\\\\MenuRuntime\\:\\:getBreadcrumbsArray\\(\\) has parameter \\$subItem with no value type specified in iterable type array\\.$#"
count: 1
path: src/Knp/Menu/Twig/MenuRuntimeExtension.php
path: src/Knp/Menu/Twig/MenuRuntime.php

-
message: "#^PHPDoc tag @param for parameter \\$subItem with type array\\<int\\|string, array\\<string, Knp\\\\Menu\\\\ItemInterface\\|string\\|null\\>\\|float\\|int\\|Knp\\\\Menu\\\\ItemInterface\\|string\\|null\\>\\|string\\|Traversable\\<mixed, array\\<string, Knp\\\\Menu\\\\ItemInterface\\|string\\|null\\>\\|float\\|int\\|Knp\\\\Menu\\\\ItemInterface\\|string\\|null\\> is not subtype of native type array\\|string\\|null\\.$#"
count: 1
path: src/Knp/Menu/Twig/MenuRuntimeExtension.php
path: src/Knp/Menu/Twig/MenuRuntime.php

18 changes: 9 additions & 9 deletions src/Knp/Menu/Twig/MenuExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class MenuExtension extends AbstractExtension
{
private ?MenuRuntimeExtension $runtimeExtension = null;
private ?MenuRuntime $runtimeExtension = null;

public function __construct(
?Helper $helper = null,
Expand All @@ -21,7 +21,7 @@ public function __construct(
) {
if (null !== $helper) {
@trigger_error('Injecting dependencies is deprecated since v3.6 and will be removed in v4.', E_USER_DEPRECATED);
$this->runtimeExtension = new MenuRuntimeExtension($helper, $matcher, $menuManipulator);
$this->runtimeExtension = new MenuRuntime($helper, $matcher, $menuManipulator);
}
}

Expand All @@ -30,10 +30,10 @@ public function getFunctions(): array
$legacy = null !== $this->runtimeExtension;

return [
new TwigFunction('knp_menu_get', $legacy ? [$this, 'get'] : [MenuRuntimeExtension::class, 'get']),
new TwigFunction('knp_menu_render', $legacy ? [$this, 'render'] : [MenuRuntimeExtension::class, 'render'], ['is_safe' => ['html']]),
new TwigFunction('knp_menu_get_breadcrumbs_array', $legacy ? [$this, 'getBreadcrumbsArray'] : [MenuRuntimeExtension::class, 'getBreadcrumbsArray']),
new TwigFunction('knp_menu_get_current_item', $legacy ? [$this, 'getCurrentItem'] : [MenuRuntimeExtension::class, 'getCurrentItem']),
new TwigFunction('knp_menu_get', $legacy ? [$this, 'get'] : [MenuRuntime::class, 'get']),
new TwigFunction('knp_menu_render', $legacy ? [$this, 'render'] : [MenuRuntime::class, 'render'], ['is_safe' => ['html']]),
new TwigFunction('knp_menu_get_breadcrumbs_array', $legacy ? [$this, 'getBreadcrumbsArray'] : [MenuRuntime::class, 'getBreadcrumbsArray']),
new TwigFunction('knp_menu_get_current_item', $legacy ? [$this, 'getCurrentItem'] : [MenuRuntime::class, 'getCurrentItem']),
];
}

Expand All @@ -42,7 +42,7 @@ public function getFilters(): array
$legacy = null !== $this->runtimeExtension;

return [
new TwigFilter('knp_menu_as_string', $legacy ? [$this, 'pathAsString'] : [MenuRuntimeExtension::class, 'pathAsString']),
new TwigFilter('knp_menu_as_string', $legacy ? [$this, 'pathAsString'] : [MenuRuntime::class, 'pathAsString']),
new TwigFilter('knp_menu_spaceless', [self::class, 'spaceless'], ['is_safe' => ['html']]),
];
}
Expand All @@ -52,8 +52,8 @@ public function getTests(): array
$legacy = null !== $this->runtimeExtension;

return [
new TwigTest('knp_menu_current', $legacy ? [$this, 'isCurrent'] : [MenuRuntimeExtension::class, 'isCurrent']),
new TwigTest('knp_menu_ancestor', $legacy ? [$this, 'isAncestor'] : [MenuRuntimeExtension::class, 'isAncestor']),
new TwigTest('knp_menu_current', $legacy ? [$this, 'isCurrent'] : [MenuRuntime::class, 'isCurrent']),
new TwigTest('knp_menu_ancestor', $legacy ? [$this, 'isAncestor'] : [MenuRuntime::class, 'isAncestor']),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Knp\Menu\Util\MenuManipulator;
use Twig\Extension\RuntimeExtensionInterface;

class MenuRuntimeExtension implements RuntimeExtensionInterface
class MenuRuntime implements RuntimeExtensionInterface
{
public function __construct(
private readonly Helper $helper,
Expand Down
4 changes: 2 additions & 2 deletions tests/Knp/Menu/Tests/Twig/MenuExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Knp\Menu\Matcher\MatcherInterface;
use Knp\Menu\Twig\Helper;
use Knp\Menu\Twig\MenuExtension;
use Knp\Menu\Twig\MenuRuntimeExtension;
use Knp\Menu\Twig\MenuRuntime;
use Knp\Menu\Util\MenuManipulator;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -202,7 +202,7 @@ private function getTemplate(
$twig = new Environment($loader, ['debug' => true, 'cache' => false]);
$twig->addExtension(new MenuExtension());
$twig->addRuntimeLoader(new FactoryRuntimeLoader([
MenuRuntimeExtension::class => fn () => new MenuRuntimeExtension(
MenuRuntime::class => fn () => new MenuRuntime(
$helper,
$matcher,
$menuManipulator,
Expand Down