Skip to content

Commit 4b4ce51

Browse files
minor symfony#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 ------- 442329a Set `strict` parameter of `in_array` to true where possible
2 parents e7c92a4 + 442329a commit 4b4ce51

File tree

62 files changed

+82
-82
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+82
-82
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
223223
}
224224
}
225225

226-
if (!\in_array(self::MESSAGE_UNUSED, $states) && $input->getOption('only-unused')
227-
|| !\in_array(self::MESSAGE_MISSING, $states) && $input->getOption('only-missing')
226+
if (!\in_array(self::MESSAGE_UNUSED, $states, true) && $input->getOption('only-unused')
227+
|| !\in_array(self::MESSAGE_MISSING, $states, true) && $input->getOption('only-missing')
228228
) {
229229
continue;
230230
}

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function process(ContainerBuilder $container): void
110110

111111
foreach ($container->findUnusedTags() as $tag) {
112112
// skip known tags
113-
if (\in_array($tag, self::KNOWN_TAGS)) {
113+
if (\in_array($tag, self::KNOWN_TAGS, true)) {
114114
continue;
115115
}
116116

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode): void
435435
if (!\is_string($value)) {
436436
return true;
437437
}
438-
if (class_exists(WorkflowEvents::class) && !\in_array($value, WorkflowEvents::ALIASES)) {
438+
if (class_exists(WorkflowEvents::class) && !\in_array($value, WorkflowEvents::ALIASES, true)) {
439439
return true;
440440
}
441441
}

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2179,7 +2179,7 @@ private function registerMessengerConfiguration(array $config, ContainerBuilder
21792179
->setArguments([$transport['dsn'], $transport['options'] + ['transport_name' => $name], new Reference($serializerId)])
21802180
->addTag('messenger.receiver', [
21812181
'alias' => $name,
2182-
'is_failure_transport' => \in_array($name, $failureTransports),
2182+
'is_failure_transport' => \in_array($name, $failureTransports, true),
21832183
]
21842184
)
21852185
;

src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private function addFormThemesSection(ArrayNodeDefinition $rootNode): void
6464
->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end()
6565
->example(['@My/form.html.twig'])
6666
->validate()
67-
->ifTrue(fn ($v) => !\in_array('form_div_layout.html.twig', $v))
67+
->ifTrue(fn ($v) => !\in_array('form_div_layout.html.twig', $v, true))
6868
->then(fn ($v) => array_merge(['form_div_layout.html.twig'], $v))
6969
->end()
7070
->end()

src/Symfony/Component/Console/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ public function find(string $name): Command
716716

717717
$aliases[$nameOrAlias] = $commandName;
718718

719-
return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
719+
return $commandName === $nameOrAlias || !\in_array($commandName, $commands, true);
720720
}));
721721
}
722722

src/Symfony/Component/Console/Descriptor/ReStructuredTextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private function getNonDefaultOptions(InputDefinition $definition): array
226226
$nonDefaultOptions = [];
227227
foreach ($definition->getOptions() as $option) {
228228
// Skip global options.
229-
if (!\in_array($option->getName(), $globalOptions)) {
229+
if (!\in_array($option->getName(), $globalOptions, true)) {
230230
$nonDefaultOptions[] = $option;
231231
}
232232
}

src/Symfony/Component/Console/Helper/TableCellStyle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function getTagOptions(): array
6767
{
6868
return array_filter(
6969
$this->getOptions(),
70-
fn ($key) => \in_array($key, self::TAG_OPTIONS) && isset($this->options[$key]),
70+
fn ($key) => \in_array($key, self::TAG_OPTIONS, true) && isset($this->options[$key]),
7171
\ARRAY_FILTER_USE_KEY
7272
);
7373
}

src/Symfony/Component/CssSelector/Parser/Token.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function isDelimiter(array $values = []): bool
7272
return true;
7373
}
7474

75-
return \in_array($this->value, $values);
75+
return \in_array($this->value, $values, true);
7676
}
7777

7878
public function isWhitespace(): bool

src/Symfony/Component/DependencyInjection/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
}

0 commit comments

Comments
 (0)