Skip to content

Commit 3d4f112

Browse files
author
Tobias Feijten
committed
Drop support for PHP <8.0 and Symfony <5.4, add typing to all classes
1 parent d9aecb3 commit 3d4f112

19 files changed

+130
-296
lines changed

.github/workflows/code_checks.yaml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,27 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
php: ['7.1', '7.2', '7.3', '7.4', '8.0']
27+
php: ['8.0', '8.1']
2828
dependencies: [highest]
2929
symfony: ['*']
3030
include:
3131
# Minimum supported dependencies with the oldest supported PHP version
32-
- php: '7.1'
32+
- php: '8.0'
3333
dependencies: lowest
3434
symfony: '*'
3535

3636
# Minimum supported dependencies with the latest supported PHP version
37-
- php: '8.0'
37+
- php: '8.1'
3838
dependencies: lowest
3939
symfony: '*'
4040

41-
- php: '8.0'
41+
- php: '8.1'
4242
dependencies: highest
4343
symfony: '*'
4444

4545
# Test each supported Symfony version with lowest supported PHP version
46-
- php: '7.1'
47-
dependencies: highest
48-
symfony: '4.4.*'
4946

50-
- php: '7.2'
51-
dependencies: highest
52-
symfony: '5.4.*'
53-
54-
- php: '7.3'
55-
dependencies: highest
56-
symfony: '5.4.*'
57-
58-
- php: '7.4'
47+
- php: '8.0'
5948
dependencies: highest
6049
symfony: '5.4.*'
6150

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v3.0.0 - 2021-12-15
4+
- Migrate router implementation to TS ([#406](https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/pull/406))
5+
- Allow Symfony 6 ([#408](https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/pull/408))
6+
- [BC break] Drop support for PHP <8.0 and Symfony <5.4, add typing to all classes
7+
- Add documentation for attributes
8+
39
## v2.8.0 - 2021-12-15
410
- Fix expose: false behavior ([#404](https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/pull/404))
511
- Fix dump using domains ([#410](https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/pull/410))

Command/DumpCommand.php

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,12 @@ class DumpCommand extends Command
2828
{
2929
protected static $defaultName = 'fos:js-routing:dump';
3030

31-
/**
32-
* @var ExposedRoutesExtractorInterface
33-
*/
34-
private $extractor;
35-
36-
/**
37-
* @var SerializerInterface
38-
*/
39-
private $serializer;
40-
41-
/**
42-
* @var string
43-
*/
44-
private $projectDir;
45-
46-
/**
47-
* @var string
48-
*/
49-
private $requestContextBaseUrl;
50-
51-
public function __construct(ExposedRoutesExtractorInterface $extractor, SerializerInterface $serializer, $projectDir, $requestContextBaseUrl = null)
31+
public function __construct(private ExposedRoutesExtractorInterface $extractor, private SerializerInterface $serializer, private string $projectDir, private ?string $requestContextBaseUrl = null)
5232
{
53-
$this->extractor = $extractor;
54-
$this->serializer = $serializer;
55-
$this->projectDir = $projectDir;
56-
$this->requestContextBaseUrl = $requestContextBaseUrl;
57-
5833
parent::__construct();
5934
}
6035

61-
protected function configure()
36+
protected function configure(): void
6237
{
6338
$this
6439
->setName('fos:js-routing:dump')
@@ -128,11 +103,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
128103

129104
/**
130105
* Performs the routes dump.
131-
*
132-
* @param InputInterface $input The command input
133-
* @param OutputInterface $output The command output
134106
*/
135-
private function doDump(InputInterface $input, OutputInterface $output)
107+
private function doDump(InputInterface $input, OutputInterface $output): void
136108
{
137109
$domain = $input->getOption('domain');
138110

Command/RouterDebugExposedCommand.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,16 @@ class RouterDebugExposedCommand extends Command
3131
{
3232
protected static $defaultName = 'fos:js-routing:debug';
3333

34-
private $extractor;
35-
36-
private $router;
37-
38-
public function __construct(ExposedRoutesExtractorInterface $extractor, RouterInterface $router)
34+
public function __construct(private ExposedRoutesExtractorInterface $extractor, private RouterInterface $router)
3935
{
40-
$this->extractor = $extractor;
41-
$this->router = $router;
42-
4336
parent::__construct();
4437
}
4538

4639

4740
/**
4841
* {@inheritdoc}
4942
*/
50-
protected function configure()
43+
protected function configure(): void
5144
{
5245
$this
5346
->setDefinition(array(
@@ -104,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
10497
return 0;
10598
}
10699

107-
protected function getRoutes($domain = array())
100+
protected function getRoutes($domain = array()): RouteCollection
108101
{
109102
$routes = $this->extractor->getRoutes();
110103

Controller/Controller.php

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,7 @@
2727
*/
2828
class Controller
2929
{
30-
/**
31-
* @var mixed
32-
*/
33-
protected $serializer;
34-
35-
/**
36-
* @var ExposedRoutesExtractorInterface
37-
*/
38-
protected $exposedRoutesExtractor;
39-
40-
/**
41-
* @var CacheControlConfig
42-
*/
43-
protected $cacheControlConfig;
44-
45-
/**
46-
* @var boolean
47-
*/
48-
protected $debug;
30+
protected CacheControlConfig $cacheControlConfig;
4931

5032
/**
5133
* Default constructor.
@@ -55,18 +37,12 @@ class Controller
5537
* @param array $cacheControl
5638
* @param boolean $debug
5739
*/
58-
public function __construct($serializer, ExposedRoutesExtractorInterface $exposedRoutesExtractor, array $cacheControl = array(), $debug = false)
40+
public function __construct(private mixed $serializer, private ExposedRoutesExtractorInterface $exposedRoutesExtractor, array $cacheControl = array(), private bool $debug = false)
5941
{
60-
$this->serializer = $serializer;
61-
$this->exposedRoutesExtractor = $exposedRoutesExtractor;
6242
$this->cacheControlConfig = new CacheControlConfig($cacheControl);
63-
$this->debug = $debug;
6443
}
6544

66-
/**
67-
* indexAction action.
68-
*/
69-
public function indexAction(Request $request, $_format)
45+
public function indexAction(Request $request, $_format): Response
7046
{
7147
$session = $request->hasSession() ? $request->getSession() : null;
7248

DependencyInjection/Configuration.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,13 @@ class Configuration implements ConfigurationInterface
2424
/**
2525
* Generates the configuration tree builder.
2626
*
27-
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
27+
* @return TreeBuilder The tree builder
2828
*/
29-
public function getConfigTreeBuilder()
29+
public function getConfigTreeBuilder(): TreeBuilder
3030
{
3131
$builder = new TreeBuilder('fos_js_routing');
32-
if (\method_exists($builder, 'getRootNode')) {
33-
$rootNode = $builder->getRootNode();
34-
} else {
35-
// BC layer for symfony/config 4.1 and older
36-
$rootNode = $builder->root('fos_js_routing');
37-
}
32+
33+
$rootNode = $builder->getRootNode();
3834

3935
$rootNode
4036
->children()

DependencyInjection/FOSJsRoutingExtension.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,11 @@
1919
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2020

2121
/**
22-
* FOSJsRoutingExtension
23-
* Load configuration.
24-
*
2522
* @author William DURAND <[email protected]>
2623
*/
2724
class FOSJsRoutingExtension extends Extension
2825
{
29-
/**
30-
* Load configuration.
31-
*/
32-
public function load(array $configs, ContainerBuilder $container)
26+
public function load(array $configs, ContainerBuilder $container): void
3327
{
3428
$processor = new Processor();
3529
$configuration = new Configuration();

0 commit comments

Comments
 (0)