Skip to content

Fix build #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Dec 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: '7.4--'
key: '7.4'
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
Expand All @@ -86,7 +86,7 @@ jobs:
- uses: actions/cache@v2
with:
path: ~/.composer/cache/files
key: '7.4--'
key: '7.4'
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler."
},
"autoload": {
"files": [
"src/aliases.php"
],
"psr-4": {
"Sentry\\SentryBundle\\": "src/"
}
Expand Down
78 changes: 9 additions & 69 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -30,85 +30,25 @@ parameters:
count: 1
path: src/DependencyInjection/SentryExtension.php

-
message: "#^Class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent not found\\.$#"
count: 1
path: src/EventListener/ErrorListener.php

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

-
message: "#^Class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent not found\\.$#"
count: 2
path: src/EventListener/RequestListener.php

-
message: "#^Class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent not found\\.$#"
count: 2
path: src/EventListener/RequestListener.php

-
message: "#^Class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent not found\\.$#"
count: 1
path: src/EventListener/RequestListener.php

-
message: "#^Class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\FilterControllerEvent not found\\.$#"
count: 1
path: src/EventListener/RequestListener.php

-
message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListener\\:\\:handleKernelRequestEvent\\(\\) has invalid typehint type Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent\\.$#"
count: 2
path: src/EventListener/RequestListener.php

-
message: "#^Call to method isMasterRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent\\.$#"
count: 1
path: src/EventListener/RequestListener.php

-
message: "#^Call to method getRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent\\.$#"
count: 1
path: src/EventListener/RequestListener.php

-
message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListener\\:\\:handleKernelControllerEvent\\(\\) has invalid typehint type Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent\\.$#"
count: 2
path: src/EventListener/RequestListener.php

-
message: "#^Call to method isMasterRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent\\.$#"
count: 1
path: src/EventListener/RequestListener.php

-
message: "#^Call to method getRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent\\.$#"
message: "#^Class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent not found\\.$#"
count: 1
path: src/EventListener/RequestListener.php

-
message: "#^Class Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListenerRequestEvent not found\\.$#"
count: 2
path: src/EventListener/SubRequestListener.php
path: src/aliases.php

-
message: "#^Class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent not found\\.$#"
count: 1
path: src/EventListener/SubRequestListener.php

-
message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListener\\:\\:handleKernelRequestEvent\\(\\) has invalid typehint type Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListenerRequestEvent\\.$#"
count: 2
path: src/EventListener/SubRequestListener.php
path: src/aliases.php

-
message: "#^Call to method isMasterRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListenerRequestEvent\\.$#"
message: "#^Class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\FilterControllerEvent not found\\.$#"
count: 1
path: src/EventListener/SubRequestListener.php
path: src/aliases.php

-
message: "#^Method Sentry\\\\SentryBundle\\\\Test\\\\DependencyInjection\\\\ConfigurationTest\\:\\:testOptionValuesProcessing\\(\\) has parameter \\$value with no typehint specified\\.$#"
Expand Down Expand Up @@ -221,7 +161,7 @@ parameters:
path: test/End2End/End2EndTest.php

-
message: "#^Comparison operation \"\\<\" between 50108 and 40300 is always false\\.$#"
message: "#^Comparison operation \"\\<\" between 50201 and 40300 is always false\\.$#"
count: 1
path: test/End2End/End2EndTest.php

Expand Down Expand Up @@ -271,7 +211,7 @@ parameters:
path: test/EventListener/RequestListenerTest.php

-
message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListener\\:\\:handleKernelRequestEvent\\(\\) expects Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent, Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent\\|Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\RequestEvent given\\.$#"
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: test/EventListener/RequestListenerTest.php

Expand All @@ -286,7 +226,7 @@ parameters:
path: test/EventListener/RequestListenerTest.php

-
message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListener\\:\\:handleKernelControllerEvent\\(\\) expects Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent, Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\ControllerEvent\\|Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\FilterControllerEvent given\\.$#"
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: test/EventListener/RequestListenerTest.php

Expand All @@ -306,7 +246,7 @@ parameters:
path: test/EventListener/SubRequestListenerTest.php

-
message: "#^Parameter \\#1 \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListener\\:\\:handleKernelRequestEvent\\(\\) expects Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListenerRequestEvent, Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent\\|Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\RequestEvent given\\.$#"
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: test/EventListener/SubRequestListenerTest.php

Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<filter>
<whitelist>
<directory>./src</directory>
<exclude>
<file>./src/aliases.php</file>
</exclude>
</whitelist>
</filter>

Expand Down
12 changes: 0 additions & 12 deletions src/EventListener/ErrorListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@

use Sentry\State\HubInterface;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Kernel;

if (version_compare(Kernel::VERSION, '4.3.0', '>=')) {
if (! class_exists(ErrorListenerExceptionEvent::class, false)) {
class_alias(ExceptionEvent::class, ErrorListenerExceptionEvent::class);
}
} else {
if (! class_exists(ErrorListenerExceptionEvent::class, false)) {
class_alias(GetResponseForExceptionEvent::class, ErrorListenerExceptionEvent::class);
}
}

/**
* This listener listens for error events and logs them to Sentry.
Expand Down
23 changes: 0 additions & 23 deletions src/EventListener/RequestListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,9 @@
use Sentry\State\HubInterface;
use Sentry\State\Scope;
use Sentry\UserDataBag;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\User\UserInterface;

if (version_compare(Kernel::VERSION, '4.3.0', '>=')) {
if (! class_exists(RequestListenerRequestEvent::class, false)) {
class_alias(RequestEvent::class, RequestListenerRequestEvent::class);
}

if (! class_exists(RequestListenerControllerEvent::class, false)) {
class_alias(ControllerEvent::class, RequestListenerControllerEvent::class);
}
} else {
if (! class_exists(RequestListenerRequestEvent::class, false)) {
class_alias(GetResponseEvent::class, RequestListenerRequestEvent::class);
}

if (! class_exists(RequestListenerControllerEvent::class, false)) {
class_alias(FilterControllerEvent::class, RequestListenerControllerEvent::class);
}
}

/**
* This listener ensures that a new {@see \Sentry\State\Scope} is created for
* each request and that it is filled with useful information, e.g. the IP
Expand Down
13 changes: 0 additions & 13 deletions src/EventListener/SubRequestListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@

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

if (version_compare(Kernel::VERSION, '4.3.0', '>=')) {
if (! class_exists(SubRequestListenerRequestEvent::class, false)) {
class_alias(RequestEvent::class, SubRequestListenerRequestEvent::class);
}
} else {
if (! class_exists(SubRequestListenerRequestEvent::class, false)) {
class_alias(GetResponseEvent::class, SubRequestListenerRequestEvent::class);
}
}

/**
* This listener ensures that a new {@see \Sentry\State\Scope} is created for
Expand Down
47 changes: 47 additions & 0 deletions src/aliases.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

use Sentry\SentryBundle\EventListener\ErrorListenerExceptionEvent;
use Sentry\SentryBundle\EventListener\RequestListenerControllerEvent;
use Sentry\SentryBundle\EventListener\RequestListenerRequestEvent;
use Sentry\SentryBundle\EventListener\SubRequestListenerRequestEvent;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Kernel;

if (version_compare(Kernel::VERSION, '4.3.0', '>=')) {
if (! class_exists(ErrorListenerExceptionEvent::class, false)) {
class_alias(ExceptionEvent::class, ErrorListenerExceptionEvent::class);
}

if (! class_exists(RequestListenerRequestEvent::class, false)) {
class_alias(RequestEvent::class, RequestListenerRequestEvent::class);
}

if (! class_exists(RequestListenerControllerEvent::class, false)) {
class_alias(ControllerEvent::class, RequestListenerControllerEvent::class);
}

if (! class_exists(SubRequestListenerRequestEvent::class, false)) {
class_alias(RequestEvent::class, SubRequestListenerRequestEvent::class);
}
} else {
if (! class_exists(ErrorListenerExceptionEvent::class, false)) {
class_alias(GetResponseForExceptionEvent::class, ErrorListenerExceptionEvent::class);
}

if (! class_exists(RequestListenerRequestEvent::class, false)) {
class_alias(GetResponseEvent::class, RequestListenerRequestEvent::class);
}

if (! class_exists(RequestListenerControllerEvent::class, false)) {
class_alias(FilterControllerEvent::class, RequestListenerControllerEvent::class);
}

if (! class_exists(SubRequestListenerRequestEvent::class, false)) {
class_alias(GetResponseEvent::class, SubRequestListenerRequestEvent::class);
}
}