Example #1
0
    private function decorateVar($var)
    {
        if (is_array($var)) {
            if (isset($var[0], $var[1]) && is_callable($var)) {
                return ClassStub::wrapCallable($var);
            }
            foreach ($var as $k => $v) {
                if ($v !== $d = $this->decorateVar($v)) {
                    $var[$k] = $d;
                }
            }

            return $var;
        }
        if (is_string($var)) {
            if (isset(self::$stubsCache[$var])) {
                return self::$stubsCache[$var];
            }
            if (false !== strpos($var, '\\')) {
                $c = (false !== $i = strpos($var, '::')) ? substr($var, 0, $i) : $var;
                if (class_exists($c, false) || interface_exists($c, false) || trait_exists($c, false)) {
                    return self::$stubsCache[$var] = new ClassStub($var);
                }
            }
            if (false !== strpos($var, DIRECTORY_SEPARATOR) && false === strpos($var, '://') && false === strpos($var, "\0") && @is_file($var)) {
                return self::$stubsCache[$var] = new LinkStub($var);
            }
        }

        return $var;
    }
Example #2
0
 public static function castRedisArray(\RedisArray $c, array $a, Stub $stub, $isNested)
 {
     $prefix = Caster::PREFIX_VIRTUAL;
     return $a + array($prefix . 'hosts' => $c->_hosts(), $prefix . 'function' => ClassStub::wrapCallable($c->_function()));
 }