Skip to content

Commit d749132

Browse files
committed
Changed private static array-properties to const
1 parent 1c6cd99 commit d749132

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

Compiler/RegisterEnvVarProcessorsPass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
class RegisterEnvVarProcessorsPass implements CompilerPassInterface
2727
{
28-
private static $allowedTypes = ['array', 'bool', 'float', 'int', 'string'];
28+
private const ALLOWED_TYPES = ['array', 'bool', 'float', 'int', 'string'];
2929

3030
public function process(ContainerBuilder $container)
3131
{
@@ -65,8 +65,8 @@ private static function validateProvidedTypes(string $types, string $class): arr
6565
$types = explode('|', $types);
6666

6767
foreach ($types as $type) {
68-
if (!\in_array($type, self::$allowedTypes)) {
69-
throw new InvalidArgumentException(sprintf('Invalid type "%s" returned by "%s::getProvidedTypes()", expected one of "%s".', $type, $class, implode('", "', self::$allowedTypes)));
68+
if (!\in_array($type, self::ALLOWED_TYPES)) {
69+
throw new InvalidArgumentException(sprintf('Invalid type "%s" returned by "%s::getProvidedTypes()", expected one of "%s".', $type, $class, implode('", "', self::ALLOWED_TYPES)));
7070
}
7171
}
7272

Compiler/ValidateEnvPlaceholdersPass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727
class ValidateEnvPlaceholdersPass implements CompilerPassInterface
2828
{
29-
private static $typeFixtures = ['array' => [], 'bool' => false, 'float' => 0.0, 'int' => 0, 'string' => ''];
29+
private const TYPE_FIXTURES = ['array' => [], 'bool' => false, 'float' => 0.0, 'int' => 0, 'string' => ''];
3030

3131
private $extensionConfig = [];
3232

@@ -52,13 +52,13 @@ public function process(ContainerBuilder $container)
5252
foreach ($resolvingBag->getEnvPlaceholders() + $resolvingBag->getUnusedEnvPlaceholders() as $env => $placeholders) {
5353
$values = [];
5454
if (false === $i = strpos($env, ':')) {
55-
$default = $defaultBag->has("env($env)") ? $defaultBag->get("env($env)") : self::$typeFixtures['string'];
55+
$default = $defaultBag->has("env($env)") ? $defaultBag->get("env($env)") : self::TYPE_FIXTURES['string'];
5656
$defaultType = null !== $default ? self::getType($default) : 'string';
5757
$values[$defaultType] = $default;
5858
} else {
5959
$prefix = substr($env, 0, $i);
6060
foreach ($envTypes[$prefix] ?? ['string'] as $type) {
61-
$values[$type] = self::$typeFixtures[$type] ?? null;
61+
$values[$type] = self::TYPE_FIXTURES[$type] ?? null;
6262
}
6363
}
6464
foreach ($placeholders as $placeholder) {

ContainerBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
126126

127127
private $removedBindingIds = [];
128128

129-
private static $internalTypes = [
129+
private const INTERNAL_TYPES = [
130130
'int' => true,
131131
'float' => true,
132132
'string' => true,
@@ -339,7 +339,7 @@ public function getReflectionClass(?string $class, bool $throw = true): ?\Reflec
339339
return null;
340340
}
341341

342-
if (isset(self::$internalTypes[$class])) {
342+
if (isset(self::INTERNAL_TYPES[$class])) {
343343
return null;
344344
}
345345

Loader/YamlFileLoader.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*/
3939
class YamlFileLoader extends FileLoader
4040
{
41-
private static $serviceKeywords = [
41+
private const SERVICE_KEYWORDS = [
4242
'alias' => 'alias',
4343
'parent' => 'parent',
4444
'class' => 'class',
@@ -64,7 +64,7 @@ class YamlFileLoader extends FileLoader
6464
'bind' => 'bind',
6565
];
6666

67-
private static $prototypeKeywords = [
67+
private const PROTOTYPE_KEYWORDS = [
6868
'resource' => 'resource',
6969
'namespace' => 'namespace',
7070
'exclude' => 'exclude',
@@ -85,7 +85,7 @@ class YamlFileLoader extends FileLoader
8585
'bind' => 'bind',
8686
];
8787

88-
private static $instanceofKeywords = [
88+
private const INSTANCEOF_KEYWORDS = [
8989
'shared' => 'shared',
9090
'lazy' => 'lazy',
9191
'public' => 'public',
@@ -97,7 +97,7 @@ class YamlFileLoader extends FileLoader
9797
'bind' => 'bind',
9898
];
9999

100-
private static $defaultsKeywords = [
100+
private const DEFAULTS_KEYWORDS = [
101101
'public' => 'public',
102102
'tags' => 'tags',
103103
'autowire' => 'autowire',
@@ -250,8 +250,8 @@ private function parseDefaults(array &$content, string $file): array
250250
}
251251

252252
foreach ($defaults as $key => $default) {
253-
if (!isset(self::$defaultsKeywords[$key])) {
254-
throw new InvalidArgumentException(sprintf('The configuration key "%s" cannot be used to define a default value in "%s". Allowed keys are "%s".', $key, $file, implode('", "', self::$defaultsKeywords)));
253+
if (!isset(self::DEFAULTS_KEYWORDS[$key])) {
254+
throw new InvalidArgumentException(sprintf('The configuration key "%s" cannot be used to define a default value in "%s". Allowed keys are "%s".', $key, $file, implode('", "', self::DEFAULTS_KEYWORDS)));
255255
}
256256
}
257257

@@ -864,11 +864,11 @@ private function loadFromExtensions(array $content)
864864
private function checkDefinition(string $id, array $definition, string $file)
865865
{
866866
if ($this->isLoadingInstanceof) {
867-
$keywords = self::$instanceofKeywords;
867+
$keywords = self::INSTANCEOF_KEYWORDS;
868868
} elseif (isset($definition['resource']) || isset($definition['namespace'])) {
869-
$keywords = self::$prototypeKeywords;
869+
$keywords = self::PROTOTYPE_KEYWORDS;
870870
} else {
871-
$keywords = self::$serviceKeywords;
871+
$keywords = self::SERVICE_KEYWORDS;
872872
}
873873

874874
foreach ($definition as $key => $value) {

0 commit comments

Comments
 (0)