Skip to content

Commit 04b206f

Browse files
committed
qa: update to laminas-coding-standard 2.3
- Fixes deprecation notices, which in turn fixes CI errors. - Apply all rules. Signed-off-by: Matthew Weier O'Phinney <[email protected]>
1 parent bb2fcc5 commit 04b206f

27 files changed

+541
-349
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.phpcs-cache
12
/clover.xml
23
/coveralls-upload.json
34
/phpunit.xml

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
"laminas/laminas-zendframework-bridge": "^1.0"
4848
},
4949
"require-dev": {
50-
"laminas/laminas-coding-standard": "~1.0.0",
50+
"laminas/laminas-coding-standard": "~2.3.0",
5151
"laminas/laminas-http": "^2.5.4",
52-
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.5"
52+
"phpunit/phpunit": "^7.1.5"
5353
},
5454
"suggest": {
5555
"alcaeus/mongo-php-adapter": "^1.0.5, if you are using ext/mongodb and wish to use the MongoConnectedListener.",

composer.lock

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

config/module.config.php

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
<?php
22

3-
/**
4-
* @see https://github.com/laminas-api-tools/api-tools for the canonical source repository
5-
* @copyright https://github.com/laminas-api-tools/api-tools/blob/master/COPYRIGHT.md
6-
* @license https://github.com/laminas-api-tools/api-tools/blob/master/LICENSE.md New BSD License
7-
*/
3+
declare(strict_types=1);
84

95
namespace Laminas\ApiTools;
106

117
use Laminas\Db\Adapter\AdapterAbstractServiceFactory as DbAdapterAbstractServiceFactory;
128
use Laminas\ServiceManager\Factory\InvokableFactory;
9+
use ZF\Apigility\MvcAuth\UnauthenticatedListener;
10+
use ZF\Apigility\MvcAuth\UnauthorizedListener;
1311

1412
return [
15-
'asset_manager' => [
13+
'asset_manager' => [
1614
'resolver_configs' => [
1715
'paths' => [
1816
__DIR__ . '/../asset',
1917
],
2018
],
2119
],
22-
'router' => [
20+
'router' => [
2321
'routes' => [
2422
'api-tools' => [
25-
'type' => 'literal',
26-
'options' => [
23+
'type' => 'literal',
24+
'options' => [
2725
'route' => '/api-tools',
2826
],
2927
'may_terminate' => false,
@@ -32,21 +30,21 @@
3230
],
3331
'service_manager' => [
3432
// Legacy Zend Framework aliases
35-
'aliases' => [
36-
\ZF\Apigility\MvcAuth\UnauthenticatedListener::class => MvcAuth\UnauthenticatedListener::class,
37-
\ZF\Apigility\MvcAuth\UnauthorizedListener::class => MvcAuth\UnauthorizedListener::class,
33+
'aliases' => [
34+
UnauthenticatedListener::class => MvcAuth\UnauthenticatedListener::class,
35+
UnauthorizedListener::class => MvcAuth\UnauthorizedListener::class,
3836
],
39-
'factories' => [
37+
'factories' => [
4038
MvcAuth\UnauthenticatedListener::class => InvokableFactory::class,
41-
MvcAuth\UnauthorizedListener::class => InvokableFactory::class,
39+
MvcAuth\UnauthorizedListener::class => InvokableFactory::class,
4240
],
4341
'abstract_factories' => [
4442
DbAdapterAbstractServiceFactory::class, // so that db-connected works "out-of-the-box"
4543
DbConnectedResourceAbstractFactory::class,
4644
TableGatewayAbstractFactory::class,
4745
],
4846
],
49-
'api-tools' => [
47+
'api-tools' => [
5048
'db-connected' => [
5149
// @codingStandardsIgnoreStart
5250
/*

phpcs.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.

phpcs.xml.dist

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0"?>
2+
<ruleset
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
5+
6+
<arg name="basepath" value="."/>
7+
<arg name="cache" value=".phpcs-cache"/>
8+
<arg name="colors"/>
9+
<arg name="extensions" value="php"/>
10+
<arg name="parallel" value="80"/>
11+
12+
<!-- Show progress -->
13+
<arg value="p"/>
14+
15+
<!-- Paths to check -->
16+
<file>config</file>
17+
<file>src</file>
18+
<file>test</file>
19+
20+
<!-- Include all rules from Laminas Coding Standard -->
21+
<rule ref="LaminasCodingStandard"/>
22+
</ruleset>

src/ApiToolsModuleInterface.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
<?php
22

3-
/**
4-
* @see https://github.com/laminas-api-tools/api-tools for the canonical source repository
5-
* @copyright https://github.com/laminas-api-tools/api-tools/blob/master/COPYRIGHT.md
6-
* @license https://github.com/laminas-api-tools/api-tools/blob/master/LICENSE.md New BSD License
7-
*/
3+
declare(strict_types=1);
84

95
namespace Laminas\ApiTools;
106

src/Application.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
<?php
22

3-
/**
4-
* @see https://github.com/laminas-api-tools/api-tools for the canonical source repository
5-
* @copyright https://github.com/laminas-api-tools/api-tools/blob/master/COPYRIGHT.md
6-
* @license https://github.com/laminas-api-tools/api-tools/blob/master/LICENSE.md New BSD License
7-
*/
3+
declare(strict_types=1);
84

95
namespace Laminas\ApiTools;
106

@@ -62,8 +58,6 @@ public function run()
6258
$result = $events->triggerEventUntil($shortCircuit, $event);
6359
} catch (Throwable $e) {
6460
return $this->handleException($e, $event, $events);
65-
} catch (Exception $e) {
66-
return $this->handleException($e, $event, $events);
6761
}
6862

6963
if ($result->stopped()) {
@@ -110,8 +104,6 @@ public function run()
110104
* Handle an exception/throwable.
111105
*
112106
* @param Throwable|Exception $exception
113-
* @param MvcEvent $event
114-
* @param EventManagerInterface $events
115107
* @return self
116108
*/
117109
private function handleException($exception, MvcEvent $event, EventManagerInterface $events)

src/Autoloader.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<?php
22

3-
/**
4-
* @see https://github.com/laminas-api-tools/api-tools for the canonical source repository
5-
* @copyright https://github.com/laminas-api-tools/api-tools/blob/master/COPYRIGHT.md
6-
* @license https://github.com/laminas-api-tools/api-tools/blob/master/LICENSE.md New BSD License
7-
*/
3+
declare(strict_types=1);
84

95
namespace Laminas\ApiTools;
106

117
use Laminas\Loader\StandardAutoloader;
128

9+
use function preg_match;
10+
use function str_replace;
11+
1312
/**
1413
* Extends StandardAutoloader to remove "_" as a directory separator
1514
*/
@@ -33,8 +32,8 @@ protected function transformClassNameToFilename($class, $directory)
3332
$matches = [];
3433
preg_match('/(?P<namespace>.+\\\)?(?P<class>[^\\\]+$)/', $class, $matches);
3534

36-
$class = (isset($matches['class'])) ? $matches['class'] : '';
37-
$namespace = (isset($matches['namespace'])) ? $matches['namespace'] : '';
35+
$class = $matches['class'] ?? '';
36+
$namespace = $matches['namespace'] ?? '';
3837

3938
return $directory
4039
. str_replace(self::NS_SEPARATOR, '/', $namespace)

src/DbConnectedResource.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,27 @@
11
<?php
22

3-
/**
4-
* @see https://github.com/laminas-api-tools/api-tools for the canonical source repository
5-
* @copyright https://github.com/laminas-api-tools/api-tools/blob/master/COPYRIGHT.md
6-
* @license https://github.com/laminas-api-tools/api-tools/blob/master/LICENSE.md New BSD License
7-
*/
3+
declare(strict_types=1);
84

95
namespace Laminas\ApiTools;
106

117
use Laminas\ApiTools\ApiProblem\Exception\DomainException;
128
use Laminas\ApiTools\Rest\AbstractResourceListener;
139
use Laminas\Db\TableGateway\TableGatewayInterface as TableGateway;
1410
use Laminas\Paginator\Adapter\DbTableGateway as TableGatewayPaginator;
11+
use Laminas\Paginator\Paginator;
1512

1613
class DbConnectedResource extends AbstractResourceListener
1714
{
18-
/**
19-
* @var string Name of collection class
20-
*/
15+
/** @var string Name of collection class */
2116
protected $collectionClass;
2217

23-
/**
24-
* @var string Name of identifier field
25-
*/
18+
/** @var string Name of identifier field */
2619
protected $identifierName;
2720

28-
/**
29-
* @var TableGateway
30-
*/
21+
/** @var TableGateway */
3122
protected $table;
3223

3324
/**
34-
* @param TableGateway $table
3525
* @param string $identifierName
3626
* @param string $collectionClass
3727
*/
@@ -91,15 +81,15 @@ public function patch($id, $data)
9181
public function delete($id)
9282
{
9383
$item = $this->table->delete([$this->identifierName => $id]);
94-
return ($item > 0);
84+
return $item > 0;
9585
}
9686

9787
/**
9888
* Fetch an existing resource.
9989
*
10090
* @param int|string $id Identifier of resource.
10191
* @return array|object Resource.
102-
* @throws DomainException if the resource is not found.
92+
* @throws DomainException If the resource is not found.
10393
*/
10494
public function fetch($id)
10595
{
@@ -114,7 +104,7 @@ public function fetch($id)
114104
* Fetch a paginated set of resources.
115105
*
116106
* @param array|object $data Ignored.
117-
* @return \Laminas\Paginator\Paginator
107+
* @return Paginator
118108
*/
119109
public function fetchAll($data = [])
120110
{

0 commit comments

Comments
 (0)