Skip to content

Commit 4ae4fba

Browse files
committed
Fix php stan errors
1 parent 3502a44 commit 4ae4fba

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

src/Internal/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,6 @@ private static function syncFlags(array $config): void
278278
self::$magicProperties = (bool) ($config['magic_properties'] ?? true);
279279
self::$magicMethods = (bool) ($config['magic_methods'] ?? true);
280280
self::$respectIgnoreTags = (bool) ($config['respect_ignore_tags'] ?? true);
281-
self::$arrayValidation = (string) ($config['array_validation'] ?? 'full');
281+
self::$arrayValidation = \is_string($config['array_validation'] ?? null) ? $config['array_validation'] : 'full';
282282
}
283283
}

src/Validator/ArrayValidator.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@
2121
*/
2222
final class ArrayValidator implements TypeValidatorInterface
2323
{
24-
private const HYBRID_SAMPLE_THRESHOLD = 128;
24+
private const HYBRID_SAMPLE_THRESHOLD = 64;
2525

26-
/**
27-
* Validates an array or Traversable collection against an ArrayTypeNode (Type[]).
28-
* Accepts native arrays and Traversable objects (e.g. ArrayIterator, Symfony RewindableGenerator).
29-
* Bypasses eager iteration on Generator instances to prevent premature generator closure.
30-
*/
3126
public function validate(mixed $value, TypeNode $node, string $context, TypeValidatorRegistry $registry): ?ErrorMessage
3227
{
3328
if (! \is_array($value) && ! ($value instanceof Traversable)) {
@@ -54,7 +49,7 @@ public function validate(mixed $value, TypeNode $node, string $context, TypeVali
5449
foreach ($value as $k => $v) {
5550
$err = $registry->validate($v, $arrayNode->type, '');
5651
if ($err !== null) {
57-
$keyStr = (\is_scalar($k) || $k === null) ? (string) $k : get_debug_type($k);
52+
$keyStr = (string) $k;
5853

5954
return ErrorFactory::createError($context . '[' . $keyStr . ']' . $err->getMessage());
6055
}
@@ -112,12 +107,12 @@ private function validateArrayHybrid(
112107
foreach ($sampleKeys as $k) {
113108
$err = $registry->validate($value[$k], $arrayNode->type, '');
114109
if ($err !== null) {
115-
$keyStr = (\is_scalar($k) || $k === null) ? (string) $k : get_debug_type($k);
110+
$keyStr = (string) $k;
116111

117112
return ErrorFactory::createError($context . '[' . $keyStr . ']' . $err->getMessage());
118113
}
119114
}
120115

121116
return null;
122117
}
123-
}
118+
}

0 commit comments

Comments
 (0)