Skip to content

Commit 2a2558f

Browse files
Merge branch '5.1' into 5.2
* 5.1: Changed private static array-properties to const
2 parents 8783a8f + 9427132 commit 2a2558f

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 ? get_debug_type($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
@@ -127,7 +127,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
127127

128128
private $removedBindingIds = [];
129129

130-
private static $internalTypes = [
130+
private const INTERNAL_TYPES = [
131131
'int' => true,
132132
'float' => true,
133133
'string' => true,
@@ -334,7 +334,7 @@ public function getReflectionClass(?string $class, bool $throw = true): ?\Reflec
334334
return null;
335335
}
336336

337-
if (isset(self::$internalTypes[$class])) {
337+
if (isset(self::INTERNAL_TYPES[$class])) {
338338
return null;
339339
}
340340

Loader/YamlFileLoader.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
*/
4040
class YamlFileLoader extends FileLoader
4141
{
42-
private static $serviceKeywords = [
42+
private const SERVICE_KEYWORDS = [
4343
'alias' => 'alias',
4444
'parent' => 'parent',
4545
'class' => 'class',
@@ -65,7 +65,7 @@ class YamlFileLoader extends FileLoader
6565
'bind' => 'bind',
6666
];
6767

68-
private static $prototypeKeywords = [
68+
private const PROTOTYPE_KEYWORDS = [
6969
'resource' => 'resource',
7070
'namespace' => 'namespace',
7171
'exclude' => 'exclude',
@@ -86,7 +86,7 @@ class YamlFileLoader extends FileLoader
8686
'bind' => 'bind',
8787
];
8888

89-
private static $instanceofKeywords = [
89+
private const INSTANCEOF_KEYWORDS = [
9090
'shared' => 'shared',
9191
'lazy' => 'lazy',
9292
'public' => 'public',
@@ -98,7 +98,7 @@ class YamlFileLoader extends FileLoader
9898
'bind' => 'bind',
9999
];
100100

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

253253
foreach ($defaults as $key => $default) {
254-
if (!isset(self::$defaultsKeywords[$key])) {
255-
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)));
254+
if (!isset(self::DEFAULTS_KEYWORDS[$key])) {
255+
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)));
256256
}
257257
}
258258

@@ -919,11 +919,11 @@ private function loadFromExtensions(array $content)
919919
private function checkDefinition(string $id, array $definition, string $file)
920920
{
921921
if ($this->isLoadingInstanceof) {
922-
$keywords = self::$instanceofKeywords;
922+
$keywords = self::INSTANCEOF_KEYWORDS;
923923
} elseif (isset($definition['resource']) || isset($definition['namespace'])) {
924-
$keywords = self::$prototypeKeywords;
924+
$keywords = self::PROTOTYPE_KEYWORDS;
925925
} else {
926-
$keywords = self::$serviceKeywords;
926+
$keywords = self::SERVICE_KEYWORDS;
927927
}
928928

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

0 commit comments

Comments
 (0)