diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php
index e914a6a..252620d 100644
--- a/.php-cs-fixer.php
+++ b/.php-cs-fixer.php
@@ -11,7 +11,8 @@
'@Symfony' => true,
'@Symfony:risky' => true,
'protected_to_private' => false,
- 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => false],
+ 'nullable_type_declaration_for_default_null_value' => false,
+ 'get_class_to_class_keyword' => false,
])
->setRiskyAllowed(true)
->setFinder(
diff --git a/README.md b/README.md
index e1d718e..9e8169b 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-Getting Started With BreadcrumbTrailBundle
+Getting Started With BreadcrumbTrailBundle
==========================================
This bundle provides a breadcrumb trail service also known as breadcrumbs or Fil d'Ariane.
diff --git a/composer.json b/composer.json
index 55cf879..099eb1d 100644
--- a/composer.json
+++ b/composer.json
@@ -7,7 +7,7 @@
"license": "MIT",
"require": {
"php": ">=7.2",
- "symfony/framework-bundle": "^4.4|^5.0|^6.0",
+ "symfony/framework-bundle": "^4.4|^5.0|^6.0|^7.0",
"twig/twig": "^2.15|^3.0",
"symfony/deprecation-contracts": "^2.4|^3.0"
},
@@ -22,12 +22,12 @@
"psr-4": { "APY\\BreadcrumbTrailBundle\\": "src/" }
},
"require-dev": {
- "symfony/phpunit-bridge": "^5.0|^6.0",
- "nyholm/symfony-bundle-test": "^v2.0",
+ "symfony/phpunit-bridge": "^5.0|^6.0|^7.0",
+ "nyholm/symfony-bundle-test": "^v2.0|^v3.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.0",
"doctrine/doctrine-bundle": "^v1.0|^v2.0",
- "doctrine/annotations": "^v1.7",
- "symfony/twig-bundle": "^3.4|^4.0|^5.0|^6.0"
+ "doctrine/annotations": "^1.8|^2.0",
+ "symfony/twig-bundle": "^4.0|^5.0|^6.0|^7.0"
},
"autoload-dev": {
"psr-4": { "APY\\BreadcrumbTrailBundle\\": "tests/" }
diff --git a/src/Annotation/Breadcrumb.php b/src/Annotation/Breadcrumb.php
index a6334f3..1d9984f 100644
--- a/src/Annotation/Breadcrumb.php
+++ b/src/Annotation/Breadcrumb.php
@@ -20,12 +20,12 @@ class Breadcrumb
/**
* @var string Title of the breadcrumb
*/
- private $title = null;
+ private $title;
/**
* @var string The name of the route
*/
- private $routeName = null;
+ private $routeName;
/**
* @var mixed An array of parameters for the route
@@ -45,7 +45,7 @@ class Breadcrumb
/**
* @var string Template of the breadcrumb trail
*/
- private $template = null;
+ private $template;
/**
* @var array with additional attributes for the breadcrumb
@@ -61,15 +61,8 @@ class Breadcrumb
* @param ?string $template
* @param array $attributes
*/
- public function __construct(
- $title = null,
- $routeName = null,
- $routeParameters = null,
- $routeAbsolute = null,
- $position = null,
- $template = null,
- $attributes = null
- ) {
+ public function __construct($title = null, $routeName = null, $routeParameters = null, $routeAbsolute = null, $position = null, $template = null, $attributes = null)
+ {
$data = [];
if (\is_string($title)) {
@@ -101,7 +94,7 @@ public function __construct(
foreach ($data['route'] as $key => $value) {
$method = 'setRoute'.$key;
if (!method_exists($this, $method)) {
- throw new \BadMethodCallException(sprintf("Unknown property '%s' for the 'route' parameter on annotation '%s'.", $key, static::class));
+ throw new \BadMethodCallException(\sprintf("Unknown property '%s' for the 'route' parameter on annotation '%s'.", $key, static::class));
}
$this->$method($value);
}
@@ -120,7 +113,7 @@ public function __construct(
$method = 'set'.$key;
if (!method_exists($this, $method)) {
- throw new \BadMethodCallException(sprintf("Unknown property '%s' on annotation '%s'.", $key, static::class));
+ throw new \BadMethodCallException(\sprintf("Unknown property '%s' on annotation '%s'.", $key, static::class));
}
$this->$method($value);
}
diff --git a/src/BreadcrumbTrail/Trail.php b/src/BreadcrumbTrail/Trail.php
index 9a28223..49fa47f 100644
--- a/src/BreadcrumbTrail/Trail.php
+++ b/src/BreadcrumbTrail/Trail.php
@@ -70,7 +70,7 @@ public function getTemplate()
*
* @return self
*
- *@throws \InvalidArgumentException
+ * @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public function add($breadcrumbOrTitle, $routeName = null, $routeParameters = [], $routeAbsolute = true, $position = 0, $attributes = [])
@@ -185,17 +185,11 @@ public function reset()
return $this;
}
- /**
- * {@inheritDoc}
- */
public function count(): int
{
return $this->breadcrumbs->count();
}
- /**
- * {@inheritDoc}
- */
public function getIterator(): \Traversable
{
$this->breadcrumbs->rewind();
@@ -246,7 +240,7 @@ private function retrieveChildObject($object, $function, $varName, array $functi
return \call_user_func([$object, $fullFunctionName]);
}
- throw new \RuntimeException(sprintf('"%s" is not callable.', implode('.', array_merge([$varName], $functions))));
+ throw new \RuntimeException(\sprintf('"%s" is not callable.', implode('.', array_merge([$varName], $functions))));
}
/**
@@ -263,6 +257,6 @@ private function retrieveObjectValue($object, $function, $parameters, $varName,
return \call_user_func_array([$object, $fullFunctionName], $parameters);
}
- throw new \RuntimeException(sprintf('"%s" is not callable.', implode('.', array_merge([$varName], $functions))));
+ throw new \RuntimeException(\sprintf('"%s" is not callable.', implode('.', array_merge([$varName], $functions))));
}
}
diff --git a/src/DependencyInjection/APYBreadcrumbTrailExtension.php b/src/DependencyInjection/APYBreadcrumbTrailExtension.php
index ff0acf4..04a0c18 100644
--- a/src/DependencyInjection/APYBreadcrumbTrailExtension.php
+++ b/src/DependencyInjection/APYBreadcrumbTrailExtension.php
@@ -19,9 +19,6 @@
class APYBreadcrumbTrailExtension extends Extension
{
- /**
- * {@inheritDoc}
- */
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php
index 46e48d6..66cf70a 100644
--- a/src/DependencyInjection/Configuration.php
+++ b/src/DependencyInjection/Configuration.php
@@ -16,7 +16,7 @@
class Configuration implements ConfigurationInterface
{
#[\ReturnTypeWillChange]
- public function getConfigTreeBuilder()
+ public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('apy_breadcrumb_trail');
// BC layer for symfony/config < 4.2
@@ -27,7 +27,7 @@ public function getConfigTreeBuilder()
->scalarNode('template')
->defaultValue('@APYBreadcrumbTrail/breadcrumbtrail.html.twig')
->end()
- ->end()
+ ->end()
;
return $treeBuilder;
diff --git a/src/EventListener/BreadcrumbListener.php b/src/EventListener/BreadcrumbListener.php
index 6978c56..b57c6a7 100644
--- a/src/EventListener/BreadcrumbListener.php
+++ b/src/EventListener/BreadcrumbListener.php
@@ -67,10 +67,12 @@ public function onKernelController(KernelEvent $event)
}
if ($class->isAbstract()) {
- throw new \InvalidArgumentException(sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class));
+ throw new \InvalidArgumentException(\sprintf('Annotations from class "%s" cannot be read as it is abstract.', $class));
}
- if (HttpKernelInterface::MASTER_REQUEST == $event->getRequestType()) {
+ $kernelRequest = \defined(HttpKernelInterface::class.'::MASTER_REQUEST') ? HttpKernelInterface::MASTER_REQUEST : HttpKernelInterface::MAIN_REQUEST;
+
+ if ($kernelRequest == $event->getRequestType()) {
$this->breadcrumbTrail->reset();
// Annotations from class
diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml
index 8d882c4..9fa86f9 100644
--- a/src/Resources/config/services.xml
+++ b/src/Resources/config/services.xml
@@ -19,5 +19,12 @@
+
+
+
+
+
+
+
diff --git a/tests/Twig/BreadcrumbTrailExtensionTest.php b/tests/Twig/BreadcrumbTrailExtensionTest.php
index 3994ddd..1c719d2 100644
--- a/tests/Twig/BreadcrumbTrailExtensionTest.php
+++ b/tests/Twig/BreadcrumbTrailExtensionTest.php
@@ -34,7 +34,12 @@ protected static function createKernel(array $options = []): KernelInterface
*/
public function testTwigFunctionGetsRegistered()
{
- $container = self::getContainer();
+ if (method_exists($this, 'getContainer')) {
+ $container = self::getContainer();
+ } else {
+ self::bootKernel();
+ $container = self::$container;
+ }
/** @var BreadcrumbTrailExtension $extension */
$extension = $container->get(BreadcrumbTrailExtension::class);