src/Schema.php
private function lookupSchema($schema, string $schemaPath) {
        if ($schema instanceof Schema) {
            return [$schema, $schemaPath];
        } else {
            $lookup = $this->getRefLookup();
            $visited = [];

            // Resolve any references first.
            while (!empty($schema['$ref'])) {
                $schemaPath = $schema['$ref'];

                if (isset($visited[$schemaPath])) {
                    throw new RefNotFoundException("Cyclical reference cannot be resolved. ($schemaPath)", 508);
                }
                $visited[$schemaPath] = true;

                try {
                    $schema = call_user_func($lookup, $schemaPath);
                } catch (\Exception $ex) {
                    throw new RefNotFoundException($ex->getMessage(), $ex->getCode(), $ex);
                }
                if ($schema === null) {
                    throw new RefNotFoundException("Schema reference could not be found. ($schemaPath)");
                }
            }

            return [$schema, $schemaPath];
        }
    }
private function lookupSchema($schema, string $schemaPath) {
        if ($schema instanceof Schema) {
            return [$schema, $schemaPath];
        } else {
            $lookup = $this->getRefLookup();
            $visited = [];

            // Resolve any references first.
            while (!empty($schema['$ref'])) {
                $schemaPath = $schema['$ref'];

                if (isset($visited[$schemaPath])) {
                    throw new RefNotFoundException("Cyclical reference cannot be resolved. ($schemaPath)", 508);
                }
                $visited[$schemaPath] = true;

                try {
                    $schema = call_user_func($lookup, $schemaPath);
                } catch (\Exception $ex) {
                    throw new RefNotFoundException($ex->getMessage(), $ex->getCode(), $ex);
                }
                if ($schema === null) {
                    throw new RefNotFoundException("Schema reference could not be found. ($schemaPath)");
                }
            }

            return [$schema, $schemaPath];
        }
    }
private function lookupSchema ( $ schema , string $ schemaPath ) { if ( $ schema instanceof Schema ) { return [ $ schema , $ schemaPath ] ; } else { $ lookup = $ this -> getRefLookup ( ) ; $ visited = [ ] ; // Resolve any references first. while ( ! empty ( $ schema [ '$ref' ] ) ) { $ schemaPath = $ schema [ '$ref' ] ; if ( isset ( $ visited [ $ schemaPath ] ) ) { throw new RefNotFoundException ( "Cyclical reference cannot be resolved. ($schemaPath)" , 508 ) ; } $ visited [ $ schemaPath ] = true ; try { $ schema = call_user_func ( $ lookup , $ schemaPath ) ; } catch ( \ Exception $ ex ) { throw new RefNotFoundException ( $ ex -> getMessage ( ) , $ ex -> getCode ( ) , $ ex ) ; } if ( $ schema === null ) { throw new RefNotFoundException ( "Schema reference could not be found. ($schemaPath)" ) ; } } return [ $ schema , $ schemaPath ] ; } }
Lookup a schema based on a schema node.

The node could be a schema array, `Schema` object, or a schema reference.

@param mixed $schema The schema node to lookup with.
@param string $schemaPath The current path of the schema.
@return array Returns an array with two elements:
- Schema|array|\ArrayAccess The schema that was found.
- string The path of the schema. This is either the reference or the `$path` parameter for inline schemas.
@throws RefNotFoundException Throws an exception when a reference could not be found.
Lookup a schema based on a schema node .