Skip to content

Commit 3dc5159

Browse files
committedApr 2, 2020
Use internal constant instead of private static property
Disabled PSR12.Properties.ConstantVisibility.NotFound CS rule, as we still on PHP 5.6 in this library. Signed-off-by: Michał Bundyra <[email protected]>
1 parent 6cf2278 commit 3dc5159

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed
 

‎phpcs.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?xml version="1.0"?>
22
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
4-
<rule ref="PSR12"/>
4+
<rule ref="PSR12">
5+
<exclude name="PSR12.Properties.ConstantVisibility.NotFound"/>
6+
</rule>
57
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
68

79
<arg value="p"/>

‎src/ConfigPostProcessor.php

+10-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
namespace Laminas\ZendFrameworkBridge;
1010

11-
use function array_flip;
1211
use function array_intersect_key;
1312
use function array_key_exists;
1413
use function array_pop;
@@ -22,8 +21,13 @@
2221

2322
class ConfigPostProcessor
2423
{
25-
/** @var array<string> */
26-
private static $SERVICE_MANAGER_KEYS_OF_INTEREST = ['aliases', 'invokables', 'factories', 'services'];
24+
/** @internal */
25+
const SERVICE_MANAGER_KEYS_OF_INTEREST = [
26+
'aliases' => true,
27+
'factories' => true,
28+
'invokables' => true,
29+
'services' => true,
30+
];
2731

2832
/** @var array String keys => string values */
2933
private $exactReplacements = [
@@ -79,9 +83,7 @@ function ($value, array $keys) {
7983

8084
// service- and pluginmanager handling
8185
function ($value) {
82-
$keysOfInterest = self::$SERVICE_MANAGER_KEYS_OF_INTEREST;
83-
84-
return is_array($value) && array_intersect_key(array_flip($keysOfInterest), $value) !== []
86+
return is_array($value) && array_intersect_key(self::SERVICE_MANAGER_KEYS_OF_INTEREST, $value) !== []
8587
? [$this, 'replaceDependencyConfiguration']
8688
: null;
8789
},
@@ -257,8 +259,9 @@ private function replaceDependencyConfiguration(array $config)
257259
$config = $this->replaceDependencyFactories($config);
258260
$config = $this->replaceDependencyServices($config);
259261

262+
$keys = self::SERVICE_MANAGER_KEYS_OF_INTEREST;
260263
foreach ($config as $key => $data) {
261-
if (in_array($key, self::$SERVICE_MANAGER_KEYS_OF_INTEREST, true)) {
264+
if (isset($keys[$key])) {
262265
continue;
263266
}
264267

0 commit comments

Comments
 (0)
Please sign in to comment.