Skip to content

Commit 853c2a3

Browse files
authored
Fix broken CI (#400)
1 parent fc25405 commit 853c2a3

File tree

8 files changed

+64
-119
lines changed

8 files changed

+64
-119
lines changed

.github/workflows/tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
- uses: actions/cache@v2
7373
with:
7474
path: ~/.composer/cache/files
75-
key: '7.4--'
75+
key: '7.4'
7676
- uses: shivammathur/setup-php@v2
7777
with:
7878
php-version: '7.4'
@@ -86,7 +86,7 @@ jobs:
8686
- uses: actions/cache@v2
8787
with:
8888
path: ~/.composer/cache/files
89-
key: '7.4--'
89+
key: '7.4'
9090
- uses: shivammathur/setup-php@v2
9191
with:
9292
php-version: '7.4'

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
"monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler."
5151
},
5252
"autoload": {
53+
"files": [
54+
"src/aliases.php"
55+
],
5356
"psr-4": {
5457
"Sentry\\SentryBundle\\": "src/"
5558
}

phpstan-baseline.neon

Lines changed: 9 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -30,85 +30,25 @@ parameters:
3030
count: 1
3131
path: src/DependencyInjection/SentryExtension.php
3232

33-
-
34-
message: "#^Class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent not found\\.$#"
35-
count: 1
36-
path: src/EventListener/ErrorListener.php
37-
3833
-
3934
message: "#^Else branch is unreachable because previous condition is always true\\.$#"
4035
count: 1
4136
path: src/EventListener/ErrorListener.php
4237

4338
-
44-
message: "#^Class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent not found\\.$#"
45-
count: 2
46-
path: src/EventListener/RequestListener.php
47-
48-
-
49-
message: "#^Class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent not found\\.$#"
50-
count: 2
51-
path: src/EventListener/RequestListener.php
52-
53-
-
54-
message: "#^Class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent not found\\.$#"
55-
count: 1
56-
path: src/EventListener/RequestListener.php
57-
58-
-
59-
message: "#^Class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\FilterControllerEvent not found\\.$#"
60-
count: 1
61-
path: src/EventListener/RequestListener.php
62-
63-
-
64-
message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListener\\:\\:handleKernelRequestEvent\\(\\) has invalid typehint type Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent\\.$#"
65-
count: 2
66-
path: src/EventListener/RequestListener.php
67-
68-
-
69-
message: "#^Call to method isMasterRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent\\.$#"
70-
count: 1
71-
path: src/EventListener/RequestListener.php
72-
73-
-
74-
message: "#^Call to method getRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerRequestEvent\\.$#"
75-
count: 1
76-
path: src/EventListener/RequestListener.php
77-
78-
-
79-
message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListener\\:\\:handleKernelControllerEvent\\(\\) has invalid typehint type Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent\\.$#"
80-
count: 2
81-
path: src/EventListener/RequestListener.php
82-
83-
-
84-
message: "#^Call to method isMasterRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent\\.$#"
85-
count: 1
86-
path: src/EventListener/RequestListener.php
87-
88-
-
89-
message: "#^Call to method getRequest\\(\\) on an unknown class Sentry\\\\SentryBundle\\\\EventListener\\\\RequestListenerControllerEvent\\.$#"
39+
message: "#^Class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseForExceptionEvent not found\\.$#"
9040
count: 1
91-
path: src/EventListener/RequestListener.php
92-
93-
-
94-
message: "#^Class Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListenerRequestEvent not found\\.$#"
95-
count: 2
96-
path: src/EventListener/SubRequestListener.php
41+
path: src/aliases.php
9742

9843
-
9944
message: "#^Class Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\GetResponseEvent not found\\.$#"
100-
count: 1
101-
path: src/EventListener/SubRequestListener.php
102-
103-
-
104-
message: "#^Parameter \\$event of method Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListener\\:\\:handleKernelRequestEvent\\(\\) has invalid typehint type Sentry\\\\SentryBundle\\\\EventListener\\\\SubRequestListenerRequestEvent\\.$#"
10545
count: 2
106-
path: src/EventListener/SubRequestListener.php
46+
path: src/aliases.php
10747

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

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

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

@@ -271,7 +211,7 @@ parameters:
271211
path: test/EventListener/RequestListenerTest.php
272212

273213
-
274-
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\\.$#"
214+
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\\.$#"
275215
count: 1
276216
path: test/EventListener/RequestListenerTest.php
277217

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

288228
-
289-
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\\.$#"
229+
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\\.$#"
290230
count: 1
291231
path: test/EventListener/RequestListenerTest.php
292232

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

308248
-
309-
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\\.$#"
249+
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\\.$#"
310250
count: 1
311251
path: test/EventListener/SubRequestListenerTest.php
312252

phpunit.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
<filter>
2121
<whitelist>
2222
<directory>./src</directory>
23+
<exclude>
24+
<file>./src/aliases.php</file>
25+
</exclude>
2326
</whitelist>
2427
</filter>
2528

src/EventListener/ErrorListener.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,6 @@
44

55
use Sentry\State\HubInterface;
66
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
7-
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
8-
use Symfony\Component\HttpKernel\Kernel;
9-
10-
if (version_compare(Kernel::VERSION, '4.3.0', '>=')) {
11-
if (! class_exists(ErrorListenerExceptionEvent::class, false)) {
12-
class_alias(ExceptionEvent::class, ErrorListenerExceptionEvent::class);
13-
}
14-
} else {
15-
if (! class_exists(ErrorListenerExceptionEvent::class, false)) {
16-
class_alias(GetResponseForExceptionEvent::class, ErrorListenerExceptionEvent::class);
17-
}
18-
}
197

208
/**
219
* This listener listens for error events and logs them to Sentry.

src/EventListener/RequestListener.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,9 @@
55
use Sentry\State\HubInterface;
66
use Sentry\State\Scope;
77
use Sentry\UserDataBag;
8-
use Symfony\Component\HttpKernel\Event\ControllerEvent;
9-
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
10-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
11-
use Symfony\Component\HttpKernel\Event\RequestEvent;
12-
use Symfony\Component\HttpKernel\Kernel;
138
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
149
use Symfony\Component\Security\Core\User\UserInterface;
1510

16-
if (version_compare(Kernel::VERSION, '4.3.0', '>=')) {
17-
if (! class_exists(RequestListenerRequestEvent::class, false)) {
18-
class_alias(RequestEvent::class, RequestListenerRequestEvent::class);
19-
}
20-
21-
if (! class_exists(RequestListenerControllerEvent::class, false)) {
22-
class_alias(ControllerEvent::class, RequestListenerControllerEvent::class);
23-
}
24-
} else {
25-
if (! class_exists(RequestListenerRequestEvent::class, false)) {
26-
class_alias(GetResponseEvent::class, RequestListenerRequestEvent::class);
27-
}
28-
29-
if (! class_exists(RequestListenerControllerEvent::class, false)) {
30-
class_alias(FilterControllerEvent::class, RequestListenerControllerEvent::class);
31-
}
32-
}
33-
3411
/**
3512
* This listener ensures that a new {@see \Sentry\State\Scope} is created for
3613
* each request and that it is filled with useful information, e.g. the IP

src/EventListener/SubRequestListener.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,6 @@
44

55
use Sentry\State\HubInterface;
66
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
7-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
8-
use Symfony\Component\HttpKernel\Event\RequestEvent;
9-
use Symfony\Component\HttpKernel\Kernel;
10-
11-
if (version_compare(Kernel::VERSION, '4.3.0', '>=')) {
12-
if (! class_exists(SubRequestListenerRequestEvent::class, false)) {
13-
class_alias(RequestEvent::class, SubRequestListenerRequestEvent::class);
14-
}
15-
} else {
16-
if (! class_exists(SubRequestListenerRequestEvent::class, false)) {
17-
class_alias(GetResponseEvent::class, SubRequestListenerRequestEvent::class);
18-
}
19-
}
207

218
/**
229
* This listener ensures that a new {@see \Sentry\State\Scope} is created for

src/aliases.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
use Sentry\SentryBundle\EventListener\ErrorListenerExceptionEvent;
4+
use Sentry\SentryBundle\EventListener\RequestListenerControllerEvent;
5+
use Sentry\SentryBundle\EventListener\RequestListenerRequestEvent;
6+
use Sentry\SentryBundle\EventListener\SubRequestListenerRequestEvent;
7+
use Symfony\Component\HttpKernel\Event\ControllerEvent;
8+
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
9+
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
10+
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
11+
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
12+
use Symfony\Component\HttpKernel\Event\RequestEvent;
13+
use Symfony\Component\HttpKernel\Kernel;
14+
15+
if (version_compare(Kernel::VERSION, '4.3.0', '>=')) {
16+
if (! class_exists(ErrorListenerExceptionEvent::class, false)) {
17+
class_alias(ExceptionEvent::class, ErrorListenerExceptionEvent::class);
18+
}
19+
20+
if (! class_exists(RequestListenerRequestEvent::class, false)) {
21+
class_alias(RequestEvent::class, RequestListenerRequestEvent::class);
22+
}
23+
24+
if (! class_exists(RequestListenerControllerEvent::class, false)) {
25+
class_alias(ControllerEvent::class, RequestListenerControllerEvent::class);
26+
}
27+
28+
if (! class_exists(SubRequestListenerRequestEvent::class, false)) {
29+
class_alias(RequestEvent::class, SubRequestListenerRequestEvent::class);
30+
}
31+
} else {
32+
if (! class_exists(ErrorListenerExceptionEvent::class, false)) {
33+
class_alias(GetResponseForExceptionEvent::class, ErrorListenerExceptionEvent::class);
34+
}
35+
36+
if (! class_exists(RequestListenerRequestEvent::class, false)) {
37+
class_alias(GetResponseEvent::class, RequestListenerRequestEvent::class);
38+
}
39+
40+
if (! class_exists(RequestListenerControllerEvent::class, false)) {
41+
class_alias(FilterControllerEvent::class, RequestListenerControllerEvent::class);
42+
}
43+
44+
if (! class_exists(SubRequestListenerRequestEvent::class, false)) {
45+
class_alias(GetResponseEvent::class, SubRequestListenerRequestEvent::class);
46+
}
47+
}

0 commit comments

Comments
 (0)