public function merge(JsonSchema $left, JsonSchema $right)
    {
        $merged = clone $right;

        if ($left->getType() !== null && $right->getType() !== null && $left->getType() !== $right->getType()) {
            throw new \RuntimeException("Both types are defined and different, merge is not possible");
        }

        if ($right->getType() === null && $left->getType() !== null) {
            $merged->setType($left->getType());
        }

        $merged->setProperties($this->arrayMerge($left->getProperties(), $right->getProperties()));
        $merged->setRequired($this->arrayUnique($this->arrayMerge($left->getRequired(), $right->getRequired())));

        return $merged;
    }
public function merge(JsonSchema $left, JsonSchema $right)
    {
        $merged = clone $right;

        if ($left->getType() !== null && $right->getType() !== null && $left->getType() !== $right->getType()) {
            throw new \RuntimeException("Both types are defined and different, merge is not possible");
        }

        if ($right->getType() === null && $left->getType() !== null) {
            $merged->setType($left->getType());
        }

        $merged->setProperties($this->arrayMerge($left->getProperties(), $right->getProperties()));
        $merged->setRequired($this->arrayUnique($this->arrayMerge($left->getRequired(), $right->getRequired())));

        return $merged;
    }
public function merge ( JsonSchema $ left , JsonSchema $ right ) { $ merged = clone $ right ; if ( $ left -> getType ( ) !== null && $ right -> getType ( ) !== null && $ left -> getType ( ) !== $ right -> getType ( ) ) { throw new \ RuntimeException ( "Both types are defined and different, merge is not possible" ) ; } if ( $ right -> getType ( ) === null && $ left -> getType ( ) !== null ) { $ merged -> setType ( $ left -> getType ( ) ) ; } $ merged -> setProperties ( $ this -> arrayMerge ( $ left -> getProperties ( ) , $ right -> getProperties ( ) ) ) ; $ merged -> setRequired ( $ this -> arrayUnique ( $ this -> arrayMerge ( $ left -> getRequired ( ) , $ right -> getRequired ( ) ) ) ) ; return $ merged ; }
Create a new JsonSchema based on two merged schema

@param JsonSchema $left
@param JsonSchema $right

@TODO Handle more fields

@return JsonSchema
Create a new JsonSchema based on two merged schema