Skip to content

Commit 5b217ad

Browse files
authored
Merge pull request #43 from samsonasik/apply-php74
Apply PHP 7.4 syntax and typed property
2 parents 57b33fe + 3187b21 commit 5b217ad

File tree

10 files changed

+28
-57
lines changed

10 files changed

+28
-57
lines changed

src/Configuration/RouteConfiguration.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Mezzio\Cors\Service\CorsMetadata;
88
use Webmozart\Assert\Assert;
99

10-
use function array_merge;
1110
use function array_unique;
1211
use function sort;
1312

@@ -16,11 +15,9 @@
1615

1716
final class RouteConfiguration extends AbstractConfiguration implements RouteConfigurationInterface
1817
{
19-
/** @var bool */
20-
protected $overridesProjectConfiguration = true;
18+
private bool $overridesProjectConfiguration = true;
2119

22-
/** @var bool */
23-
protected $explicit = false;
20+
private bool $explicit = false;
2421

2522
public function setOverridesProjectConfiguration(bool $overridesProjectConfiguration): void
2623
{
@@ -65,9 +62,9 @@ public function mergeWithConfiguration(ConfigurationInterface $configuration): R
6562
$instance->setAllowedMaxAge($configuration->allowedMaxAge());
6663
}
6764

68-
$instance->setAllowedHeaders(array_merge($configuration->allowedHeaders(), $instance->allowedHeaders()));
69-
$instance->setAllowedOrigins(array_merge($configuration->allowedOrigins(), $instance->allowedOrigins()));
70-
$instance->setExposedHeaders(array_merge($configuration->exposedHeaders(), $instance->exposedHeaders()));
65+
$instance->setAllowedHeaders([...$configuration->allowedHeaders(), ...$instance->allowedHeaders()]);
66+
$instance->setAllowedOrigins([...$configuration->allowedOrigins(), ...$instance->allowedOrigins()]);
67+
$instance->setExposedHeaders([...$configuration->exposedHeaders(), ...$instance->exposedHeaders()]);
7168

7269
return $instance->withRequestMethods($configuration->allowedMethods());
7370
}
@@ -79,7 +76,7 @@ public function mergeWithConfiguration(ConfigurationInterface $configuration): R
7976
*/
8077
public function withRequestMethods(array $methods): RouteConfigurationInterface
8178
{
82-
$methods = $this->normalizeRequestMethods(array_merge($this->allowedMethods, $methods));
79+
$methods = $this->normalizeRequestMethods([...$this->allowedMethods, ...$methods]);
8380

8481
$instance = clone $this;
8582
$instance->allowedMethods = $methods;

src/Middleware/CorsMiddleware.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@
1919

2020
final class CorsMiddleware implements MiddlewareInterface
2121
{
22-
/** @var CorsInterface */
23-
private $cors;
22+
private CorsInterface $cors;
2423

25-
/** @var ConfigurationLocatorInterface */
26-
private $configurationLocator;
24+
private ConfigurationLocatorInterface $configurationLocator;
2725

28-
/** @var ResponseFactoryInterface */
29-
private $responseFactory;
26+
private ResponseFactoryInterface $responseFactory;
3027

3128
public function __construct(
3229
CorsInterface $cors,

src/Service/ConfigurationLocator.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,13 @@
1919

2020
final class ConfigurationLocator implements ConfigurationLocatorInterface
2121
{
22-
/** @var ConfigurationInterface */
23-
private $configuration;
22+
private ConfigurationInterface $configuration;
2423

25-
/** @var ServerRequestFactoryInterface */
26-
private $requestFactory;
24+
private ServerRequestFactoryInterface $requestFactory;
2725

28-
/** @var RouterInterface */
29-
private $router;
26+
private RouterInterface $router;
3027

31-
/** @var RouteConfigurationFactoryInterface */
32-
private $routeConfigurationFactory;
28+
private RouteConfigurationFactoryInterface $routeConfigurationFactory;
3329

3430
public function __construct(
3531
ConfigurationInterface $configuration,

src/Service/Cors.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717

1818
final class Cors implements CorsInterface
1919
{
20-
/** @var UriFactoryInterface */
21-
private $uriFactory;
20+
private UriFactoryInterface $uriFactory;
2221

2322
public function __construct(UriFactoryInterface $uriFactory)
2423
{

src/Service/ResponseFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
final class ResponseFactory implements ResponseFactoryInterface
1515
{
16-
/** @var PsrResponseFactoryInterface */
17-
private $responseFactory;
16+
private PsrResponseFactoryInterface $responseFactory;
1817

1918
public function __construct(PsrResponseFactoryInterface $responseFactory)
2019
{

test/Configuration/RouteConfigurationFactoryTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010

1111
final class RouteConfigurationFactoryTest extends TestCase
1212
{
13-
/**
14-
* @var RouteConfigurationFactory
15-
*/
16-
private $factory;
13+
private RouteConfigurationFactory $factory;
1714

1815
protected function setUp(): void
1916
{

test/Middleware/CorsMiddlewareTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ final class CorsMiddlewareTest extends TestCase
3232
/** @psalm-var ResponseFactoryInterface&MockObject */
3333
private $responseFactoryInterface;
3434

35-
/** @var CorsMiddleware */
36-
private $middleware;
35+
private CorsMiddleware $middleware;
3736

3837
/**
3938
* @psalm-return array<non-empty-string,array{0:non-empty-string}>

test/Service/ConfigurationLocatorTest.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,31 @@
2020

2121
use function array_diff;
2222
use function array_fill;
23-
use function array_merge;
2423
use function count;
2524

2625
final class ConfigurationLocatorTest extends TestCase
2726
{
28-
/** @var ConfigurationLocator */
29-
private $locator;
27+
private ConfigurationLocator $locator;
3028

3129
/**
32-
* @var MockObject
33-
* @psalm-var ConfigurationInterface&MockObject
30+
* @psalm-var MockObject&ConfigurationInterface
3431
*/
35-
private $projectConfiguration;
32+
private ConfigurationInterface $projectConfiguration;
3633

3734
/**
38-
* @var MockObject
3935
* @psalm-var MockObject&ServerRequestFactoryInterface
4036
*/
41-
private $requestFactory;
37+
private ServerRequestFactoryInterface $requestFactory;
4238

4339
/**
44-
* @var MockObject
4540
* @psalm-var MockObject&RouterInterface
4641
*/
47-
private $router;
42+
private RouterInterface $router;
4843

4944
/**
50-
* @var MockObject
51-
* @psalm-var RouteConfigurationFactoryInterface&MockObject
45+
* @psalm-var MockObject&RouteConfigurationFactoryInterface
5246
*/
53-
private $routeConfigurationFactory;
47+
private RouteConfigurationFactoryInterface $routeConfigurationFactory;
5448

5549
public function testWontLocateAnyConfigurationIfRouteIsUnknown(): void
5650
{
@@ -334,7 +328,7 @@ private function createServerRequestArguments(string $initialRequestMethod, UriI
334328
$consecutiveArguments[] = [$requestMethod, $requestUri];
335329
}
336330

337-
return array_merge([$initialArgument], $consecutiveArguments);
331+
return [...[$initialArgument], ...$consecutiveArguments];
338332
}
339333

340334
public function testWillEarlyReturnExplicitRouteConfiguration(): void

test/Service/CorsTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ final class CorsTest extends TestCase
2323
*/
2424
private $uriFactory;
2525

26-
/**
27-
* @var Cors
28-
*/
29-
private $cors;
26+
private Cors $cors;
3027

3128
/**
3229
* @dataProvider crossOriginProvider

test/Service/ResponseFactoryTest.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,12 @@
1515

1616
final class ResponseFactoryTest extends TestCase
1717
{
18-
/**
19-
* @var ResponseFactory
20-
*/
21-
private $responseFactory;
18+
private ResponseFactory $responseFactory;
2219

2320
/**
24-
* @var MockObject
2521
* @psalm-var MockObject&ResponseFactoryInterface
2622
*/
27-
private $psrResponseFactory;
23+
private MockObject $psrResponseFactory;
2824

2925
protected function setUp(): void
3026
{

0 commit comments

Comments
 (0)