Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/GuessTypeFromSwitcherAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private function guessType(Arg $args, Scope $scope) : Type
foreach($types as $type) {
$rawKey = new ConstantStringType('raw');
if ($type->hasOffsetValueType($rawKey)->yes()) {
$isRaw = $type->getOffsetValueType($rawKey)->toBoolean()->isTrue() ? TrinaryLogic::createYes() : TrinaryLogic::createNo();
$isRaw = $type->getOffsetValueType($rawKey)->toBoolean()->isTrue();
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion tests/data/pll_the_languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@

// With unknown variable merged.
$args = array_merge( [ 'raw' => 1 ], $options );
assertType('array<string, mixed>', pll_the_languages($args));
assertType('array<string, mixed>|string', pll_the_languages($args));

// With raw attribute set to true outside.
$array['raw'] = 1;
assertType('array<string, mixed>', pll_the_languages($array));

// With raw attribute set to false outside.
$array['raw'] = false;
assertType('string', pll_the_languages($array));
18 changes: 17 additions & 1 deletion tests/data/the_languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,26 @@
// Unknown attributes.
assertType('array<string, mixed>|string', $switcher->the_languages($link, $array));

// With unknown variable merged.
// With raw attribute set to true and merged into an array.
$args = array_merge( $array, [ 'raw' => 1 ] );
assertType('array<string, mixed>', $switcher->the_languages($link, $args));

// With raw attribute set to true and merged with an array.
$args = array_merge( [ 'raw' => true ], $array );
assertType('array<string, mixed>|string', $switcher->the_languages($link, $args));

// With raw attribute set to true outside.
$array['raw'] = 1;
assertType('array<string, mixed>', $switcher->the_languages($link, $array));

// With raw attribute set to false outside.
$array['raw'] = false;
assertType('string', $switcher->the_languages($link, $array));

// With raw attribute set to false and merged in an array.
$args = array_merge( $array, [ 'raw' => false ] );
assertType('string', $switcher->the_languages($link, $array));

// With raw attribute set to false and merged with an array.
$args = array_merge( [ 'raw' => false ], $array );
assertType('string', $switcher->the_languages($link, $array));