Skip to content

Commit

Permalink
Drop support for Symfony <4.4 (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean85 committed Jun 28, 2022
1 parent 5aaee42 commit 6db5a35
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 464 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/tests.yaml
Expand Up @@ -24,7 +24,6 @@ jobs:
- '8.0'
- '8.1'
symfony-version:
- 3.4.*
- 4.4.*
- 5.*
- 6.*
Expand All @@ -37,14 +36,7 @@ jobs:
symfony-version: 6.*
- php: '7.4'
symfony-version: 6.*
- php: '8.0'
symfony-version: 3.4.*
- php: '8.1'
symfony-version: 3.4.*
include:
- php: '7.2'
symfony-version: 3.4.*
dependencies: lowest
- php: '7.2'
symfony-version: 4.4.*
dependencies: lowest
Expand All @@ -71,10 +63,6 @@ jobs:
- name: Setup Problem Matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Remove Symfony Messenger
run: composer remove --dev symfony/messenger --no-update
if: matrix.symfony-version == '3.4.*'

- name: Install dependencies
uses: ramsey/composer-install@v1
with:
Expand All @@ -100,7 +88,7 @@ jobs:
include:
- php: '7.2'
dependencies: lowest
symfony-version: 3.4.*
symfony-version: 4.4.*
- php: '7.4'
dependencies: highest
- php: '8.0'
Expand Down
26 changes: 13 additions & 13 deletions composer.json
Expand Up @@ -28,14 +28,14 @@
"php-http/discovery": "^1.11",
"sentry/sdk": "^3.2",
"symfony/cache-contracts": "^1.1||^2.4||^3.0",
"symfony/config": "^3.4.44||^4.4.20||^5.0.11||^6.0",
"symfony/console": "^3.4.44||^4.4.20||^5.0.11||^6.0",
"symfony/dependency-injection": "^3.4.44||^4.4.20||^5.0.11||^6.0",
"symfony/event-dispatcher": "^3.4.44||^4.4.20||^5.0.11||^6.0",
"symfony/http-kernel": "^3.4.44||^4.4.20||^5.0.11||^6.0",
"symfony/config": "^4.4.20||^5.0.11||^6.0",
"symfony/console": "^4.4.20||^5.0.11||^6.0",
"symfony/dependency-injection": "^4.4.20||^5.0.11||^6.0",
"symfony/event-dispatcher": "^4.4.20||^5.0.11||^6.0",
"symfony/http-kernel": "^4.4.20||^5.0.11||^6.0",
"symfony/polyfill-php80": "^1.22",
"symfony/psr-http-message-bridge": "^1.2||^2.0",
"symfony/security-core": "^3.4.44||^4.4.20||^5.0.11||^6.0"
"symfony/security-core": "^4.4.20||^5.0.11||^6.0"
},
"require-dev": {
"doctrine/dbal": "^2.13||^3.0",
Expand All @@ -50,16 +50,16 @@
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpunit/phpunit": "^8.5.14||^9.3.9",
"symfony/browser-kit": "^3.4.44||^4.4.20||^5.0.11||^6.0",
"symfony/cache": "^3.4.44||^4.4.20||^5.0.11||^6.0",
"symfony/dom-crawler": "^3.4.44||^4.4.20||^5.0.11||^6.0",
"symfony/framework-bundle": "^3.4.44||^4.4.20||^5.0.11||^6.0",
"symfony/browser-kit": "^4.4.20||^5.0.11||^6.0",
"symfony/cache": "^4.4.20||^5.0.11||^6.0",
"symfony/dom-crawler": "^4.4.20||^5.0.11||^6.0",
"symfony/framework-bundle": "^4.4.20||^5.0.11||^6.0",
"symfony/messenger": "^4.4.20||^5.0.11||^6.0",
"symfony/monolog-bundle": "^3.4",
"symfony/phpunit-bridge": "^5.2.6||^6.0",
"symfony/process": "^3.4.44||^4.4.20||^5.0.11||^6.0",
"symfony/twig-bundle": "^3.4.44||^4.4.20||^5.0.11||^6.0",
"symfony/yaml": "^3.4.44||^4.4.20||^5.0.11||^6.0",
"symfony/process": "^4.4.20||^5.0.11||^6.0",
"symfony/twig-bundle": "^4.4.20||^5.0.11||^6.0",
"symfony/yaml": "^4.4.20||^5.0.11||^6.0",
"vimeo/psalm": "^4.3"
},
"suggest": {
Expand Down
85 changes: 0 additions & 85 deletions phpstan-baseline.neon
Expand Up @@ -150,11 +150,6 @@ parameters:
count: 1
path: src/EventListener/ConsoleCommandListener.php

-
message: "#^Else branch is unreachable because previous condition is always true\\.$#"
count: 1
path: src/EventListener/ErrorListener.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent\\:\\:isMasterRequest\\(\\)\\.$#"
count: 1
Expand Down Expand Up @@ -280,101 +275,21 @@ parameters:
count: 1
path: tests/End2End/TracingEnd2EndTest.php

-
message: "#^Call to method getException\\(\\) on an unknown class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent\\.$#"
count: 1
path: tests/EventListener/ErrorListenerTest.php

-
message: "#^Instantiated class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent not found\\.$#"
count: 1
path: tests/EventListener/ErrorListenerTest.php

-
message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\ErrorListener\\:\\:handleExceptionEvent\\(\\) expects Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\ExceptionEvent, Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\ExceptionEvent\\|Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent given\\.$#"
count: 1
path: tests/EventListener/ErrorListenerTest.php

-
message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\ErrorListenerTest\\:\\:testHandleExceptionEvent\\(\\) has invalid type Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent\\.$#"
count: 1
path: tests/EventListener/ErrorListenerTest.php

-
message: "#^Class Symfony\\\\Component\\\\Messenger\\\\Event\\\\WorkerMessageFailedEvent constructor invoked with 4 parameters, 3 required\\.$#"
count: 1
path: tests/EventListener/MessengerListenerTest.php

-
message: "#^If condition is always false\\.$#"
count: 1
path: tests/EventListener/MessengerListenerTest.php

-
message: "#^Call to function method_exists\\(\\) with \\$this\\(Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\AuthenticatedTokenStub\\) and 'setAuthenticated' will always evaluate to false\\.$#"
count: 1
path: tests/EventListener/RequestListenerTest.php

-
message: "#^Instantiated class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\FilterControllerEvent not found\\.$#"
count: 3
path: tests/EventListener/RequestListenerTest.php

-
message: "#^Instantiated class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent not found\\.$#"
count: 9
path: tests/EventListener/RequestListenerTest.php

-
message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListener\\:\\:handleKernelControllerEvent\\(\\) expects Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\ControllerEvent, Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\ControllerEvent\\|Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\FilterControllerEvent given\\.$#"
count: 1
path: tests/EventListener/RequestListenerTest.php

-
message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListener\\:\\:handleKernelRequestEvent\\(\\) expects Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\RequestEvent, Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent\\|Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\RequestEvent given\\.$#"
count: 1
path: tests/EventListener/RequestListenerTest.php

-
message: "#^Parameter \\#1 \\$user of method Symfony\\\\Component\\\\Security\\\\Core\\\\Authentication\\\\Token\\\\AbstractToken\\:\\:setUser\\(\\) expects Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface, string\\|Stringable\\|Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface given\\.$#"
count: 1
path: tests/EventListener/RequestListenerTest.php

-
message: "#^Parameter \\$controllerEvent of method Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\RequestListenerTest\\:\\:testHandleKernelControllerEvent\\(\\) has invalid type Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\FilterControllerEvent\\.$#"
count: 1
path: tests/EventListener/RequestListenerTest.php

-
message: "#^Parameter \\$requestEvent of method Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\RequestListenerTest\\:\\:testHandleKernelRequestEvent\\(\\) has invalid type Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent\\.$#"
count: 1
path: tests/EventListener/RequestListenerTest.php

-
message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent\\:\\:isMasterRequest\\(\\)\\.$#"
count: 1
path: tests/EventListener/SubRequestListenerTest.php

-
message: "#^Instantiated class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent not found\\.$#"
count: 2
path: tests/EventListener/SubRequestListenerTest.php

-
message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListener\\:\\:handleKernelRequestEvent\\(\\) expects Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\RequestEvent, Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent\\|Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\RequestEvent given\\.$#"
count: 1
path: tests/EventListener/SubRequestListenerTest.php

-
message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\SubRequestListenerTest\\:\\:isMainRequest\\(\\) expects Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent, Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent\\|Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\RequestEvent given\\.$#"
count: 1
path: tests/EventListener/SubRequestListenerTest.php

-
message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\SubRequestListenerTest\\:\\:testHandleKernelRequestEvent\\(\\) has invalid type Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent\\.$#"
count: 1
path: tests/EventListener/SubRequestListenerTest.php

-
message: "#^Call to an undefined method TCacheAdapter of Symfony\\\\Component\\\\Cache\\\\Adapter\\\\AdapterInterface\\:\\:delete\\(\\)\\.$#"
count: 2
Expand Down
6 changes: 3 additions & 3 deletions src/EventListener/AbstractTracingRequestListener.php
Expand Up @@ -7,6 +7,7 @@
use Sentry\State\HubInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\Routing\Route;

abstract class AbstractTracingRequestListener
Expand Down Expand Up @@ -34,11 +35,10 @@ public function __construct(HubInterface $hub)
* gathering information like the HTTP status code and attaching them as
* tags of the span/transaction.
*
* @param RequestListenerResponseEvent $event The event
* @param ResponseEvent $event The event
*/
public function handleKernelResponseEvent(RequestListenerResponseEvent $event): void
public function handleKernelResponseEvent(ResponseEvent $event): void
{
/** @var Response $response */
$response = $event->getResponse();
$span = $this->hub->getSpan();

Expand Down
10 changes: 3 additions & 7 deletions src/EventListener/ErrorListener.php
Expand Up @@ -30,14 +30,10 @@ public function __construct(HubInterface $hub)
/**
* Handles an exception that happened while running the application.
*
* @param ErrorListenerExceptionEvent $event The event
* @param ExceptionEvent $event The event
*/
public function handleExceptionEvent(ErrorListenerExceptionEvent $event): void
public function handleExceptionEvent(ExceptionEvent $event): void
{
if ($event instanceof ExceptionEvent) {
$this->hub->captureException($event->getThrowable());
} else {
$this->hub->captureException($event->getException());
}
$this->hub->captureException($event->getThrowable());
}
}
10 changes: 6 additions & 4 deletions src/EventListener/RequestListener.php
Expand Up @@ -7,6 +7,8 @@
use Sentry\State\HubInterface;
use Sentry\State\Scope;
use Sentry\UserDataBag;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\User\UserInterface;
Expand Down Expand Up @@ -46,9 +48,9 @@ public function __construct(HubInterface $hub, ?TokenStorageInterface $tokenStor
* This method is called for each request handled by the framework and
* fills the Sentry scope with information about the current user.
*
* @param RequestListenerRequestEvent $event The event
* @param RequestEvent $event The event
*/
public function handleKernelRequestEvent(RequestListenerRequestEvent $event): void
public function handleKernelRequestEvent(RequestEvent $event): void
{
if (!$this->isMainRequest($event)) {
return;
Expand Down Expand Up @@ -81,9 +83,9 @@ public function handleKernelRequestEvent(RequestListenerRequestEvent $event): vo
* This method is called for each request handled by the framework and
* sets the route on the current Sentry scope.
*
* @param RequestListenerControllerEvent $event The event
* @param ControllerEvent $event The event
*/
public function handleKernelControllerEvent(RequestListenerControllerEvent $event): void
public function handleKernelControllerEvent(ControllerEvent $event): void
{
if (!$this->isMainRequest($event)) {
return;
Expand Down
5 changes: 3 additions & 2 deletions src/EventListener/SubRequestListener.php
Expand Up @@ -6,6 +6,7 @@

use Sentry\State\HubInterface;
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;

/**
* This listener ensures that a new {@see \Sentry\State\Scope} is created for
Expand Down Expand Up @@ -34,9 +35,9 @@ public function __construct(HubInterface $hub)
* This method is called for each subrequest handled by the framework and
* pushes a new {@see \Sentry\State\Scope} onto the stack.
*
* @param SubRequestListenerRequestEvent $event The event
* @param RequestEvent $event The event
*/
public function handleKernelRequestEvent(SubRequestListenerRequestEvent $event): void
public function handleKernelRequestEvent(RequestEvent $event): void
{
if ($this->isMainRequest($event)) {
return;
Expand Down
10 changes: 6 additions & 4 deletions src/EventListener/TracingRequestListener.php
Expand Up @@ -7,6 +7,8 @@
use Sentry\Tracing\Transaction;
use Sentry\Tracing\TransactionContext;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Event\TerminateEvent;

/**
* This event listener acts on the master requests and starts a transaction
Expand All @@ -20,9 +22,9 @@ final class TracingRequestListener extends AbstractTracingRequestListener
* This method is called for each subrequest handled by the framework and
* starts a new {@see Transaction}.
*
* @param RequestListenerRequestEvent $event The event
* @param RequestEvent $event The event
*/
public function handleKernelRequestEvent(RequestListenerRequestEvent $event): void
public function handleKernelRequestEvent(RequestEvent $event): void
{
if (!$this->isMainRequest($event)) {
return;
Expand All @@ -47,9 +49,9 @@ public function handleKernelRequestEvent(RequestListenerRequestEvent $event): vo
* This method is called for each request handled by the framework and
* ends the tracing on terminate after the client received the response.
*
* @param RequestListenerTerminateEvent $event The event
* @param TerminateEvent $event The event
*/
public function handleKernelTerminateEvent(RequestListenerTerminateEvent $event): void
public function handleKernelTerminateEvent(TerminateEvent $event): void
{
$transaction = $this->hub->getTransaction();

Expand Down
5 changes: 3 additions & 2 deletions src/EventListener/TracingSubRequestListener.php
Expand Up @@ -7,6 +7,7 @@
use Sentry\Tracing\Span;
use Sentry\Tracing\SpanContext;
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;

/**
* This event listener acts on the sub requests and starts a child span of the
Expand All @@ -18,9 +19,9 @@ final class TracingSubRequestListener extends AbstractTracingRequestListener
* This method is called for each subrequest handled by the framework and
* traces each by starting a new {@see Span}.
*
* @param SubRequestListenerRequestEvent $event The event
* @param RequestEvent $event The event
*/
public function handleKernelRequestEvent(SubRequestListenerRequestEvent $event): void
public function handleKernelRequestEvent(RequestEvent $event): void
{
if ($this->isMainRequest($event)) {
return;
Expand Down

0 comments on commit 6db5a35

Please sign in to comment.