Skip to content

Commit 110ba44

Browse files
authored
Add Symfony 7 support (#92)
1 parent 1166ef2 commit 110ba44

File tree

7 files changed

+28
-78
lines changed

7 files changed

+28
-78
lines changed

Command/ImportCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function configure(): void
4646
);
4747
}
4848

49-
public function execute(InputInterface $input, OutputInterface $output)
49+
public function execute(InputInterface $input, OutputInterface $output): int
5050
{
5151
$progressBar = new ProgressBar($output);
5252
$progressBar->setFormat(' %current% [%bar%] %elapsed:6s% %memory:6s%');

DependencyInjection/Configuration.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class Configuration implements ConfigurationInterface
2323
{
24-
public function getConfigTreeBuilder()
24+
public function getConfigTreeBuilder(): TreeBuilder
2525
{
2626
$treeBuilder = new TreeBuilder('sulu_redirect');
2727
$treeBuilder->getRootNode()

GoneSubscriber/GoneEntitySubscriber.php

+1-14
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,19 @@
1111

1212
namespace Sulu\Bundle\RedirectBundle\GoneSubscriber;
1313

14-
use Doctrine\Common\EventSubscriber;
1514
use Doctrine\ORM\Event\LifecycleEventArgs;
16-
use Doctrine\ORM\Events;
1715
use Sulu\Bundle\RedirectBundle\Entity\RedirectRoute;
1816
use Sulu\Bundle\RedirectBundle\Exception\RedirectRouteNotUniqueException;
1917
use Sulu\Bundle\RedirectBundle\Manager\RedirectRouteManagerInterface;
2018
use Sulu\Bundle\RouteBundle\Model\RouteInterface;
21-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
22-
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
2319

2420
/**
2521
* This gone subscriber listens for removed route entities.
2622
*
2723
* @internal this is a internal listener which should not be used directly
2824
*/
29-
class GoneEntitySubscriber implements EventSubscriber, ContainerAwareInterface
25+
class GoneEntitySubscriber
3026
{
31-
use ContainerAwareTrait;
32-
3327
/**
3428
* @var RedirectRouteManagerInterface
3529
*/
@@ -41,13 +35,6 @@ public function __construct(
4135
$this->redirectRouteManager = $redirectRouteManager;
4236
}
4337

44-
public function getSubscribedEvents()
45-
{
46-
return [
47-
Events::preRemove,
48-
];
49-
}
50-
5138
public function preRemove(LifecycleEventArgs $event): void
5239
{
5340
$route = $event->getObject();

Resources/config/gone_subscriber.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class="Sulu\Bundle\RedirectBundle\GoneSubscriber\GoneEntitySubscriber">
2020
<argument type="service" id="sulu_redirect.redirect_route_manager"/>
2121

22-
<tag name="doctrine.event_subscriber"/>
22+
<tag name="doctrine.event_listener" event="preRemove"/>
2323
</service>
2424
</services>
2525
</container>

Tests/Unit/Controller/RedirectControllerTest.php

+12-24
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Sulu\Bundle\RedirectBundle\Controller\WebsiteRedirectController;
1616
use Sulu\Bundle\RedirectBundle\Model\RedirectRouteInterface;
17-
use Symfony\Component\HttpFoundation\ParameterBag;
1817
use Symfony\Component\HttpFoundation\RedirectResponse;
1918
use Symfony\Component\HttpFoundation\Request;
2019

@@ -25,16 +24,6 @@ class RedirectControllerTest extends TestCase
2524
*/
2625
private $controller;
2726

28-
/**
29-
* @var Request
30-
*/
31-
private $request;
32-
33-
/**
34-
* @var ParameterBag
35-
*/
36-
private $queryBag;
37-
3827
/**
3928
* @var RedirectRouteInterface
4029
*/
@@ -43,25 +32,20 @@ class RedirectControllerTest extends TestCase
4332
protected function setUp(): void
4433
{
4534
$this->controller = new WebsiteRedirectController();
46-
47-
$this->request = $this->prophesize(Request::class);
48-
$this->queryBag = $this->prophesize(ParameterBag::class);
4935
$this->redirectRoute = $this->prophesize(RedirectRouteInterface::class);
50-
51-
$this->request->reveal()->query = $this->queryBag->reveal();
5236
}
5337

5438
public function testRedirect()
5539
{
5640
$target = '/test';
5741
$statusCode = 301;
5842

59-
$this->queryBag->all()->willReturn([]);
43+
$request = Request::create('http://captain-sulu.io/');
6044

6145
$this->redirectRoute->getTarget()->willReturn($target);
6246
$this->redirectRoute->getStatusCode()->willReturn($statusCode);
6347

64-
$response = $this->controller->redirect($this->request->reveal(), $this->redirectRoute->reveal());
48+
$response = $this->controller->redirect($request, $this->redirectRoute->reveal());
6549

6650
$this->assertInstanceOf(RedirectResponse::class, $response);
6751
$this->assertEquals($target, $response->getTargetUrl());
@@ -74,12 +58,14 @@ public function testRedirectWithQuery()
7458
$statusCode = 301;
7559
$query = ['test' => 1, 'my-parameter' => 'awesome sulu'];
7660

77-
$this->queryBag->all()->willReturn($query);
61+
$request = Request::create('http://captain-sulu.io/');
62+
$request->query->set('test', $query['test']);
63+
$request->query->set('my-parameter', $query['my-parameter']);
7864

7965
$this->redirectRoute->getTarget()->willReturn($target);
8066
$this->redirectRoute->getStatusCode()->willReturn($statusCode);
8167

82-
$response = $this->controller->redirect($this->request->reveal(), $this->redirectRoute->reveal());
68+
$response = $this->controller->redirect($request, $this->redirectRoute->reveal());
8369

8470
$this->assertInstanceOf(RedirectResponse::class, $response);
8571
$this->assertEquals(
@@ -94,12 +80,12 @@ public function testRedirectExternal()
9480
$target = 'http://captain-sulu.io/test';
9581
$statusCode = 301;
9682

97-
$this->queryBag->all()->willReturn([]);
83+
$request = Request::create('http://captain-sulu.io/');
9884

9985
$this->redirectRoute->getTarget()->willReturn($target);
10086
$this->redirectRoute->getStatusCode()->willReturn($statusCode);
10187

102-
$response = $this->controller->redirect($this->request->reveal(), $this->redirectRoute->reveal());
88+
$response = $this->controller->redirect($request, $this->redirectRoute->reveal());
10389

10490
$this->assertInstanceOf(RedirectResponse::class, $response);
10591
$this->assertEquals(
@@ -115,12 +101,14 @@ public function testRedirectExternalWithQuery()
115101
$statusCode = 301;
116102
$query = ['test' => 1, 'my-parameter' => 'awesome sulu'];
117103

118-
$this->queryBag->all()->willReturn($query);
104+
$request = Request::create('http://captain-sulu.io/');
105+
$request->query->set('test', $query['test']);
106+
$request->query->set('my-parameter', $query['my-parameter']);
119107

120108
$this->redirectRoute->getTarget()->willReturn($target);
121109
$this->redirectRoute->getStatusCode()->willReturn($statusCode);
122110

123-
$response = $this->controller->redirect($this->request->reveal(), $this->redirectRoute->reveal());
111+
$response = $this->controller->redirect($request, $this->redirectRoute->reveal());
124112

125113
$this->assertInstanceOf(RedirectResponse::class, $response);
126114
$this->assertEquals(

composer.json

+12-12
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
"php": "^7.2 || ^8.0",
88
"sulu/sulu": "^2.2.5 || ^2.3@dev",
99
"ramsey/uuid": "^3.1 || ^4.0",
10-
"symfony/dependency-injection": "^4.3 || ^5.0 || ^6.0",
11-
"symfony/config": "^4.3 || ^5.0 || ^6.0",
12-
"symfony/console": "^4.3 || ^5.0 || ^6.0",
13-
"symfony/http-foundation": "^4.3 || ^5.0 || ^6.0",
10+
"symfony/dependency-injection": "^4.3 || ^5.0 || ^6.0 || ^7.0",
11+
"symfony/config": "^4.3 || ^5.0 || ^6.0 || ^7.0",
12+
"symfony/console": "^4.3 || ^5.0 || ^6.0 || ^7.0",
13+
"symfony/http-foundation": "^4.3 || ^5.0 || ^6.0 || ^7.0",
1414
"handcraftedinthealps/rest-routing-bundle": "^1.0",
1515
"friendsofsymfony/rest-bundle": "^2.8 || ^3.0",
1616
"jms/serializer-bundle": "^3.0 || ^4.0 || ^5.0",
17-
"symfony/http-kernel": "^4.3 || ^5.0 || ^6.0",
17+
"symfony/http-kernel": "^4.3 || ^5.0 || ^6.0 || ^7.0",
1818
"doctrine/orm": "^2.5.3",
19-
"symfony/event-dispatcher": "^4.3 || ^5.0 || ^6.0",
20-
"symfony/property-access": "^4.3 || ^5.0 || ^6.0",
21-
"symfony/routing": "^4.3 || ^5.0 || ^6.0",
19+
"symfony/event-dispatcher": "^4.3 || ^5.0 || ^6.0 || ^7.0",
20+
"symfony/property-access": "^4.3 || ^5.0 || ^6.0 || ^7.0",
21+
"symfony/routing": "^4.3 || ^5.0 || ^6.0 || ^7.0",
2222
"symfony-cmf/routing": "^2.1 || ^3.0"
2323
},
2424
"require-dev": {
@@ -30,12 +30,12 @@
3030
"phpstan/phpstan-symfony": "^1.0",
3131
"phpunit/phpunit": "^8.0",
3232
"php-cs-fixer/shim": "^3.0",
33-
"symfony/browser-kit": "^4.3 || ^5.0 || ^6.0",
34-
"symfony/dotenv": "^4.3 || ^5.0 || ^6.0",
33+
"symfony/browser-kit": "^4.3 || ^5.0 || ^6.0 || ^7.0",
34+
"symfony/dotenv": "^4.3 || ^5.0 || ^6.0 || ^7.0",
3535
"symfony/monolog-bundle": "^3.1",
36-
"jackalope/jackalope-doctrine-dbal": "^1.3.4",
36+
"jackalope/jackalope-doctrine-dbal": "^1.3.4 || ^2.0",
3737
"handcraftedinthealps/zendsearch": "^2.0",
38-
"symfony/framework-bundle": "^4.3 || ^5.0 || ^6.0",
38+
"symfony/framework-bundle": "^4.3 || ^5.0 || ^6.0 || ^7.0",
3939
"phpspec/prophecy": "^1.10"
4040
},
4141
"keywords": [

phpstan-baseline.neon

-25
Original file line numberDiff line numberDiff line change
@@ -320,16 +320,6 @@ parameters:
320320
count: 4
321321
path: Tests/Unit/Controller/RedirectControllerTest.php
322322

323-
-
324-
message: "#^Call to an undefined method Symfony\\\\Component\\\\HttpFoundation\\\\Request\\:\\:reveal\\(\\)\\.$#"
325-
count: 4
326-
path: Tests/Unit/Controller/RedirectControllerTest.php
327-
328-
-
329-
message: "#^Cannot call method willReturn\\(\\) on array\\.$#"
330-
count: 4
331-
path: Tests/Unit/Controller/RedirectControllerTest.php
332-
333323
-
334324
message: "#^Cannot call method willReturn\\(\\) on int\\.$#"
335325
count: 4
@@ -360,26 +350,11 @@ parameters:
360350
count: 1
361351
path: Tests/Unit/Controller/RedirectControllerTest.php
362352

363-
-
364-
message: "#^Property Sulu\\\\Bundle\\\\RedirectBundle\\\\Tests\\\\Unit\\\\Controller\\\\RedirectControllerTest\\:\\:\\$queryBag \\(Symfony\\\\Component\\\\HttpFoundation\\\\ParameterBag\\) does not accept Prophecy\\\\Prophecy\\\\ObjectProphecy\\<Symfony\\\\Component\\\\HttpFoundation\\\\ParameterBag\\>\\.$#"
365-
count: 1
366-
path: Tests/Unit/Controller/RedirectControllerTest.php
367-
368353
-
369354
message: "#^Property Sulu\\\\Bundle\\\\RedirectBundle\\\\Tests\\\\Unit\\\\Controller\\\\RedirectControllerTest\\:\\:\\$redirectRoute \\(Sulu\\\\Bundle\\\\RedirectBundle\\\\Model\\\\RedirectRouteInterface\\) does not accept Prophecy\\\\Prophecy\\\\ObjectProphecy\\<Sulu\\\\Bundle\\\\RedirectBundle\\\\Model\\\\RedirectRouteInterface\\>\\.$#"
370355
count: 1
371356
path: Tests/Unit/Controller/RedirectControllerTest.php
372357

373-
-
374-
message: "#^Property Sulu\\\\Bundle\\\\RedirectBundle\\\\Tests\\\\Unit\\\\Controller\\\\RedirectControllerTest\\:\\:\\$request \\(Symfony\\\\Component\\\\HttpFoundation\\\\Request\\) does not accept Prophecy\\\\Prophecy\\\\ObjectProphecy\\<Symfony\\\\Component\\\\HttpFoundation\\\\Request\\>\\.$#"
375-
count: 1
376-
path: Tests/Unit/Controller/RedirectControllerTest.php
377-
378-
-
379-
message: "#^Property Symfony\\\\Component\\\\HttpFoundation\\\\Request\\:\\:\\$query \\(Symfony\\\\Component\\\\HttpFoundation\\\\InputBag\\<string\\>\\) does not accept Symfony\\\\Component\\\\HttpFoundation\\\\ParameterBag\\.$#"
380-
count: 1
381-
path: Tests/Unit/Controller/RedirectControllerTest.php
382-
383358
-
384359
message: "#^Cannot access offset 'exceptions' on mixed\\.$#"
385360
count: 2

0 commit comments

Comments
 (0)