Skip to content

Commit 53a3ecd

Browse files
committed
feat: laminas coding standard 2.2.0
Signed-off-by: Geert Eltink <[email protected]>
1 parent 3694544 commit 53a3ecd

12 files changed

+323
-89
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/.phpcs-cache
2+
/.phpunit.result.cache
13
/clover.xml
24
/coveralls-upload.json
35
/docs/html/

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
"psr/http-server-middleware": "^1.0"
3737
},
3838
"require-dev": {
39-
"laminas/laminas-coding-standard": "~1.0.0",
40-
"phpspec/prophecy-phpunit": "^2.0",
39+
"laminas/laminas-coding-standard": "~2.2.0",
4140
"phpspec/prophecy": "^1.12",
41+
"phpspec/prophecy-phpunit": "^2.0",
4242
"phpunit/phpunit": "^9.3"
4343
},
4444
"conflict": {

composer.lock

Lines changed: 280 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpcs.xml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
<?xml version="1.0"?>
2-
<ruleset name="Laminas coding standard">
3-
<rule ref="./vendor/laminas/laminas-coding-standard/ruleset.xml"/>
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
4+
5+
<arg name="basepath" value="."/>
6+
<arg name="cache" value=".phpcs-cache"/>
7+
<arg name="colors"/>
8+
<arg name="extensions" value="php"/>
9+
<arg name="parallel" value="80"/>
10+
11+
<!-- Show progress -->
12+
<arg value="p"/>
413

514
<!-- Paths to check -->
615
<file>src</file>
716
<file>test</file>
17+
18+
<!-- Include all rules from the Laminas Coding Standard -->
19+
<rule ref="LaminasCodingStandard"/>
820
</ruleset>

src/AuthorizationInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ interface AuthorizationInterface
1111
/**
1212
* Check if a role is granted for the request
1313
*/
14-
public function isGranted(string $role, ServerRequestInterface $request) : bool;
14+
public function isGranted(string $role, ServerRequestInterface $request): bool;
1515
}

src/AuthorizationMiddleware.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,26 @@
1212

1313
class AuthorizationMiddleware implements MiddlewareInterface
1414
{
15-
/**
16-
* @var AuthorizationInterface
17-
*/
15+
/** @var AuthorizationInterface */
1816
private $authorization;
1917

20-
/**
21-
* @var callable
22-
*/
18+
/** @var callable */
2319
private $responseFactory;
2420

2521
public function __construct(AuthorizationInterface $authorization, callable $responseFactory)
2622
{
2723
$this->authorization = $authorization;
2824

2925
// Ensures type safety of the composed factory
30-
$this->responseFactory = function () use ($responseFactory) : ResponseInterface {
26+
$this->responseFactory = function () use ($responseFactory): ResponseInterface {
3127
return $responseFactory();
3228
};
3329
}
3430

3531
/**
3632
* {@inheritDoc}
3733
*/
38-
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
34+
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
3935
{
4036
$user = $request->getAttribute(UserInterface::class, false);
4137
if (! $user instanceof UserInterface) {

src/AuthorizationMiddlewareFactory.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

1212
class AuthorizationMiddlewareFactory
1313
{
14-
public function __invoke(ContainerInterface $container) : AuthorizationMiddleware
14+
public function __invoke(ContainerInterface $container): AuthorizationMiddleware
1515
{
16-
if (! $container->has(AuthorizationInterface::class)
16+
if (
17+
! $container->has(AuthorizationInterface::class)
1718
&& ! $container->has(\Zend\Expressive\Authorization\AuthorizationInterface::class)
1819
) {
1920
throw new Exception\InvalidConfigException(sprintf(

src/ConfigProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ConfigProvider
99
/**
1010
* Return the configuration array.
1111
*/
12-
public function __invoke() : array
12+
public function __invoke(): array
1313
{
1414
return [
1515
'dependencies' => $this->getDependencies(),
@@ -20,7 +20,7 @@ public function __invoke() : array
2020
/**
2121
* Returns the configuration for the AuthorizationInterface adapter
2222
*/
23-
public function getAuthorizationConfig() : array
23+
public function getAuthorizationConfig(): array
2424
{
2525
return [
2626
/**
@@ -59,10 +59,10 @@ public function getAuthorizationConfig() : array
5959
/**
6060
* Returns the container dependencies
6161
*/
62-
public function getDependencies() : array
62+
public function getDependencies(): array
6363
{
6464
return [
65-
'aliases' => [
65+
'aliases' => [
6666
// Provide an alias for the AuthorizationInterface based on the adapter you are using.
6767
// AuthorizationInterface::class => LaminasAcl::class,
6868
// AuthorizationInterface::class => LaminasRbac::class,

test/AuthorizationMiddlewareFactoryTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ class AuthorizationMiddlewareFactoryTest extends TestCase
3737

3838
protected function setUp(): void
3939
{
40-
$this->container = $this->prophesize(ContainerInterface::class);
41-
$this->factory = new AuthorizationMiddlewareFactory();
42-
$this->authorization = $this->prophesize(AuthorizationInterface::class);
40+
$this->container = $this->prophesize(ContainerInterface::class);
41+
$this->factory = new AuthorizationMiddlewareFactory();
42+
$this->authorization = $this->prophesize(AuthorizationInterface::class);
4343
$this->responsePrototype = $this->prophesize(ResponseInterface::class);
44-
$this->responseFactory = function () {
44+
$this->responseFactory = function () {
4545
return $this->responsePrototype->reveal();
4646
};
4747

@@ -75,7 +75,7 @@ public function testFactory()
7575
public static function assertResponseFactoryReturns(
7676
ResponseInterface $expected,
7777
AuthorizationMiddleware $middleware
78-
) : void {
78+
): void {
7979
$r = new ReflectionProperty($middleware, 'responseFactory');
8080
$r->setAccessible(true);
8181
$responseFactory = $r->getValue($middleware);

test/AuthorizationMiddlewareTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ class AuthorizationMiddlewareTest extends TestCase
3737

3838
protected function setUp(): void
3939
{
40-
$this->authorization = $this->prophesize(AuthorizationInterface::class);
41-
$this->request = $this->prophesize(ServerRequestInterface::class);
42-
$this->handler = $this->prophesize(RequestHandlerInterface::class);
40+
$this->authorization = $this->prophesize(AuthorizationInterface::class);
41+
$this->request = $this->prophesize(ServerRequestInterface::class);
42+
$this->handler = $this->prophesize(RequestHandlerInterface::class);
4343
$this->responsePrototype = $this->prophesize(ResponseInterface::class);
44-
$this->responseFactory = function () {
44+
$this->responseFactory = function () {
4545
return $this->responsePrototype->reveal();
4646
};
4747
}
@@ -120,7 +120,7 @@ public function testProcessRoleGranted()
120120
$this->assertSame($this->responsePrototype->reveal(), $response);
121121
}
122122

123-
private function generateUser(string $identity, array $roles = []) : DefaultUser
123+
private function generateUser(string $identity, array $roles = []): DefaultUser
124124
{
125125
return new DefaultUser($identity, $roles);
126126
}

0 commit comments

Comments
 (0)