src/Schema.php
private function parseNode($node, $value = null) {
        if (is_array($value)) {
            if (is_array($node['type'])) {
                trigger_error('Schemas with multiple types are deprecated.', E_USER_DEPRECATED);
            }

            // The value describes a bit more about the schema.
            switch ($node['type']) {
                case 'array':
                    if (isset($value['items'])) {
                        // The value includes array schema information.
                        $node = array_replace($node, $value);
                    } else {
                        $node['items'] = $this->parseInternal($value);
                    }
                    break;
                case 'object':
                    // The value is a schema of the object.
                    if (isset($value['properties'])) {
                        list($node['properties']) = $this->parseProperties($value['properties']);
                    } else {
                        list($node['properties'], $required) = $this->parseProperties($value);
                        if (!empty($required)) {
                            $node['required'] = $required;
                        }
                    }
                    break;
                default:
                    $node = array_replace($node, $value);
                    break;
            }
        } elseif (is_string($value)) {
            if ($node['type'] === 'array' && $arrType = $this->getType($value)) {
                $node['items'] = ['type' => $arrType];
            } elseif (!empty($value)) {
                $node['description'] = $value;
            }
        } elseif ($value === null) {
            // Parse child elements.
            if ($node['type'] === 'array' && isset($node['items'])) {
                // The value includes array schema information.
                $node['items'] = $this->parseInternal($node['items']);
            } elseif ($node['type'] === 'object' && isset($node['properties'])) {
                list($node['properties']) = $this->parseProperties($node['properties']);
            }
        }

        if (is_array($node)) {
            if (!empty($node['allowNull'])) {
                $node['nullable'] = true;
            }
            unset($node['allowNull']);

            if ($node['type'] === null || $node['type'] === []) {
                unset($node['type']);
            }
        }

        return $node;
    }
private function parseNode($node, $value = null) {
        if (is_array($value)) {
            if (is_array($node['type'])) {
                trigger_error('Schemas with multiple types are deprecated.', E_USER_DEPRECATED);
            }

            // The value describes a bit more about the schema.
            switch ($node['type']) {
                case 'array':
                    if (isset($value['items'])) {
                        // The value includes array schema information.
                        $node = array_replace($node, $value);
                    } else {
                        $node['items'] = $this->parseInternal($value);
                    }
                    break;
                case 'object':
                    // The value is a schema of the object.
                    if (isset($value['properties'])) {
                        list($node['properties']) = $this->parseProperties($value['properties']);
                    } else {
                        list($node['properties'], $required) = $this->parseProperties($value);
                        if (!empty($required)) {
                            $node['required'] = $required;
                        }
                    }
                    break;
                default:
                    $node = array_replace($node, $value);
                    break;
            }
        } elseif (is_string($value)) {
            if ($node['type'] === 'array' && $arrType = $this->getType($value)) {
                $node['items'] = ['type' => $arrType];
            } elseif (!empty($value)) {
                $node['description'] = $value;
            }
        } elseif ($value === null) {
            // Parse child elements.
            if ($node['type'] === 'array' && isset($node['items'])) {
                // The value includes array schema information.
                $node['items'] = $this->parseInternal($node['items']);
            } elseif ($node['type'] === 'object' && isset($node['properties'])) {
                list($node['properties']) = $this->parseProperties($node['properties']);
            }
        }

        if (is_array($node)) {
            if (!empty($node['allowNull'])) {
                $node['nullable'] = true;
            }
            unset($node['allowNull']);

            if ($node['type'] === null || $node['type'] === []) {
                unset($node['type']);
            }
        }

        return $node;
    }
private function parseNode ( $ node , $ value = null ) { if ( is_array ( $ value ) ) { if ( is_array ( $ node [ 'type' ] ) ) { trigger_error ( 'Schemas with multiple types are deprecated.' , E_USER_DEPRECATED ) ; } // The value describes a bit more about the schema. switch ( $ node [ 'type' ] ) { case 'array' : if ( isset ( $ value [ 'items' ] ) ) { // The value includes array schema information. $ node = array_replace ( $ node , $ value ) ; } else { $ node [ 'items' ] = $ this -> parseInternal ( $ value ) ; } break ; case 'object' : // The value is a schema of the object. if ( isset ( $ value [ 'properties' ] ) ) { list ( $ node [ 'properties' ] ) = $ this -> parseProperties ( $ value [ 'properties' ] ) ; } else { list ( $ node [ 'properties' ] , $ required ) = $ this -> parseProperties ( $ value ) ; if ( ! empty ( $ required ) ) { $ node [ 'required' ] = $ required ; } } break ; default : $ node = array_replace ( $ node , $ value ) ; break ; } } elseif ( is_string ( $ value ) ) { if ( $ node [ 'type' ] === 'array' && $ arrType = $ this -> getType ( $ value ) ) { $ node [ 'items' ] = [ 'type' => $ arrType ] ; } elseif ( ! empty ( $ value ) ) { $ node [ 'description' ] = $ value ; } } elseif ( $ value === null ) { // Parse child elements. if ( $ node [ 'type' ] === 'array' && isset ( $ node [ 'items' ] ) ) { // The value includes array schema information. $ node [ 'items' ] = $ this -> parseInternal ( $ node [ 'items' ] ) ; } elseif ( $ node [ 'type' ] === 'object' && isset ( $ node [ 'properties' ] ) ) { list ( $ node [ 'properties' ] ) = $ this -> parseProperties ( $ node [ 'properties' ] ) ; } } if ( is_array ( $ node ) ) { if ( ! empty ( $ node [ 'allowNull' ] ) ) { $ node [ 'nullable' ] = true ; } unset ( $ node [ 'allowNull' ] ) ; if ( $ node [ 'type' ] === null || $ node [ 'type' ] === [ ] ) { unset ( $ node [ 'type' ] ) ; } } return $ node ; }
Parse a schema node.

@param array|Schema $node The node to parse.
@param mixed $value Additional information from the node.
@return array|\ArrayAccess Returns a JSON schema compatible node.
@throws ParseException Throws an exception if there was a problem parsing the schema node.
Parse a schema node .