diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9eb8fda..1c23654 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,8 +1,15 @@
Changelog
=========
+## Version 3.0.0
+
+* Removed Doctrine annotation support. Use PHP 8 attributes instead.
+* Removed `doctrine/annotations` dependency.
+* PHP 8.0 is now the minimum required version.
+
## Version 2.4.0
-* Add support for PHP 8 attributes
+
+* Added PHP 8 attributes as an alternative to Doctrine annotations (deprecated).
## Version 2.0
diff --git a/Controller/PassthruController.php b/Controller/PassthruController.php
index 9a50630..11d7a03 100644
--- a/Controller/PassthruController.php
+++ b/Controller/PassthruController.php
@@ -8,15 +8,12 @@
namespace Webfactory\Bundle\LegacyIntegrationBundle\Controller;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
-use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation as Legacy;
+use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute as Legacy;
class PassthruController
{
- /**
- * @Legacy\Dispatch
- * @Legacy\Passthru
- */
+ #[Legacy\Dispatch]
+ #[Legacy\Passthru]
public function indexAction()
{
}
diff --git a/EventListener/LegacyApplicationDispatchingEventListener.php b/EventListener/LegacyApplicationDispatchingEventListener.php
index a47ea8d..1d3baf4 100644
--- a/EventListener/LegacyApplicationDispatchingEventListener.php
+++ b/EventListener/LegacyApplicationDispatchingEventListener.php
@@ -8,10 +8,8 @@
namespace Webfactory\Bundle\LegacyIntegrationBundle\EventListener;
-use Doctrine\Common\Annotations\Reader;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
-use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\Dispatch;
-use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\Dispatch as DispatchAttribute;
+use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\Dispatch;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\LegacyApplication;
@@ -22,8 +20,6 @@ class LegacyApplicationDispatchingEventListener
*/
private $legacyApplication;
- protected $reader;
-
protected $stopwatch;
/**
@@ -31,10 +27,9 @@ class LegacyApplicationDispatchingEventListener
*/
protected $filters = [];
- public function __construct(LegacyApplication $legacyApplication, Reader $reader)
+ public function __construct(LegacyApplication $legacyApplication)
{
$this->legacyApplication = $legacyApplication;
- $this->reader = $reader;
}
public function addFilter(Filter $filter)
@@ -51,26 +46,16 @@ public function onKernelController(ControllerEvent $event)
$object = new \ReflectionObject($controller[0]);
$method = $object->getMethod($controller[1]);
- $dispatch = false;
- foreach ($this->reader->getMethodAnnotations($method) as $configuration) {
- if ($configuration instanceof Dispatch) {
- $dispatch = true;
- break;
- }
- }
-
- if (!$dispatch && $method->getAttributes(DispatchAttribute::class)) {
- $dispatch = true;
+ if (!$method->getAttributes(Dispatch::class)) {
+ return;
}
- if ($dispatch) {
- $response = $this->legacyApplication->handle($event->getRequest(), $event->getRequestType(), false);
+ $response = $this->legacyApplication->handle($event->getRequest(), $event->getRequestType(), false);
- foreach ($this->filters as $filter) {
- $filter->filter($event, $response);
- if ($event->isPropagationStopped()) {
- break;
- }
+ foreach ($this->filters as $filter) {
+ $filter->filter($event, $response);
+ if ($event->isPropagationStopped()) {
+ break;
}
}
}
diff --git a/Integration/Annotation/Dispatch.php b/Integration/Annotation/Dispatch.php
deleted file mode 100644
index bbe841a..0000000
--- a/Integration/Annotation/Dispatch.php
+++ /dev/null
@@ -1,29 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation;
-
-use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\Dispatch as DispatchAttribute;
-
-/**
- * @Annotation
- * @deprecated Use the attribute instead.
- */
-class Dispatch extends DispatchAttribute
-{
- public function __construct()
- {
- trigger_deprecation(
- 'webfactory/legacy-integration-bundle',
- '2.4.0',
- 'The %s annotation has been deprecated, use the %s attribute instead.',
- __CLASS__,
- DispatchAttribute::class
- );
- }
-}
diff --git a/Integration/Annotation/Filter.php b/Integration/Annotation/Filter.php
deleted file mode 100644
index 853c975..0000000
--- a/Integration/Annotation/Filter.php
+++ /dev/null
@@ -1,31 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation;
-
-use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\Filter as FilterAttribute;
-
-/**
- * @Annotation
- * @deprecated Use the attribute instead.
- */
-class Filter extends FilterAttribute
-{
- public function __construct($values)
- {
- trigger_deprecation(
- 'webfactory/legacy-integration-bundle',
- '2.4.0',
- 'The %s annotation has been deprecated, use the %s attribute instead.',
- __CLASS__,
- FilterAttribute::class
- );
-
- parent::__construct($values['class'] ?? null, $values['service'] ?? null);
- }
-}
diff --git a/Integration/Annotation/IgnoreHeader.php b/Integration/Annotation/IgnoreHeader.php
deleted file mode 100644
index e22192b..0000000
--- a/Integration/Annotation/IgnoreHeader.php
+++ /dev/null
@@ -1,31 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation;
-
-use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\IgnoreHeader as IgnoreHeaderAttribute;
-
-/**
- * @Annotation
- * @deprecated Use the attribute instead.
- */
-class IgnoreHeader extends IgnoreHeaderAttribute
-{
- public function __construct(array $values)
- {
- trigger_deprecation(
- 'webfactory/legacy-integration-bundle',
- '2.4.0',
- 'The %s annotation has been deprecated, use the %s attribute instead.',
- __CLASS__,
- IgnoreHeaderAttribute::class
- );
-
- parent::__construct($values['value']);
- }
-}
diff --git a/Integration/Annotation/IgnoreRedirect.php b/Integration/Annotation/IgnoreRedirect.php
deleted file mode 100644
index 5e8ad0e..0000000
--- a/Integration/Annotation/IgnoreRedirect.php
+++ /dev/null
@@ -1,29 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation;
-
-use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\IgnoreRedirect as IgnoreRedirectAttribute;
-
-/**
- * @Annotation
- * @deprecated Use the attribute instead.
- */
-class IgnoreRedirect extends IgnoreRedirectAttribute
-{
- public function __construct()
- {
- trigger_deprecation(
- 'webfactory/legacy-integration-bundle',
- '2.4.0',
- 'The %s annotation has been deprecated, use the %s attribute instead.',
- __CLASS__,
- IgnoreRedirectAttribute::class
- );
- }
-}
diff --git a/Integration/Annotation/KeepCookies.php b/Integration/Annotation/KeepCookies.php
deleted file mode 100644
index e0c83a3..0000000
--- a/Integration/Annotation/KeepCookies.php
+++ /dev/null
@@ -1,29 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation;
-
-use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\KeepCookies as KeepCookiesAttribute;
-
-/**
- * @Annotation
- * @deprecated Use the attribute instead.
- */
-class KeepCookies extends KeepCookiesAttribute
-{
- public function __construct()
- {
- trigger_deprecation(
- 'webfactory/legacy-integration-bundle',
- '2.4.0',
- 'The %s annotation has been deprecated, use the %s attribute instead.',
- __CLASS__,
- KeepCookiesAttribute::class
- );
- }
-}
diff --git a/Integration/Annotation/KeepHeaders.php b/Integration/Annotation/KeepHeaders.php
deleted file mode 100644
index af17c6c..0000000
--- a/Integration/Annotation/KeepHeaders.php
+++ /dev/null
@@ -1,29 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation;
-
-use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\KeepHeaders as KeepHeadersAttribute;
-
-/**
- * @Annotation
- * @deprecated Use the attribute instead.
- */
-class KeepHeaders extends KeepHeadersAttribute
-{
- public function __construct()
- {
- trigger_deprecation(
- 'webfactory/legacy-integration-bundle',
- '2.4.0',
- 'The %s annotation has been deprecated, use the %s attribute instead.',
- __CLASS__,
- KeepHeadersAttribute::class
- );
- }
-}
diff --git a/Integration/Annotation/Passthru.php b/Integration/Annotation/Passthru.php
deleted file mode 100644
index ca53dc5..0000000
--- a/Integration/Annotation/Passthru.php
+++ /dev/null
@@ -1,29 +0,0 @@
-
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation;
-
-use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\Passthru as PassthruAttribute;
-
-/**
- * @Annotation
- * @deprecated Use the attribute instead.
- */
-class Passthru extends PassthruAttribute
-{
- public function __construct()
- {
- trigger_deprecation(
- 'webfactory/legacy-integration-bundle',
- '2.4.0',
- 'The %s annotation has been deprecated, use the %s attribute instead.',
- __CLASS__,
- PassthruAttribute::class
- );
- }
-}
diff --git a/Integration/Attribute/Filter.php b/Integration/Attribute/Filter.php
index 1af9e97..148a90b 100644
--- a/Integration/Attribute/Filter.php
+++ b/Integration/Attribute/Filter.php
@@ -25,7 +25,7 @@ public function __construct(?string $class = null, ?string $service = null)
$this->service = $service;
if (!$this->class && !$this->service) {
- throw new \Exception('Parameter "class" or "service" is missing in Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\Filter.');
+ throw new \Exception('Parameter "class" or "service" is missing in '.self::class.'.');
}
}
@@ -33,20 +33,20 @@ public function createFilter(ContainerInterface $container)
{
if ($class = $this->class) {
if (!class_exists($class)) {
- throw new \Exception('Unknown class '.$class.' configured with the Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\Filter annotation.');
+ throw new \Exception('Unknown class '.$class.' configured with the '.self::class.' attribute.');
}
$filter = new $class();
}
if ($service = $this->service) {
if (!$container->has($service)) {
- throw new \Exception('Unknown service '.$service.' configured with the Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\Filter annotation.');
+ throw new \Exception('Unknown service '.$service.' configured with the '.self::class.' attribute.');
}
$filter = $container->get($service);
}
if (!$filter instanceof FilterInterface) {
- throw new \Exception('Class '.\get_class($filter).' configured with the Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\Filter annotation is not a Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter.');
+ throw new \Exception('Class '.\get_class($filter).' configured with the '.self::class.' attribute is not a '.FilterInterface::class.'.');
}
return $filter;
diff --git a/Integration/Filter/ControllerAnnotations.php b/Integration/Filter/ControllerAttributes.php
similarity index 67%
rename from Integration/Filter/ControllerAnnotations.php
rename to Integration/Filter/ControllerAttributes.php
index 617b86e..2bbf487 100644
--- a/Integration/Filter/ControllerAnnotations.php
+++ b/Integration/Filter/ControllerAttributes.php
@@ -8,20 +8,17 @@
namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter;
-use Doctrine\Common\Annotations\Reader;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter as FilterInterface;
-class ControllerAnnotations implements FilterInterface
+class ControllerAttributes implements FilterInterface
{
- protected $reader;
protected $container;
- public function __construct(Reader $reader, ContainerInterface $container)
+ public function __construct(ContainerInterface $container)
{
- $this->reader = $reader;
$this->container = $container;
}
@@ -34,15 +31,6 @@ public function filter(ControllerEvent $event, Response $response)
$object = new \ReflectionObject($controller[0]);
$method = $object->getMethod($controller[1]);
- foreach ($this->reader->getMethodAnnotations($method) as $annotation) {
- if ($annotation instanceof Factory) {
- $annotation->createFilter($this->container)->filter($event, $response);
- if ($event->isPropagationStopped()) {
- return;
- }
- }
- }
-
foreach ($method->getAttributes(Factory::class, \ReflectionAttribute::IS_INSTANCEOF) as $attribute) {
$attribute->newInstance()->createFilter($this->container)->filter($event, $response);
if ($event->isPropagationStopped()) {
diff --git a/Integration/Filter/KeepCookiesAndHeadersFilter.php b/Integration/Filter/KeepCookiesAndHeadersFilter.php
index c312791..b6590a8 100644
--- a/Integration/Filter/KeepCookiesAndHeadersFilter.php
+++ b/Integration/Filter/KeepCookiesAndHeadersFilter.php
@@ -8,35 +8,24 @@
namespace Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter;
-use Doctrine\Common\Annotations\Reader;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
-use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\KeepCookies;
-use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Annotation\KeepHeaders;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\KeepCookies as KeepCookiesAttribute;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Attribute\KeepHeaders as KeepHeadersAttribute;
use Webfactory\Bundle\LegacyIntegrationBundle\Integration\Filter as FilterInterface;
class KeepCookiesAndHeadersFilter implements FilterInterface
{
- /** @var Reader */
- private $reader;
-
/** @var Response */
private $legacyResponse;
/** @var KeepHeadersAttribute */
- private $keepHeadersAnnotation;
+ private $keepHeaders;
/** @var KeepCookiesAttribute */
- private $keepCookiesAnnotation;
-
- public function __construct(Reader $reader)
- {
- $this->reader = $reader;
- }
+ private $keepCookies;
public function filter(ControllerEvent $event, Response $response)
{
@@ -49,20 +38,12 @@ public function filter(ControllerEvent $event, Response $response)
$object = new \ReflectionObject($controller[0]);
$method = $object->getMethod($controller[1]);
- foreach ($this->reader->getMethodAnnotations($method) as $annotation) {
- if ($annotation instanceof KeepHeaders) {
- $this->keepHeadersAnnotation = $annotation;
- } elseif ($annotation instanceof KeepCookies) {
- $this->keepCookiesAnnotation = $annotation;
- }
- }
-
foreach ($method->getAttributes(KeepHeadersAttribute::class) as $attribute) {
- $this->keepHeadersAnnotation = $attribute->newInstance();
+ $this->keepHeaders = $attribute->newInstance();
}
foreach ($method->getAttributes(KeepCookiesAttribute::class) as $attribute) {
- $this->keepCookiesAnnotation = $attribute->newInstance();
+ $this->keepCookies = $attribute->newInstance();
}
}
@@ -75,9 +56,9 @@ public function onKernelResponse(ResponseEvent $event)
$response = $event->getResponse();
$legacyHeaders = $this->legacyResponse->headers;
- if ($this->keepHeadersAnnotation) {
+ if ($this->keepHeaders) {
foreach ($legacyHeaders->all() as $name => $values) {
- if ($this->keepHeadersAnnotation->shouldKeep($name)) {
+ if ($this->keepHeaders->shouldKeep($name)) {
foreach ($values as $value) {
$response->headers->set($name, $value);
}
@@ -85,10 +66,10 @@ public function onKernelResponse(ResponseEvent $event)
}
}
- if ($this->keepCookiesAnnotation) {
+ if ($this->keepCookies) {
foreach ($legacyHeaders->getCookies() as $cookie) {
/** @var Cookie $cookie */
- if ($this->keepCookiesAnnotation->shouldKeep($cookie->getName())) {
+ if ($this->keepCookies->shouldKeep($cookie->getName())) {
$response->headers->setCookie($cookie);
}
}
diff --git a/Integration/LegacyApplication.php b/Integration/LegacyApplication.php
index 6210197..e00d0e2 100644
--- a/Integration/LegacyApplication.php
+++ b/Integration/LegacyApplication.php
@@ -46,7 +46,7 @@ public function isDispatched(): bool
public function getResponse(): Response
{
if (null === $this->response) {
- throw new LegacyIntegrationException('The legacy application has not been started or has not generated a response. Maybe the @Dispatch annotation is missing for the current controller?');
+ throw new LegacyIntegrationException('The legacy application has not been started or has not generated a response. Maybe the #[Dispatch] attribute is missing for the current controller?');
}
return $this->response;
diff --git a/Resources/config/services.xml b/Resources/config/services.xml
index 9a52ae2..969afae 100644
--- a/Resources/config/services.xml
+++ b/Resources/config/services.xml
@@ -23,7 +23,7 @@
-
+
diff --git a/UPGRADING.md b/UPGRADING.md
index 2e36534..7ad11b9 100644
--- a/UPGRADING.md
+++ b/UPGRADING.md
@@ -1,2 +1,22 @@
-* The webfactory.integration.filter tag has been renamed to "webfactory_legacy_integration.filter"
+# UPGRADING
+
+## 3.0.0
+
+* Doctrine annotation support has been removed. Replace all annotation usages with PHP 8 attributes:
+ * `@Legacy\Dispatch` → `#[Legacy\Dispatch]`
+ * `@Legacy\Passthru` → `#[Legacy\Passthru]`
+ * `@Legacy\IgnoreRedirect` → `#[Legacy\IgnoreRedirect]`
+ * `@Legacy\IgnoreHeader("some-name")` → `#[Legacy\IgnoreHeader('some-name')]`
+ * `@Legacy\KeepHeaders` → `#[Legacy\KeepHeaders]`
+ * `@Legacy\KeepCookies` → `#[Legacy\KeepCookies]`
+ * `@Legacy\Filter(class="...")` → `#[Legacy\Filter(class: '...')]`
+* The `doctrine/annotations` package is no longer required.
+* PHP 8.0 is now the minimum required version.
+
+## 2.4.0
+* Add support for PHP 8 attributes.
+
+## Older
+
+* The webfactory.integration.filter tag has been renamed to "webfactory_legacy_integration.filter"
diff --git a/composer.json b/composer.json
index cfd3398..24e5bb1 100644
--- a/composer.json
+++ b/composer.json
@@ -18,7 +18,6 @@
"require": {
"ext-tidy": "*",
- "doctrine/annotations": "~1.0",
"psr/container": "^1.0",
"psr/log": "^1.0",
"symfony/config": "^4.3|^5.0|^6.0|^7.0",
@@ -31,6 +30,6 @@
"webfactory/dom": "~1.0, >= 1.0.15"
},
"conflict": {
- "php": "<7.0"
+ "php": " < 8.0"
}
}