Skip to content

Commit 7fec186

Browse files
Jean85ste93crycleptric
authored
Add support for Symfony 7 (#761)
Co-authored-by: Stefano Arlandini <[email protected]> Co-authored-by: Michael Hoffmann <[email protected]>
1 parent 76b46d2 commit 7fec186

15 files changed

+100
-48
lines changed

.github/workflows/tests.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
- 4.4.*
3333
- 5.*
3434
- 6.*
35+
- 7.*
3536
dependencies:
3637
- highest
3738
exclude:
@@ -41,6 +42,16 @@ jobs:
4142
symfony-version: 6.*
4243
- php: '7.4'
4344
symfony-version: 6.*
45+
- php: '7.2'
46+
symfony-version: 7.*
47+
- php: '7.3'
48+
symfony-version: 7.*
49+
- php: '7.4'
50+
symfony-version: 7.*
51+
- php: '8.0'
52+
symfony-version: 7.*
53+
- php: '8.1'
54+
symfony-version: 7.*
4455
include:
4556
- php: '7.2'
4657
symfony-version: 4.4.*
@@ -51,6 +62,9 @@ jobs:
5162
- php: '8.0'
5263
symfony-version: 6.*
5364
dependencies: lowest
65+
- php: '8.2'
66+
symfony-version: 7.*
67+
dependencies: lowest
5468

5569
steps:
5670
- name: Checkout

.php-cs-fixer.dist.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414
'imports_order' => ['class', 'function', 'const'],
1515
],
1616
'declare_strict_types' => true,
17+
'get_class_to_class_keyword' => false,
1718
'random_api_migration' => true,
1819
'yoda_style' => true,
1920
'self_accessor' => false,
21+
'nullable_type_declaration_for_default_null_value' => false,
22+
'no_null_property_initialization' => false,
2023
'phpdoc_no_useless_inheritdoc' => false,
24+
'no_superfluous_phpdoc_tags' => false,
2125
'phpdoc_to_comment' => false,
2226
'phpdoc_align' => [
2327
'tags' => ['param', 'return', 'throws', 'type', 'var'],

composer.json

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,40 +27,41 @@
2727
"php": "^7.2||^8.0",
2828
"guzzlehttp/psr7": "^1.7 || ^2.0",
2929
"jean85/pretty-package-versions": "^1.5 || ^2.0",
30-
"sentry/sdk": "^3.4",
31-
"sentry/sentry": "^3.20.1",
30+
"sentry/sdk": "^3.6",
31+
"sentry/sentry": "^3.22.1",
3232
"symfony/cache-contracts": "^1.1||^2.4||^3.0",
33-
"symfony/config": "^4.4.20||^5.0.11||^6.0",
34-
"symfony/console": "^4.4.20||^5.0.11||^6.0",
35-
"symfony/dependency-injection": "^4.4.20||^5.0.11||^6.0",
36-
"symfony/event-dispatcher": "^4.4.20||^5.0.11||^6.0",
37-
"symfony/http-kernel": "^4.4.20||^5.0.11||^6.0",
33+
"symfony/config": "^4.4.20||^5.0.11||^6.0||^7.0",
34+
"symfony/console": "^4.4.20||^5.0.11||^6.0||^7.0",
35+
"symfony/dependency-injection": "^4.4.20||^5.0.11||^6.0||^7.0",
36+
"symfony/event-dispatcher": "^4.4.20||^5.0.11||^6.0||^7.0",
37+
"symfony/http-kernel": "^4.4.20||^5.0.11||^6.0||^7.0",
3838
"symfony/polyfill-php80": "^1.22",
39-
"symfony/psr-http-message-bridge": "^1.2||^2.0||^6.4",
40-
"symfony/security-core": "^4.4.20||^5.0.11||^6.0",
41-
"symfony/security-http": "^4.4.20||^5.0.11||^6.0"
39+
"symfony/psr-http-message-bridge": "^1.2||^2.0||^6.4||^7.0",
40+
"symfony/security-core": "^4.4.20||^5.0.11||^6.0||^7.0",
41+
"symfony/security-http": "^4.4.20||^5.0.11||^6.0||^7.0"
4242
},
4343
"require-dev": {
4444
"doctrine/dbal": "^2.13||^3.0",
4545
"doctrine/doctrine-bundle": "^1.12||^2.5",
46-
"friendsofphp/php-cs-fixer": "^2.19||<=3.16.0",
46+
"friendsofphp/php-cs-fixer": "^2.19||^3.40",
47+
"masterminds/html5": "^2.8",
4748
"phpstan/extension-installer": "^1.0",
4849
"phpstan/phpstan": "^1.3",
4950
"phpstan/phpstan-phpunit": "^1.0",
5051
"phpstan/phpstan-symfony": "^1.0",
5152
"phpunit/phpunit": "^8.5.14||^9.3.9",
52-
"symfony/browser-kit": "^4.4.20||^5.0.11||^6.0",
53-
"symfony/cache": "^4.4.20||^5.0.11||^6.0",
54-
"symfony/dom-crawler": "^4.4.20||^5.0.11||^6.0",
55-
"symfony/framework-bundle": "^4.4.20||^5.0.11||^6.0",
56-
"symfony/http-client": "^4.4.20||^5.0.11||^6.0",
57-
"symfony/messenger": "^4.4.20||^5.0.11||^6.0",
53+
"symfony/browser-kit": "^4.4.20||^5.0.11||^6.0||^7.0",
54+
"symfony/cache": "^4.4.20||^5.0.11||^6.0||^7.0",
55+
"symfony/dom-crawler": "^4.4.20||^5.0.11||^6.0||^7.0",
56+
"symfony/framework-bundle": "^4.4.20||^5.0.11||^6.0||^7.0",
57+
"symfony/http-client": "^4.4.20||^5.0.11||^6.0||^7.0",
58+
"symfony/messenger": "^4.4.20||^5.0.11||^6.0||^7.0",
5859
"symfony/monolog-bundle": "^3.4",
59-
"symfony/phpunit-bridge": "^5.2.6||^6.0",
60-
"symfony/process": "^4.4.20||^5.0.11||^6.0",
61-
"symfony/twig-bundle": "^4.4.20||^5.0.11||^6.0",
62-
"symfony/yaml": "^4.4.20||^5.0.11||^6.0",
63-
"vimeo/psalm": "^4.3"
60+
"symfony/phpunit-bridge": "^5.2.6||^6.0||^7.0",
61+
"symfony/process": "^4.4.20||^5.0.11||^6.0||^7.0",
62+
"symfony/twig-bundle": "^4.4.20||^5.0.11||^6.0||^7.0",
63+
"symfony/yaml": "^4.4.20||^5.0.11||^6.0||^7.0",
64+
"vimeo/psalm": "^4.3||^5.16.0"
6465
},
6566
"suggest": {
6667
"monolog/monolog": "Allow sending log messages to Sentry by using the included Monolog handler.",

phpstan-baseline.neon

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,16 @@ parameters:
330330
count: 1
331331
path: tests/End2End/TracingEnd2EndTest.php
332332

333+
-
334+
message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#"
335+
count: 1
336+
path: tests/EventListener/ErrorListenerTest.php
337+
338+
-
339+
message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#"
340+
count: 2
341+
path: tests/EventListener/LoginListenerTest.php
342+
333343
-
334344
message: "#^Call to function method_exists\\(\\) with \\$this\\(Sentry\\\\SentryBundle\\\\Tests\\\\EventListener\\\\AuthenticatedTokenStub\\) and 'setAuthenticated' will always evaluate to false\\.$#"
335345
count: 1
@@ -360,11 +370,31 @@ parameters:
360370
count: 1
361371
path: tests/EventListener/LoginListenerTest.php
362372

373+
-
374+
message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#"
375+
count: 6
376+
path: tests/EventListener/RequestListenerTest.php
377+
378+
-
379+
message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#"
380+
count: 2
381+
path: tests/EventListener/SubRequestListenerTest.php
382+
363383
-
364384
message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpKernel\\\\Event\\\\KernelEvent\\:\\:isMasterRequest\\(\\)\\.$#"
365385
count: 1
366386
path: tests/EventListener/SubRequestListenerTest.php
367387

388+
-
389+
message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#"
390+
count: 3
391+
path: tests/EventListener/TracingRequestListenerTest.php
392+
393+
-
394+
message: "#^Access to undefined constant Symfony\\\\Component\\\\HttpKernel\\\\HttpKernelInterface\\:\\:MASTER_REQUEST\\.$#"
395+
count: 2
396+
path: tests/EventListener/TracingSubRequestListenerTest.php
397+
368398
-
369399
message: "#^Call to an undefined method TCacheAdapter of Symfony\\\\Component\\\\Cache\\\\Adapter\\\\AdapterInterface\\:\\:delete\\(\\)\\.$#"
370400
count: 2

src/EventListener/MessengerListener.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Symfony\Component\Messenger\Event\WorkerMessageHandledEvent;
1414
use Symfony\Component\Messenger\Exception\DelayedMessageHandlingException;
1515
use Symfony\Component\Messenger\Exception\HandlerFailedException;
16+
use Symfony\Component\Messenger\Exception\WrappedExceptionsInterface;
1617
use Symfony\Component\Messenger\Stamp\BusNameStamp;
1718

1819
final class MessengerListener
@@ -94,9 +95,11 @@ public function handleWorkerMessageHandledEvent(WorkerMessageHandledEvent $event
9495
*/
9596
private function captureException(\Throwable $exception, bool $willRetry): void
9697
{
97-
if ($exception instanceof HandlerFailedException) {
98+
if ($exception instanceof WrappedExceptionsInterface) {
99+
$exception = $exception->getWrappedExceptions();
100+
} elseif ($exception instanceof HandlerFailedException && method_exists($exception, 'getNestedExceptions')) {
98101
$exception = $exception->getNestedExceptions();
99-
} elseif ($exception instanceof DelayedMessageHandlingException) {
102+
} elseif ($exception instanceof DelayedMessageHandlingException && method_exists($exception, 'getExceptions')) {
100103
$exception = $exception->getExceptions();
101104
}
102105

src/Tracing/HttpClient/AbstractTraceableHttpClient.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,11 @@ private static function shouldAttachTracingHeaders(?ClientInterface $client, Uri
138138

139139
// Check if the request destination is allow listed in the trace_propagation_targets option.
140140
if (
141-
null !== $sdkOptions->getTracePropagationTargets() &&
141+
null !== $sdkOptions->getTracePropagationTargets()
142142
// Due to BC, we treat an empty array (the default) as all hosts are allow listed
143-
(
144-
[] === $sdkOptions->getTracePropagationTargets() ||
145-
\in_array($uri->getHost(), $sdkOptions->getTracePropagationTargets())
143+
&& (
144+
[] === $sdkOptions->getTracePropagationTargets()
145+
|| \in_array($uri->getHost(), $sdkOptions->getTracePropagationTargets())
146146
)
147147
) {
148148
return true;

tests/End2End/App/Messenger/FooMessageHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
namespace Sentry\SentryBundle\Tests\End2End\App\Messenger;
66

77
use Symfony\Component\Messenger\Exception\UnrecoverableExceptionInterface;
8-
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
98

10-
class FooMessageHandler implements MessageHandlerInterface
9+
class FooMessageHandler
1110
{
1211
public function __invoke(FooMessage $message): void
1312
{

tests/End2End/App/messenger.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ services:
77

88
Sentry\SentryBundle\Tests\End2End\App\Messenger\FooMessageHandler:
99
class: \Sentry\SentryBundle\Tests\End2End\App\Messenger\FooMessageHandler
10+
tags:
11+
- { name: messenger.message_handler }
1012

1113
Sentry\SentryBundle\Tests\End2End\App\Controller\MessengerController:
1214
autowire: true

tests/End2End/End2EndTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ public function testNotice(): void
198198

199199
public function testCommand(): void
200200
{
201-
self::bootKernel();
202-
$application = new Application(self::$kernel);
201+
$application = new Application(self::bootKernel());
203202

204203
try {
205204
$application->doRun(new ArgvInput(['bin/console', 'main-command', '--option1', '--option2=foo', 'bar']), new NullOutput());

tests/EventListener/ErrorListenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function handleExceptionEventDataProvider(): \Generator
6666
new ExceptionEvent(
6767
$this->createMock(HttpKernelInterface::class),
6868
new Request(),
69-
HttpKernelInterface::MASTER_REQUEST,
69+
\defined(HttpKernelInterface::class . '::MAIN_REQUEST') ? HttpKernelInterface::MAIN_REQUEST : HttpKernelInterface::MASTER_REQUEST,
7070
new \Exception()
7171
),
7272
];

0 commit comments

Comments
 (0)