/**
  * Two union types are equal if they have the same number of alternates
  * and all alternates are equal.
  */
 public function equals(PhpType $that)
 {
     if ($that->isUnionType()) {
         $that = $that->toMaybeUnionType();
         if (count($this->alternates) !== count($that->getAlternates())) {
             return false;
         }
         foreach ($that->getAlternates() as $alternate) {
             if (!$this->contains($alternate)) {
                 return false;
             }
         }
         return true;
     }
     return false;
 }