private static function mergeParameterPair()

in src/api-gen/DataMerger.php [563:600]


  private static function mergeParameterPair(
    ScannedParameter $a,
    ScannedParameter $b,
  ): ScannedParameter {
    $visibility = null;
    if ($a->__isPromoted()) {
      $visibility = $a->__getVisibility();
    } else if ($b->__isPromoted()) {
      $visibility = $b->__getVisibility();
    }
    $default = null;
    if ($a->isOptional()) {
      $default = $a->getDefault();
    }
    if ($b->isOptional()) {
      $bds = TypeAssert\not_null($b->getDefault());
      if (
        $default === null ||
        Str\length($bds->getAST()->getCode()) >
          Str\length($default->getAST()->getCode())
      ) {
        $default = $bds;
      }
    }

    return new ScannedParameter(
      $a->getASTx(),
      self::mergeNames($a->getName(), $b->getName()),
      $a->getContext(),
      self::mergeAttributes($a->getAttributes(), $b->getAttributes()),
      self::mergeDocComments($a->getDocComment(), $b->getDocComment()),
      self::mergeTypehintPair($a->getTypehint(), $b->getTypehint()),
      $a->isInOut() || $b->isInOut(),
      $a->isVariadic() || $b->isVariadic(),
      $default,
      $visibility,
    );
  }