Skip to content

Commit b0c1932

Browse files
committed
Attempted fix for PHPstan-issues
1 parent 2ddbcaf commit b0c1932

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/Codebooks/MetadataPolicyOperatorsEnum.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,26 @@ public function getSupportedParameterContainedValueTypes(): array
137137

138138

139139
/**
140-
* @phpstan-ignore missingType.iterableValue (We can handle mixed type using array_diff)
140+
* @param mixed $value scalar or stringable object
141+
* @param string[] $superset
141142
*/
142143
public function isValueSubsetOf(mixed $value, array $superset): bool
143144
{
144145
$value = is_array($value) ? $value : [$value];
145146

146-
return array_diff($value, $superset) === [];
147+
$cast = static fn(mixed $v): string|int|float|bool|null =>
148+
is_object($v) && method_exists($v, '__toString') ? (string) $v : $v;
149+
150+
return array_diff(
151+
array_map($cast, $value),
152+
array_map($cast, $superset)
153+
) === [];
147154
}
148155

149156

150157
/**
151-
* @phpstan-ignore missingType.iterableValue (We can handle mixed type using array_diff)
158+
* @param string|int|float|bool|null|object $value scalar or stringable object
159+
* @param array<string|int|float|bool|null|object> $subset
152160
*/
153161
public function isValueSupersetOf(mixed $value, array $subset): bool
154162
{

0 commit comments

Comments
 (0)