src/Schema.php
protected function parseInternal(array $arr): array {
        if (empty($arr)) {
            // An empty schema validates to anything.
            return [];
        } elseif (isset($arr['type'])) {
            // This is a long form schema and can be parsed as the root.
            return $this->parseNode($arr);
        } else {
            // Check for a root schema.
            $value = reset($arr);
            $key = key($arr);
            if (is_int($key)) {
                $key = $value;
                $value = null;
            }
            list ($name, $param) = $this->parseShortParam($key, $value);
            if (empty($name)) {
                return $this->parseNode($param, $value);
            }
        }

        // If we are here then this is n object schema.
        list($properties, $required) = $this->parseProperties($arr);

        $result = [
            'type' => 'object',
            'properties' => $properties,
            'required' => $required
        ];

        return array_filter($result);
    }
protected function parseInternal(array $arr): array {
        if (empty($arr)) {
            // An empty schema validates to anything.
            return [];
        } elseif (isset($arr['type'])) {
            // This is a long form schema and can be parsed as the root.
            return $this->parseNode($arr);
        } else {
            // Check for a root schema.
            $value = reset($arr);
            $key = key($arr);
            if (is_int($key)) {
                $key = $value;
                $value = null;
            }
            list ($name, $param) = $this->parseShortParam($key, $value);
            if (empty($name)) {
                return $this->parseNode($param, $value);
            }
        }

        // If we are here then this is n object schema.
        list($properties, $required) = $this->parseProperties($arr);

        $result = [
            'type' => 'object',
            'properties' => $properties,
            'required' => $required
        ];

        return array_filter($result);
    }
protected function parseInternal ( array $ arr ) : array { if ( empty ( $ arr ) ) { // An empty schema validates to anything. return [ ] ; } elseif ( isset ( $ arr [ 'type' ] ) ) { // This is a long form schema and can be parsed as the root. return $ this -> parseNode ( $ arr ) ; } else { // Check for a root schema. $ value = reset ( $ arr ) ; $ key = key ( $ arr ) ; if ( is_int ( $ key ) ) { $ key = $ value ; $ value = null ; } list ( $ name , $ param ) = $ this -> parseShortParam ( $ key , $ value ) ; if ( empty ( $ name ) ) { return $ this -> parseNode ( $ param , $ value ) ; } } // If we are here then this is n object schema. list ( $ properties , $ required ) = $ this -> parseProperties ( $ arr ) ; $ result = [ 'type' => 'object' , 'properties' => $ properties , 'required' => $ required ] ; return array_filter ( $ result ) ; }
Parse a schema in short form into a full schema array.

@param array $arr The array to parse into a schema.
@return array The full schema array.
@throws ParseException Throws an exception when an item in the schema is invalid.
Parse a schema in short form into a full schema array .