Skip to content

Commit

Permalink
fix logic overwrite creating wrong changes
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmuffme committed Dec 6, 2022
1 parent ccd2008 commit 0036f0a
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/Hooks/StrictEqualityHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,38 +173,49 @@ private static function isUnionCompatibleType(array $left_type_atomics, array $r

private static function isUnionStringEqualOrdered(array $first_types, array $second_types): bool
{
$generic_string = false;
$non_empty_string = false;
$literal_string = false;
foreach ($first_types as $atomic_type) {
if ($atomic_type instanceof Atomic\TNonFalsyString) {
if ($generic_string === false && $non_empty_string === false && $literal_string === false && $atomic_type instanceof Atomic\TNonFalsyString) {
$with_false = true;
$with_true = false;
$with_null = true;
continue;
}

if ($atomic_type instanceof Atomic\TLiteralString) {
if ((bool) $atomic_type->value === true) {
if ($generic_string === false && $non_empty_string === false && $atomic_type instanceof Atomic\TLiteralString) {
$literal_string = true;
if ((!isset($with_false) || $with_false === true) && (bool) $atomic_type->value === true) {
$with_false = true;
$with_true = false;
} else {
} elseif ((!isset($with_false) || $with_false === false)) {
$with_false = false;
$with_true = true;
} else {
$with_false = false;
$with_true = false;
}

$with_null = false;
if ($atomic_type->value !== '') {
if ((!isset($with_null) || $with_null === true) && $atomic_type->value !== '') {
$with_null = true;
} else {
$with_null = false;
}

continue;
}

if ($atomic_type instanceof Atomic\TNonEmptyString) {
if ($generic_string === false && $atomic_type instanceof Atomic\TNonEmptyString) {
$non_empty_string = true;
$with_false = false;
$with_true = false;
$with_null = true;
continue;
}

if ($atomic_type instanceof Atomic\TString) {
$generic_string = true;
$with_false = false;
$with_true = false;
$with_null = false;
Expand Down

0 comments on commit 0036f0a

Please sign in to comment.