$wildcard_op_result =
$a_wildcard->
$operation_method_name($b_wildcard);
// Early return if both operands contain only wildcard tags.
if (count($a_wildcard->elements
) ===
count($a->elements
) &&
count($b_wildcard->elements
) ===
count($b->elements
)) { return $wildcard_op_result;
} // 2. Operation applied with wildcard tags resolved into concrete tags.
// For example: <p class="text-align-center"> in the first operand and
// <$text-container class="text-align-center"> in the second
// operand.
$a_concrete = self::
resolveWildcards($a);
$b_concrete = self::
resolveWildcards($b);
$concrete_op_result =
$a_concrete->
$operation_method_name($b_concrete);
// Using the PHP array union operator is safe because the two operation
// result arrays ensure there is no overlap between the array keys.
// @codingStandardsIgnoreStart
assert(Inspector::
assertAll(function D
$t) { return self::
isWildcardTag($t);
},
array_keys($wildcard_op_result->elements
)));
assert(Inspector::
assertAll(function D
$t) { return !self::
isWildcardTag($t);
},
array_keys($concrete_op_result->elements
)));
// @codingStandardsIgnoreEnd
return new self($concrete_op_result->elements +
$wildcard_op_result->elements
);
}