Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 00daa1c

Browse files
committed
CS fixes
- Ensure all files have file-level docblocks - Use strict_types everywhere - `) :` vs `):` for defining return type hints - Return early
1 parent 30688c3 commit 00daa1c

8 files changed

+70
-21
lines changed

src/ZendModuleProvider.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* @license https://github.com/zendframework/zend-config-aggregator-modulemanager/blob/master/LICENSE.md
66
* New BSD License
77
*/
8+
89
declare(strict_types=1);
910

1011
namespace Zend\ConfigAggregatorModuleManager;
@@ -23,11 +24,10 @@
2324
use Zend\ModuleManager\Feature\ValidatorProviderInterface;
2425

2526
/**
26-
* Provide a configuration by using zend-modulemanager Module files.
27+
* Provide configuration by consuming zend-modulemanager Module classes.
2728
*/
2829
class ZendModuleProvider
2930
{
30-
3131
/**
3232
* @var object
3333
*/
@@ -51,7 +51,7 @@ public function __construct($module)
5151
$this->module = $module;
5252
}
5353

54-
public function __invoke(): array
54+
public function __invoke() : array
5555
{
5656
return array_filter(array_replace_recursive($this->getModuleConfig(), [
5757
$this->getDependenciesIdentifier() => $this->getModuleDependencies(),
@@ -65,7 +65,7 @@ public function __invoke(): array
6565
]));
6666
}
6767

68-
private function getModuleConfig(): array
68+
private function getModuleConfig() : array
6969
{
7070
$module = $this->module;
7171

@@ -90,39 +90,39 @@ private function getModuleConfig(): array
9090
*
9191
* @return array
9292
*/
93-
private function convert($config): array
93+
private function convert($config) : array
9494
{
9595
if ($config instanceof Config) {
96-
$config = $config->toArray();
96+
return $config->toArray();
9797
}
9898

9999
if ($config instanceof Traversable) {
100-
$config = iterator_to_array($config);
100+
return iterator_to_array($config);
101101
}
102102

103103
if (! is_array($config)) {
104104
throw new InvalidArgumentException(sprintf(
105-
'Config being merged must be an array, '
106-
. 'implement the Traversable interface, or be an '
107-
. 'instance of Zend\Config\Config. %s given.',
105+
'Config being merged must be an array, implement the Traversable interface,'
106+
. ' or be an instance of %s. %s given.',
107+
Config::class,
108108
is_object($config) ? get_class($config) : gettype($config)
109109
));
110110
}
111111

112112
return $config;
113113
}
114114

115-
public function getDependenciesIdentifier(): string
115+
public function getDependenciesIdentifier() : string
116116
{
117117
return $this->dependenciesIdentifier;
118118
}
119119

120-
public function setDependenciesIdentifier(string $dependenciesIdentifier): void
120+
public function setDependenciesIdentifier(string $dependenciesIdentifier) : void
121121
{
122122
$this->dependenciesIdentifier = (string) $dependenciesIdentifier;
123123
}
124124

125-
private function getModuleDependencies(): array
125+
private function getModuleDependencies() : array
126126
{
127127
$module = $this->module;
128128
if (! $module instanceof ServiceProviderInterface) {
@@ -132,7 +132,7 @@ private function getModuleDependencies(): array
132132
return array_replace_recursive($this->dependencies, $this->convert($module->getServiceConfig()));
133133
}
134134

135-
public function getRouteConfig(): array
135+
public function getRouteConfig() : array
136136
{
137137
if (! $this->module instanceof RouteProviderInterface) {
138138
return [];
@@ -141,7 +141,7 @@ public function getRouteConfig(): array
141141
return $this->convert($this->module->getRouteConfig());
142142
}
143143

144-
public function getFormElementConfig(): array
144+
public function getFormElementConfig() : array
145145
{
146146
if (! $this->module instanceof FormElementProviderInterface) {
147147
return [];
@@ -150,7 +150,7 @@ public function getFormElementConfig(): array
150150
return $this->convert($this->module->getFormElementConfig());
151151
}
152152

153-
public function getFilterConfig(): array
153+
public function getFilterConfig() : array
154154
{
155155
if (! $this->module instanceof FilterProviderInterface) {
156156
return [];
@@ -159,7 +159,7 @@ public function getFilterConfig(): array
159159
return $this->convert($this->module->getFilterConfig());
160160
}
161161

162-
public function getValidatorConfig(): array
162+
public function getValidatorConfig() : array
163163
{
164164
if (! $this->module instanceof ValidatorProviderInterface) {
165165
return [];
@@ -168,7 +168,7 @@ public function getValidatorConfig(): array
168168
return $this->convert($this->module->getValidatorConfig());
169169
}
170170

171-
public function getHydratorConfig(): array
171+
public function getHydratorConfig() : array
172172
{
173173
if (! $this->module instanceof HydratorProviderInterface) {
174174
return [];
@@ -186,7 +186,7 @@ public function getInputFilterConfig()
186186
return $this->convert($this->module->getInputFilterConfig());
187187
}
188188

189-
public function getSerializerConfig(): array
189+
public function getSerializerConfig() : array
190190
{
191191
if (! $this->module instanceof SerializerProviderInterface) {
192192
return [];

test/Resources/ServiceManagerConfigurationTrait.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-config-aggregator-modulemanager for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-config-aggregator-modulemanager/blob/master/LICENSE.md
6+
* New BSD License
7+
*/
8+
9+
declare(strict_types=1);
210

311
namespace ZendTest\ConfigAggregatorModuleManager\Resources;
412

513
trait ServiceManagerConfigurationTrait
614
{
7-
private function createServiceManagerConfiguration(): array
15+
private function createServiceManagerConfiguration() : array
816
{
917
return [
1018
'factories' => [],

test/Resources/ZendModule.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-config-aggregator-modulemanager for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-config-aggregator-modulemanager/blob/master/LICENSE.md
6+
* New BSD License
7+
*/
8+
9+
declare(strict_types=1);
210

311
namespace ZendTest\ConfigAggregatorModuleManager\Resources;
412

test/Resources/ZendModuleWithInvalidConfiguration.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-config-aggregator-modulemanager for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-config-aggregator-modulemanager/blob/master/LICENSE.md
6+
* New BSD License
7+
*/
8+
9+
declare(strict_types=1);
210

311
namespace ZendTest\ConfigAggregatorModuleManager\Resources;
412

test/Resources/ZendModuleWithTraversableConfig.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-config-aggregator-modulemanager for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-config-aggregator-modulemanager/blob/master/LICENSE.md
6+
* New BSD License
7+
*/
8+
9+
declare(strict_types=1);
210

311
namespace ZendTest\ConfigAggregatorModuleManager\Resources;
412

test/Resources/ZendModuleWithZendConfig.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-config-aggregator-modulemanager for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-config-aggregator-modulemanager/blob/master/LICENSE.md
6+
* New BSD License
7+
*/
8+
9+
declare(strict_types=1);
210

311
namespace ZendTest\ConfigAggregatorModuleManager\Resources;
412

test/Resources/ZendModuleWithoutImplementingInterfaces.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-config-aggregator-modulemanager for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-config-aggregator-modulemanager/blob/master/LICENSE.md
6+
* New BSD License
7+
*/
8+
9+
declare(strict_types=1);
210

311
namespace ZendTest\ConfigAggregatorModuleManager\Resources;
412

test/ZendModuleProviderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* New BSD License
77
*/
88

9+
declare(strict_types=1);
10+
911
namespace ZendTest\ConfigAggregatorModuleManager;
1012

1113
use InvalidArgumentException;
@@ -31,7 +33,6 @@
3133
*/
3234
class ZendModuleProviderTest extends TestCase
3335
{
34-
3536
use ServiceManagerConfigurationTrait;
3637

3738
public function testCanProvideDependenciesFromServiceProviderInterface()

0 commit comments

Comments
 (0)