Skip to content

Commit 0398f4e

Browse files
minor #53073 Set strict parameter of in_array to true where possible (alexandre-daubois)
This PR was merged into the 7.1 branch. Discussion ---------- Set `strict` parameter of `in_array` to true where possible | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT This pull request introduces a comprehensive update where the `in_array` function is now consistently invoked with the `strict` parameter set to `true`. This change is implemented across various components of the framework to enhance type safety and reliability. To me, this update is a step towards more explicit and error-resistant code. Commits ------- 442329a50f Set `strict` parameter of `in_array` to true where possible
2 parents 2759e85 + 0009662 commit 0398f4e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Compiler/RegisterEnvVarProcessorsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ 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::ALLOWED_TYPES)) {
68+
if (!\in_array($type, self::ALLOWED_TYPES, true)) {
6969
throw new InvalidArgumentException(sprintf('Invalid type "%s" returned by "%s::getProvidedTypes()", expected one of "%s".', $type, $class, implode('", "', self::ALLOWED_TYPES)));
7070
}
7171
}

Compiler/ResolveInstanceofConditionalsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ private function processDefinition(ContainerBuilder $container, string $id, Defi
127127
foreach ($tags as $k => $v) {
128128
if (null === $definition->getDecoratedService() || $interface === $definition->getClass() || \in_array($k, $tagsToKeep, true)) {
129129
foreach ($v as $v) {
130-
if ($definition->hasTag($k) && \in_array($v, $definition->getTag($k))) {
130+
if ($definition->hasTag($k) && \in_array($v, $definition->getTag($k), true)) {
131131
continue;
132132
}
133133
$definition->addTag($k, $v);

0 commit comments

Comments
 (0)