src/Registry/Common.php
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)
                ));
            }
        }
    }
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)
                ));
            }
        }
    }
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 ) ) ) ; } } }
Gets value by reference if possible.

@param  string $key
@param  mixed  $value
@return void
@throws \ReflectionException  Risen from self::get().
@throws RuntimeException  If cyclic or invalid reference detected.
Gets value by reference if possible .