Skip to content
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

feat: support Symfony 7 #104

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
29 changes: 4 additions & 25 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,11 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- symfony: '4.4.*'
php: '8.0'
- symfony: '4.4.*'
php: '8.1'
- symfony: '4.4.*'
php: '8.2'
- symfony: '5.4.*'
php: '8.0'
- symfony: '5.4.*'
php: '8.1'
- symfony: '5.4.*'
php: '8.2'
- symfony: '6.2.*'
php: '8.1'
- symfony: '6.2.*'
php: '8.2'
- symfony: '7.1.*'
php: '8.2'
steps:
- name: checkout
Expand Down Expand Up @@ -71,21 +60,11 @@ jobs:
strategy:
matrix:
include:
- symfony: '4.4.*'
php: '8.0'
- symfony: '4.4.*'
php: '8.1'
- symfony: '4.4.*'
php: '8.2'
- symfony: '5.4.*'
php: '8.0'
- symfony: '5.4.*'
php: '8.1'
- symfony: '5.4.*'
php: '8.2'
- symfony: '6.2.*'
php: '8.1'
- symfony: '6.2.*'
php: '8.2'
- symfony: '7.1.*'
php: '8.2'
steps:
- name: checkout
Expand Down
22 changes: 4 additions & 18 deletions EventListener/FinishRootSpanSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,17 @@ public static function getSubscribedEvents(): array

public function onFinishRequest(KernelEvent $event): void
{
# TODO: when Symfony 4.4 is unmaintained (November 2023), remove outer if-block in favor of isMainRequest()
if (method_exists($event, 'isMainRequest')) {
if (!$event->isMainRequest()) {
return;
}
} elseif (method_exists($event, 'isMasterRequest')) {
if (!$event->isMasterRequest()) {
return;
}
if (!$event->isMainRequest()) {
return;
}

$this->tracing->finishActiveSpan();
}

public function onTerminate(KernelEvent $event): void
{
# TODO: when Symfony 4.4 is unmaintained (November 2023), remove outer if-block in favor of isMainRequest()
if (method_exists($event, 'isMainRequest')) {
if (!$event->isMainRequest()) {
return;
}
} elseif (method_exists($event, 'isMasterRequest')) {
if (!$event->isMasterRequest()) {
return;
}
if (!$event->isMainRequest()) {
return;
}

$this->persistence->flush();
Expand Down
11 changes: 2 additions & 9 deletions EventListener/StartRootSpanSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,8 @@ public static function getSubscribedEvents(): array

public function onRequest(KernelEvent $event): void
{
# TODO: when Symfony 4.4 is unmaintained (November 2023), remove outer if-block in favor of isMainRequest()
if (method_exists($event, 'isMainRequest')) {
if (!$event->isMainRequest()) {
return;
}
} elseif (method_exists($event, 'isMasterRequest')) {
if (!$event->isMasterRequest()) {
return;
}
if (!$event->isMainRequest()) {
return;
}

$request = $event->getRequest();
Expand Down
7 changes: 2 additions & 5 deletions Tests/EventListener/FinishRootSpanSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public function testGetSubscribedEvents(): void

public function testOnFinishRequestIsMainRequest(): void
{
# TODO: when Symfony 4.4 is unmaintained (November 2023), replace HttpKernelInterface::MASTER_REQUEST with HttpKernelInterface::MAIN_REQUEST
$event = new KernelEvent($this->kernel->reveal(), $this->request->reveal(), HttpKernelInterface::MASTER_REQUEST);
$event = new KernelEvent($this->kernel->reveal(), $this->request->reveal(), HttpKernelInterface::MAIN_REQUEST);

$this->tracing->finishActiveSpan()->shouldBeCalledOnce();
$this->persistence->flush()->shouldNotBeCalled();
Expand All @@ -63,8 +62,7 @@ public function testOnFinishRequestIsNotMainRequest(): void

public function testOnTerminateIsMainRequest(): void
{
# TODO: when Symfony 4.4 is unmaintained (November 2023), replace HttpKernelInterface::MASTER_REQUEST with HttpKernelInterface::MAIN_REQUEST
$event = new KernelEvent($this->kernel->reveal(), $this->request->reveal(), HttpKernelInterface::MASTER_REQUEST);
$event = new KernelEvent($this->kernel->reveal(), $this->request->reveal(), HttpKernelInterface::MAIN_REQUEST);

$this->tracing->finishActiveSpan()->shouldNotBeCalled();
$this->persistence->flush()->shouldBeCalledOnce();
Expand All @@ -74,7 +72,6 @@ public function testOnTerminateIsMainRequest(): void

public function testOnTerminateIsNotMainRequest(): void
{
# TODO: when Symfony 4.4 is unmaintained (November 2023), replace HttpKernelInterface::MASTER_REQUEST with HttpKernelInterface::MAIN_REQUEST
$event = new KernelEvent($this->kernel->reveal(), $this->request->reveal(), HttpKernelInterface::SUB_REQUEST);

$this->tracing->finishActiveSpan()->shouldNotBeCalled();
Expand Down
3 changes: 1 addition & 2 deletions Tests/EventListener/StartRootSpanSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public function testGetSubscribedEvents(): void
public function testOnRequestIsMasterRequest(): void
{
$request = Request::create('http://some.uri.test/');
# TODO: when Symfony 4.4 is unmaintained (November 2023), replace HttpKernelInterface::MASTER_REQUEST with HttpKernelInterface::MAIN_REQUEST
$event = new KernelEvent($this->kernel->reveal(), $request, HttpKernelInterface::MASTER_REQUEST);
$event = new KernelEvent($this->kernel->reveal(), $request, HttpKernelInterface::MAIN_REQUEST);

$this->spanOptionsFactory->createSpanOptions($request)->willReturn(['some' => 'options']);
$this->tracing->startActiveSpan(
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
"type": "library",
"license": "MIT",
"require": {
"php": "^8.0",
"php": "^8.2",
"ext-json": "*",
"psr/log": "^1.1|^2.0|^3.0",
"psr/http-message": "^1.0",
"psr/http-client": "^1.0",
"opentracing/opentracing": "^1.0.1",
"composer/package-versions-deprecated": "^1.11.99",
"symfony/http-kernel": "^4.4|^5.4|^6.2",
"symfony/dependency-injection": "^4.4|^5.4|^6.2",
"symfony/config": "^4.4|^5.4|^6.2",
"symfony/console": "^4.4|^5.4|^6.2",
"symfony/yaml": "^4.4|^5.4|^6.2"
"symfony/http-kernel": "^5.4|^6.2|^7.1",
"symfony/dependency-injection": "^5.4|^6.2|^7.1",
"symfony/config": "^5.4|^6.2|^7.1",
"symfony/console": "^5.4|^6.2||^7.1",
"symfony/yaml": "^5.4|^6.2|^7.1"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
Expand Down
Loading