From 1fe8404e2dbf6e883afa2d36f0d74da1bdf58239 Mon Sep 17 00:00:00 2001 From: DerManoMann Date: Tue, 17 Mar 2026 15:02:26 +1300 Subject: [PATCH 1/3] Use `in_array` with `strict: true` where appropriate --- src/Analysis.php | 2 +- src/Annotations/AbstractAnnotation.php | 2 +- src/Annotations/Schema.php | 2 +- src/Loggers/ConsoleLogger.php | 2 +- src/Processors/Concerns/MergePropertiesTrait.php | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Analysis.php b/src/Analysis.php index 762c94e35..1e0d7787a 100644 --- a/src/Analysis.php +++ b/src/Analysis.php @@ -71,7 +71,7 @@ public function addAnnotation(OA\AbstractAnnotation $annotation, Context $contex $context->annotations = []; } - if (in_array($annotation, $context->annotations, true) === false) { + if (in_array($annotation, $context->annotations, strict: true) === false) { $context->annotations[] = $annotation; } } diff --git a/src/Annotations/AbstractAnnotation.php b/src/Annotations/AbstractAnnotation.php index 965fd604b..90815627f 100644 --- a/src/Annotations/AbstractAnnotation.php +++ b/src/Annotations/AbstractAnnotation.php @@ -448,7 +448,7 @@ private function validateValueType(string $type, mixed $value): bool 'number' => is_numeric($value), 'object' => is_object($value), 'array' => is_array($value) && array_is_list($value), - 'scheme' => in_array($value, ['http', 'https', 'ws', 'wss'], true), + 'scheme' => in_array($value, ['http', 'https', 'ws', 'wss'], strict: true), default => throw new OpenApiException('Invalid type "' . $type . '"'), }; diff --git a/src/Annotations/Schema.php b/src/Annotations/Schema.php index 43e942368..a89e951a9 100644 --- a/src/Annotations/Schema.php +++ b/src/Annotations/Schema.php @@ -353,7 +353,7 @@ public function isNullable(): bool */ public function hasType(string $type): bool { - return in_array($type, (array) $this->type, true); + return in_array($type, (array) $this->type, strict: true); } public function jsonSerialize(): \stdClass diff --git a/src/Loggers/ConsoleLogger.php b/src/Loggers/ConsoleLogger.php index 34f2397e7..51c6ebadb 100644 --- a/src/Loggers/ConsoleLogger.php +++ b/src/Loggers/ConsoleLogger.php @@ -66,7 +66,7 @@ public function log($level, $message, array $context = []): void } $stop = empty($color) ? '' : static::COLOR_STOP; - if (!in_array($level, self::LOG_LEVELS_UP_TO_NOTICE, true)) { + if (!in_array($level, self::LOG_LEVELS_UP_TO_NOTICE, strict: true)) { $this->loggedMessageAboveNotice = true; } diff --git a/src/Processors/Concerns/MergePropertiesTrait.php b/src/Processors/Concerns/MergePropertiesTrait.php index 86748d8d1..c01ee17a4 100644 --- a/src/Processors/Concerns/MergePropertiesTrait.php +++ b/src/Processors/Concerns/MergePropertiesTrait.php @@ -40,7 +40,7 @@ protected function mergeProperties(OA\Schema $schema, array $from, array &$exist foreach ($from['properties'] as $context) { if (is_iterable($context->annotations)) { foreach ($context->annotations as $annotation) { - if ($annotation instanceof OA\Property && !in_array($annotation->_context->property, $existing, true)) { + if ($annotation instanceof OA\Property && !in_array($annotation->_context->property, $existing, strict: true)) { $existing[] = $annotation->_context->property; $schema->merge([$annotation], true); } @@ -54,7 +54,7 @@ protected function mergeMethods(OA\Schema $schema, array $from, array &$existing foreach ($from['methods'] as $context) { if (is_iterable($context->annotations)) { foreach ($context->annotations as $annotation) { - if ($annotation instanceof OA\Property && !in_array($annotation->_context->property, $existing, true)) { + if ($annotation instanceof OA\Property && !in_array($annotation->_context->property, $existing, strict: true)) { $existing[] = $annotation->_context->property; $schema->merge([$annotation], true); } From 7d1f81f918fc2c5bf168ac5e7d4baa79c3943c34 Mon Sep 17 00:00:00 2001 From: DerManoMann Date: Tue, 17 Mar 2026 15:04:27 +1300 Subject: [PATCH 2/3] Update cs-fixer rules to use new `modifier_keywords` rule --- .php-cs-fixer.dist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 0f94e7343..cf85c2438 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -38,7 +38,7 @@ 'ordered_imports' => true, 'no_unused_imports' => true, 'blank_line_before_statement' => ['statements' => ['return']], - 'visibility_required' => true, + 'modifier_keywords' => true, 'cast_spaces' => ['space' => 'single'], 'concat_space' => ['spacing' => 'one'], 'type_declaration_spaces' => true, From 616795e5287e43d049d81bf78c85a385a576d4f5 Mon Sep 17 00:00:00 2001 From: DerManoMann Date: Tue, 17 Mar 2026 15:10:42 +1300 Subject: [PATCH 3/3] . --- src/Serializer.php | 2 +- src/Type/LegacyTypeResolver.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Serializer.php b/src/Serializer.php index 329c11dcd..34a539bdb 100644 --- a/src/Serializer.php +++ b/src/Serializer.php @@ -97,7 +97,7 @@ public function deserializeFile(string $filename, string $format = 'json', strin $contents = file_get_contents($filename); $ext = pathinfo($filename, PATHINFO_EXTENSION); - if ('yaml' === $format || in_array($ext, ['yml', 'yaml'])) { + if ('yaml' === $format || in_array($ext, ['yml', 'yaml'], strict: true)) { $contents = json_encode(Yaml::parse($contents)); } diff --git a/src/Type/LegacyTypeResolver.php b/src/Type/LegacyTypeResolver.php index b19ada877..6094d6c0e 100644 --- a/src/Type/LegacyTypeResolver.php +++ b/src/Type/LegacyTypeResolver.php @@ -103,7 +103,7 @@ protected function augmentItems(OA\Schema $schema, Analysis $analysis): void protected function normaliseTypeResult(?string $explicitType = null, ?array $explicitDetails = null, array $types = [], ?string $name = null, ?bool $nullable = null, ?bool $isArray = null, bool $unsupported = false, ?Context $context = null): \stdClass { - $types = array_filter($types, static fn (string $t): bool => !in_array($t, ['null', ''])); + $types = array_filter($types, static fn (string $t): bool => !in_array($t, ['null', ''], strict: true)); if ($context) { foreach ($types as $ii => $type) {