Look up an annotation with a $ref url.

@param  string $ref The $ref value, for example: "#/components/schemas/Product"
@throws Exception
344813
public function ref($ref)
    {
        if (substr($ref, 0, 2) !== '#/') {
            // @todo Add support for external (http) refs?
            throw new Exception('Unsupported $ref "' . $ref . '", it should start with "#/"');
        }
        return $this->resolveRef($ref, '#/', $this, []);
    }
1310435
protected function getByRef($key, &$value)
    {
        if (!$this->checkRefs ||!is_string($value)) {
            return;
        }

        $this->checkRefs = false;
        $references = [$key];
        $key = $value;
        while ($this->isRef($key)) {
            if (in_array($key, $references)) {
                $this->checkRefs = true;
                $this->key = null;
                $references[] = $key;
                throw new RuntimeException(sprintf(
                    "Cyclic reference detected: %s",
                    implode(" ~~> ", $references)
                ));
            }
            $references[] = $key;
            $previous = $key;
            $key = $this->get($key, null, false);
        };
        $this->checkRefs = true;
        if (isset($previous)) {
            if ($this->exists($previous)) {
                $value = $key;
            } else {
                $this->key = null;
                $references[sizeof($references) - 1] .= " (missing key)";
                throw new RuntimeException(sprintf(
                    "Invalid reference detected: %s",
                    implode(" ~~> ", $references)
                ));
            }
        }
    }
925053
public int addRef(Object ref)
    {
        if (_refs == null)
            _refs = new ArrayList();

        _refs.add(ref);

        return _refs.size() - 1;
    }
430028
public function urlForReference(string $user, string $repo, string $ref): string
    {
        $key = sprintf(self::CACHE_KEY_TEMPLATE, md5($user . $repo), 'ref_url_' . md5($ref));

        if (($latest = $this->getFromCache($key)) !== null) {
            return $latest;
        }

        [$type, $resolved] = $this->resolveRefType($ref);
        $repoURL = $this->urlForRepository($user, $repo);

        switch ($type) {
            case 'commit':
                $url = "${repoURL}/commit/${resolved}";
                break;

            case 'tag':
                $url = "${repoURL}/releases/tag/${resolved}";
                break;

            case 'pull':
                $url = "${repoURL}/pull/${resolved}";
                break;

            case 'branch':
            default:
                $url = "${repoURL}/tree/${resolved}";
        }

        $this->setToCache($key, $url, 30);
        return $url;
    }
392299
public function preloadNode($ref, string $namespace = NcrPreloader::DEFAULT_NAMESPACE): void
    {
        $nodeRef = $this->toNodeRef($ref);
        if (!$nodeRef instanceof NodeRef) {
            return;
        }

        $this->ncrPreloader->addNodeRef($nodeRef, $namespace);
    }
998791
public function getDBRef(array $ref)
    {
        $db = (isset($ref['$db']) && $ref['$db'] !== $this->name) ? $this->connection->selectDB($ref['$db']) : $this;
        return MongoDBRef::get($db, $ref);
    }
143078
private function _checkRef(&$reference, &$refCode)
    {
        if (!is_string($reference)) {
            $reference = strval($reference);
            if (!is_string($reference)) {
                throw new Klarna_InvalidTypeException("Reference", "string");
            }
        }

        if (!is_string($refCode)) {
            $refCode = strval($refCode);
            if (!is_string($refCode)) {
                throw new Klarna_InvalidTypeException("Reference code", "string");
            }
        }
    }
728900
public function addReferenceCache($reference)
    {
        if ( !$cache = $this->getMongator()->getFieldsCache() ) {
            return null;
        }

        foreach ($this->getQueryHashes() as $hash) {
            $value = $cache->get($hash);
            if (!$value) $value = array();

            if (!isset($value['references']) || !in_array($reference, $value['references'])) {
                $value['references'][] = $reference;
                $cache->set($hash, $value);
            }
        }
    }
193827
public static String getRelativeRef(String ref) {
        Matcher matcher = match(ref);
        return matcher != null ? String.format("/%s/%s", matcher.group(1), matcher.group(2)) : null;
    }
215738
public function setMustPass($ref)
    {
        if (null!==$this->getMask($ref)) {
            $this->must_pass = $ref;
        } else {
            throw new \Exception(sprintf("Unknown standard [%s] in Hostname validation!", $ref));
        }
    }
909584
public function _refBind($field_in, $expression, $field_out = null)
    {
        if ($this->controller) {
            return $this->controller->refBind($this, $field, $expression);
        }

        list($myref, $rest) = explode('/', $ref, 2);

        if (!$this->_references[$myref]) {
            throw $this->exception('No such relation')
            ->addMoreInfo('ref', $myref)
            ->addMoreInfo('rest', $rest);
        }
        // Determine and populate related model

        if (is_array($this->_references[$myref])) {
            $m = $this->_references[$myref][0];
        } else {
            $m = $this->_references[$myref];
        }
        $m = $this->add($m);
        if ($rest) {
            $m = $m->_ref($rest);
        }
        $this->_refGlue();

        if (!isset($this->_references[$ref])) {
            throw $this->exception('Unable to traverse, no reference defined by this name')
            ->addMoreInfo('name', $ref);
        }

        $r = $this->_references[$ref];

        if (is_array($r)) {
            list($m, $our_field, $their_field) = $r;

            if (is_string($m)) {
                $m = $this->add($m);
            } else {
                $m = $m->newInstance();
            }

            return $m->addCondition($their_field, $this[$our_field]);
        }

        if (is_string($m)) {
            $m = $this->add($m);
        } else {
            $m = $m->newInstance();
        }

        return $m->load($this[$our_field]);
    }
1133504
protected function _check($reference)
    {
        $isString = is_string($reference);
        if ($isString) {
            if (!class_exists($reference)) {
                throw new InvalidArgumentException("Can't Spy the unexisting class `{$reference}`.");
            }
            $reflection = Inspector::inspect($reference);
        } else {
            $reflection = Inspector::inspect(get_class($reference));
        }

        if (!$reflection->isInternal()) {
            return;
        }
        if (!$isString) {
            throw new InvalidArgumentException("Can't Spy built-in PHP instances, create a test double using `Double::instance()`.");
        }
    }
1077602
private function loadExternalRef($reference)
    {
        list($prefix, $path) = parse_external_ref($reference);
        return $this->loaderManager->getLoader($prefix)->load($path);
    }
220343
public function show($username, $repository, $reference)
    {
        $reference = $this->encodeReference($reference);

        return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/git/refs/'.$reference);
    }
1098912
private function parseRefAsCommit($reference): ?string
    {
        if (preg_match(self::REGEX_COMMIT, $reference, $matches) !== 1) {
            return null;
        }

        return $matches[0];
    }
1047023
function getReference($table, $ref = null) {
		if (isset($this->references[$table])) {
			if (!strlen($ref)) {
				return current($this->references[$table]);
			}
			if (isset($this->references[$table][$ref])) {
				return $this->references[$table][$ref];
			}
		}
	}
1109731
public function findByReference($reference)
    {
        $qb = $this
            ->createQueryBuilder('e')
            ->where('e.reference = :reference')
            ->setParameter('reference', $reference);

        return $qb
            ->getQuery()
            ->getArrayResult();
    }