From ee5ccef03a02cb887ae6502ba2c4c34ba9c97832 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 4 Feb 2023 16:44:32 +0100 Subject: [PATCH] Misc code improvements and optimizations --- .../Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php | 2 +- .../Component/DependencyInjection/Loader/XmlFileLoader.php | 2 +- src/Symfony/Component/Validator/Constraints/Cidr.php | 2 +- src/Symfony/Component/Yaml/Dumper.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php index a4f34ce4dc6d9..bf2d6347daa38 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php @@ -145,7 +145,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $format = $input->getOption('format'); $xliffVersion = '1.2'; - if (\in_array($format, array_keys(self::FORMATS), true)) { + if (array_key_exists($format, self::FORMATS)) { [$format, $xliffVersion] = self::FORMATS[$format]; } diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index bbe04d7c75011..9bf4955d15ece 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -737,7 +737,7 @@ private function validateAlias(\DOMElement $alias, string $file) if (!$child instanceof \DOMElement || self::NS !== $child->namespaceURI) { continue; } - if (!\in_array($child->localName, ['deprecated'], true)) { + if ('deprecated' !== $child->localName) { throw new InvalidArgumentException(sprintf('Invalid child element "%s" defined for alias "%s" in "%s".', $child->localName, $alias->getAttribute('id'), $file)); } } diff --git a/src/Symfony/Component/Validator/Constraints/Cidr.php b/src/Symfony/Component/Validator/Constraints/Cidr.php index c40669e824dba..ea28afeac29a2 100644 --- a/src/Symfony/Component/Validator/Constraints/Cidr.php +++ b/src/Symfony/Component/Validator/Constraints/Cidr.php @@ -66,7 +66,7 @@ public function __construct( ) { $this->version = $version ?? $options['version'] ?? $this->version; - if (!\in_array($this->version, array_keys(self::NET_MAXES))) { + if (!array_key_exists($this->version, self::NET_MAXES)) { throw new ConstraintDefinitionException(sprintf('The option "version" must be one of "%s".', implode('", "', array_keys(self::NET_MAXES)))); } diff --git a/src/Symfony/Component/Yaml/Dumper.php b/src/Symfony/Component/Yaml/Dumper.php index 19001e7c295a6..51b35a38e9f40 100644 --- a/src/Symfony/Component/Yaml/Dumper.php +++ b/src/Symfony/Component/Yaml/Dumper.php @@ -146,7 +146,7 @@ private function dumpTaggedValue(TaggedValue $value, int $inline, int $indent, i { $output = sprintf('%s!%s', $prefix ? $prefix.' ' : '', $value->getTag()); - if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && false !== strpos($value->getValue(), "\n") && false === strpos($value->getValue(), "\r\n")) { + if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && str_contains($value->getValue(), "\n") && !str_contains($value->getValue(), "\r\n")) { // If the first line starts with a space character, the spec requires a blockIndicationIndicator // http://www.yaml.org/spec/1.2/spec.html#id2793979 $blockIndentationIndicator = (' ' === substr($value->getValue(), 0, 1)) ? (string) $this->indentation : '';