Skip to content

Commit

Permalink
make some classes final (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher authored Sep 20, 2021
1 parent bfcb0ba commit c0fb196
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 62 deletions.
5 changes: 1 addition & 4 deletions src/DAMAMenuBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
* @final
*/
class DAMAMenuBundle extends Bundle
final class DAMAMenuBundle extends Bundle
{
public function build(ContainerBuilder $container): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

/**
* @final
*/
class NodeVisitorCompilerPass implements CompilerPassInterface
final class NodeVisitorCompilerPass implements CompilerPassInterface
{
use PriorityTaggedServiceTrait;

Expand Down
5 changes: 1 addition & 4 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
* @final
*/
class Configuration implements ConfigurationInterface
final class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder(): TreeBuilder
{
Expand Down
5 changes: 1 addition & 4 deletions src/DependencyInjection/DAMAMenuExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

/**
* @final
*/
class DAMAMenuExtension extends Extension
final class DAMAMenuExtension extends Extension
{
public const NODE_FACTORY_SERVICE_ID_PREFIX = 'dama_menu.node_factory.custom.';
public const TREE_BUILDER_SERVICE_ID_PREFIX = 'dama_menu.tree_builder.custom.';
Expand Down
13 changes: 5 additions & 8 deletions src/Menu/MenuFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,22 @@
use DAMA\MenuBundle\Node\Node;
use DAMA\MenuBundle\Node\NodeFactoryInterface;

/**
* @final
*/
class MenuFactory implements MenuFactoryInterface
final class MenuFactory implements MenuFactoryInterface
{
/**
* @var MenuConfigProvider
*/
protected $menuConfigProvider;
private $menuConfigProvider;

/**
* @var MenuTreeTraverserInterface
*/
protected $menuTreeTraverser;
private $menuTreeTraverser;

/**
* @var array<string, Node>
*/
protected $cache = [];
private $cache = [];

public function __construct(MenuConfigProvider $menuConfigProvider, MenuTreeTraverserInterface $menuTreeTraverser)
{
Expand All @@ -53,7 +50,7 @@ public function create(string $name): Node
return $root;
}

protected function getRootNode(NodeFactoryInterface $nodeFactory, MenuTreeBuilderInterface $menuTreeBuilder): Node
private function getRootNode(NodeFactoryInterface $nodeFactory, MenuTreeBuilderInterface $menuTreeBuilder): Node
{
$root = $nodeFactory->create(null);
$menuTreeBuilder->build($root);
Expand Down
7 changes: 2 additions & 5 deletions src/MenuConfig/MenuConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

namespace DAMA\MenuBundle\MenuConfig;

/**
* @final
*/
class MenuConfigProvider
final class MenuConfigProvider
{
/**
* @var array<string, array>
*/
protected $configs = [];
private $configs = [];

/**
* @param array<string, mixed> $config
Expand Down
7 changes: 2 additions & 5 deletions src/MenuTree/MenuTreeTraverser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
use DAMA\MenuBundle\Node\Node;
use DAMA\MenuBundle\NodeVisitor\NodeVisitorInterface;

/**
* @final
*/
class MenuTreeTraverser implements MenuTreeTraverserInterface
final class MenuTreeTraverser implements MenuTreeTraverserInterface
{
/**
* @var NodeVisitorInterface[]
*/
protected $visitors = [];
private $visitors = [];

public function traverse(Node $node): void
{
Expand Down
5 changes: 1 addition & 4 deletions src/Node/NodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

namespace DAMA\MenuBundle\Node;

/**
* @final
*/
class NodeFactory implements NodeFactoryInterface
final class NodeFactory implements NodeFactoryInterface
{
public function create(?string $label = null): Node
{
Expand Down
6 changes: 2 additions & 4 deletions src/NodeVisitor/NodeActivator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@

/**
* This visitor will set a node to active if one of its routes matches the current route of the request.
*
* @final
*/
class NodeActivator implements NodeVisitorInterface
final class NodeActivator implements NodeVisitorInterface
{
/**
* @var RequestStack
*/
protected $requestStack;
private $requestStack;

public function __construct(RequestStack $requestStack)
{
Expand Down
4 changes: 1 addition & 3 deletions src/NodeVisitor/NodeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@

/**
* This visitor will remove the node from the tree if not all necessary permissions are granted.
*
* @final
*/
class NodeFilter implements NodeVisitorInterface
final class NodeFilter implements NodeVisitorInterface
{
/**
* @var TokenStorageInterface
Expand Down
4 changes: 1 addition & 3 deletions src/NodeVisitor/NodeRoutePropagator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

/**
* This visitor will propagate the route of the current node to the direct parent if it does not have a route yet.
*
* @final
*/
class NodeRoutePropagator implements NodeVisitorInterface
final class NodeRoutePropagator implements NodeVisitorInterface
{
/**
* {@inheritdoc}
Expand Down
5 changes: 1 addition & 4 deletions src/Twig/MenuExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

/**
* @final
*/
class MenuExtension extends AbstractExtension
final class MenuExtension extends AbstractExtension
{
public function getFunctions(): array
{
Expand Down
5 changes: 1 addition & 4 deletions src/Twig/MenuRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
use Twig\Extension\RuntimeExtensionInterface;
use Twig\TemplateWrapper;

/**
* @final
*/
class MenuRuntime implements RuntimeExtensionInterface
final class MenuRuntime implements RuntimeExtensionInterface
{
/**
* @var Environment
Expand Down
9 changes: 3 additions & 6 deletions tests/Menu/MenuFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function setUp(): void
{
$this->nodeFactory = $this->createMock(NodeFactoryInterface::class);
$this->treeBuilder = $this->createMock(MenuTreeBuilderInterface::class);
$this->menuConfigProvider = $this->createMock(MenuConfigProvider::class);
$this->menuConfigProvider = new MenuConfigProvider();
$this->menuTreeTraverser = $this->createMock(MenuTreeTraverserInterface::class);

$this->menuFactory = new MenuFactory($this->menuConfigProvider, $this->menuTreeTraverser);
Expand All @@ -49,13 +49,10 @@ public function testCreate(): void
;

$this->menuConfigProvider
->expects($this->once())
->method('getMenuConfig')
->with('name')
->will($this->returnValue([
->addMenuConfig('name', [
'tree_builder' => $this->treeBuilder,
'node_factory' => $this->nodeFactory,
]))
])
;

$this->menuTreeTraverser
Expand Down

0 comments on commit c0fb196

Please sign in to comment.