创建实体单例
@param $classPath
@return mixed
420634
public static function singleton($classPath) {
        if ( !isset(self::$INSTANES[$classPath]) ) {
            $reflect = new \ReflectionClass($classPath);
            self::$INSTANES[$classPath] = $reflect->newInstance();
        }
        return self::$INSTANES[$classPath];
    }
1202159
public function get(string $path, string $className) {
		$this->add(new Route($path, Route::GET, $className));
	}
418514
private void scanJavaClassPaths() {
		final String[] javaClassPaths = ClassUtil.getJavaClassPaths();
		for (String classPath : javaClassPaths) {
			// bug修复，由于路径中空格和中文导致的Jar找不到
			classPath = URLUtil.decode(classPath, CharsetUtil.systemCharsetName());

			scanFile(new File(classPath), null);
		}
	}
271333
public function loadClass($className)
    {
        foreach ($this->namespaces as $namespace => $path) {
            if (null === $namespace || $namespace === substr($className, 0, strlen($namespace))) {
                $fileName = '';
                $namespace = '';

                if (false !== ($lastNsPos = strripos($className, $this->namespaceSeparator))) {
                    $namespace = substr($className, 0, $lastNsPos);
                    $className = substr($className, $lastNsPos + 1);
                    $fileName = str_replace(
                        $this->namespaceSeparator,
                        DIRECTORY_SEPARATOR,
                        $namespace
                    ) . DIRECTORY_SEPARATOR;
                }

                $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . $this->fileExtension;

                $this->requireFile(($path !== null ? $path . DIRECTORY_SEPARATOR : '') . $fileName);

                break;
            }
        }

        return $this;
    }
1169187
public function findPath($classname, $basepath = null)
    {
        $path = false;

        /*
         * Exception rule for Exception classes
        *
        * Transform class to lower case to always load the exception class from the /exception/ folder.
        */
        if ($pos = strpos($classname, 'Exception')) {
            $filename = substr($classname, $pos + strlen('Exception'));
            $classname = str_replace($filename, ucfirst(strtolower($filename)), $classname);
        }

        $word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', ' \\1', $classname));

        $parts = explode(' ', $word);

        array_shift($parts);

        $path = strtolower(implode('/', $parts));

        if (count($parts) == 1) {
            $path = $path.'/'.$path;
        }

        if (!is_file($this->_basepath.'/'.$path.'.php')) {
            $path = $path.'/'.strtolower(array_pop($parts));
        }

        $path = $this->_basepath.'/'.$path.'.php';

        return $path;
    }
911489
public static function __import($path, $classpath = null)
    {
        if ($classpath) {
            // Apparently casting to (string) no longer invokes __toString() automatically.
            if (is_object($classpath)) {
                $classpath = $classpath->__toString();
            }

            // classpaths are currently additive, but we also don't want to just
            // indiscriminantly prepand/append stuff to the include_path.  This means
            // we need to parse current incldue_path, and prepend any
            // specified classpath locations that are not already in the include_path.
            //
            // NOTE:  the reason why we do it this way instead of just changing include_path
            // and then changing it back, is that in many cases applications (e.g. Propel) will
            // include/require class files from within method calls.  This means that not all
            // necessary files will be included in this import() call, and hence we can't
            // change the include_path back without breaking those apps.  While this method could
            // be more expensive than switching & switching back (not sure, but maybe), it makes it
            // possible to write far less expensive run-time applications (e.g. using Propel), which is
            // really where speed matters more.

            $curr_parts = Phing::explodeIncludePath();
            $add_parts = Phing::explodeIncludePath($classpath);
            $new_parts = array_diff($add_parts, $curr_parts);
            if ($new_parts) {
                set_include_path(implode(PATH_SEPARATOR, array_merge($new_parts, $curr_parts)));
            }
        }

        $ret = include_once $path;

        if ($ret === false) {
            $msg = "Error importing $path";
            if (self::getMsgOutputLevel() >= Project::MSG_DEBUG) {
                $x = new Exception("for-path-trace-only");
                $msg .= $x->getTraceAsString();
            }
            throw new ConfigurationException($msg);
        }
    }
325749
public function resolve($path){
        // 如果不指定完整的url, 则认为是访问$urlBase内资源
        if ($this -> isUrlFormat($path)) {
            $url = $path;
        }
        // 忽略重复的路径分隔符
        else if (strpos($path, '/') === 0) {
            $url = $this -> urlBase . substr($path, 1);
        } else {
            $url = $this -> urlBase . $path;
        }
        
        return $url;
    }
163745
public function pathToClass($relativePath)
    {
        if (strpos($relativePath, '/') !== false) {
            $relativePath = dirname($relativePath).'/'.basename($relativePath, '.php');
        } else {
            $relativePath = basename($relativePath, '.php');
        }

        return str_replace('/', '\\', $relativePath);
    }
116118
private function getClassNameFromFile($filepath)
    {
        $contents = file_get_contents($filepath);
        $namespace = $class = '';
        $getting_namespace = $getting_class = false;
        foreach (token_get_all($contents) as $token) {
            if (is_array($token) && $token[0] == T_NAMESPACE) {
                $getting_namespace = true;
            }

            if (is_array($token) && in_array($token[0], [T_CLASS, T_TRAIT, T_INTERFACE])) {
                $getting_class = true;
            }

            if ($getting_namespace === true) {
                if (is_array($token) && in_array($token[0], [T_STRING, T_NS_SEPARATOR])) {
                    $namespace .= $token[1];
                } elseif ($token === ';') {
                    $getting_namespace = false;
                }
            }

            if ($getting_class === true) {
                if (is_array($token) && $token[0] == T_STRING) {
                    $class = $token[1];
                    break;
                }
            }
        }

        return $namespace ? $namespace.'\\'.$class : $class;
    }
1347264
protected function getReflection($filepath)
    {
        // Regexp instead of tokenizer because of the bad perf @link > https://gist.github.com/1886076
        if (!preg_match('#^namespace\s+(.+?);.*class\s+(\w+).+;$#sm', file_get_contents($filepath), $captured)) {
            throw new \RuntimeException('Unable to find namespace or class declaration');
        }

        $fqcn = $captured[1].'\\'.$captured[2];

        try {
            $reflectedClass = new \ReflectionClass($fqcn);
        } catch (\ReflectionException $exception) {
            $this->registerAutoload($fqcn, $filepath);
            $reflectedClass = new \ReflectionClass($fqcn);
        }

        return $reflectedClass;
    }
255388
private static function findClasses($path)
    {
        $extraTypes = self::determineExtraTypes();

        // @codingStandardsIgnoreStart
        $contents = @php_strip_whitespace($path);
        // @codingStandardsIgnoreEnd
        if (!$contents) {
            if (!file_exists($path)) {
                $message = 'File at "%s" does not exist, check your classmap definitions';
            } elseif (!is_readable($path)) {
                $message = 'File at "%s" is not readable, check its permissions';
            } elseif ('' === trim(file_get_contents($path))) {
                // The input file was really empty and thus contains no classes
                return array();
            } else {
                $message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
            }
            $error = error_get_last();
            if (isset($error['message'])) {
                $message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
            }
            throw new \RuntimeException(sprintf($message, $path));
        }

        // return early if there is no chance of matching anything in this file
        if (!preg_match('{\b(?:class|interface'.$extraTypes.')\s}i', $contents)) {
            return array();
        }

        $matches = self::extractClasses($contents, $extraTypes);
        $classes = self::buildClassList($matches);

        return $classes;
    }
168841
public function namespaceToPath($namespace, Dir $classPath = NULL) {
    $cp = $classPath ?: $this->getClassPath()->up();
    
    // end und anfangs backslashs weg
    $namespace = trim($namespace,'\\'); 
    
    $dir = $cp->sub(str_replace('\\','/',$namespace).'/');
    
    return $dir;
  }
574078
public static function ClassPathToRealFilePath ($class_path, $class_file_ext = self::CLASS_FILE_EXT) {
		return static::$_VendorRootDir . str_replace(static::NAMESPACE_SEPARATOR, '/', $class_path) . $class_file_ext;
	}
330969
protected function _getClassNameFromFilePath($sFilePath)
    {
        $sFileName = basename($sFilePath);
        $aMatches = array();

        if (!preg_match(AbstractQuery::REGEXP_FILE, $sFileName, $aMatches)) {
            throw new MigrationException('Could not extract class name from file name');
        }

        return $aMatches[2] . 'migration';
    }
279281
public function getFormAttributes( $classPath = null ) {

		if( !isset( $classPath ) ) {

			$classPath	= 'cmsgears\core\common\models\forms\GenericForm';
		}

		$refclass	= new \ReflectionClass( $classPath );
		$attribArr	= array();

		foreach ( $refclass->getProperties() as $property ) {

			$name = $property->name;

			if ( $property->class == $refclass->name ) {

				$attribArr[ $name ] = $this->$name;
			}
		}

		return $attribArr;
	}
1093180
public function saveDataToCache($cachePath)
    {
        $url = Config::get('url.schedule_all_school');

        // 请求参数
        $param['__EVENTTARGET'] = "";
        $param['__EVENTARGUMENT'] = "";
        $param['__VIEWSTATE'] = true;
        $param['ddlXY'] = '';
        $param['ddlJS'] = '';
        $param['kcmc'] = '';
        $param['ddlXN'] = '2016-2017';
        $param['ddlXQ'] = '2';
        $param['DropDownList1'] = 'kcmc';
        $param['TextBox1'] = '';
        $param['Button1'] = iconv('utf-8', 'gb2312', " 查 询 ");
        $pageCount = 0;
        while (true) {
            $response = $this->request('post', [$url, $param]);
            $body = $this->checkAndThrow($response);

            // 写入数据到缓存
            if ($body) {
                $crawler = new Crawler($body);
                // 翻页菜单
                $spanNode = $crawler->filterXPath('//table[@id="DBGrid"]//td[@colspan="19"]//span');
                // 写入数据到缓存
                $pageCount = $spanNode->text();
                file_put_contents($cachePath . $pageCount . '.html', $body);
                // 下一页
                $nextNode = $spanNode->nextAll();
                if ($nextNode->count() == 0) {
                    break;
                }
                if (!preg_match('/\'(.*?)\'/', $nextNode->attr('href'), $matches)) {
                    break;
                }
                // 参数重新赋值
                $param['__EVENTTARGET'] = str_replace('$', ":", $matches[1]);
                $param['__VIEWSTATE'] = $crawler->filterXPath('//input[@name="__VIEWSTATE"]')->attr('value');
                unset($param['Button1']);
            }
        }

        return $pageCount;
    }
892156
private function getClassTypeStandarized( $path )
	{
		$class = '';

		$ctrl_parts = explode( '/', $path );

		while ( $class_name = array_shift( $ctrl_parts ) )
		{
			$class .= ucfirst( $class_name );
		}

		return $class;
	}