当前位置: 首页>>代码示例>>PHP>>正文


PHP xp::cli方法代码示例

本文整理汇总了PHP中xp::cli方法的典型用法代码示例。如果您正苦于以下问题:PHP xp::cli方法的具体用法?PHP xp::cli怎么用?PHP xp::cli使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xp的用法示例。


在下文中一共展示了xp::cli方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadClass0

 /**
  * Load the class by the specified name
  *
  * @param   string class fully qualified class name io.File
  * @return  string class name
  * @throws  lang.ClassNotFoundException in case the class can not be found
  * @throws  lang.ClassFormatException in case the class format is invalud
  */
 public function loadClass0($class)
 {
     $name = strtr($class, '.', '\\');
     if (isset(\xp::$cl[$class])) {
         return $name;
     }
     // Load class
     \xp::$cl[$class] = nameof($this) . '://' . $this->path;
     \xp::$cll++;
     try {
         $r = (include $this->classUri($class));
     } catch (ClassLoadingException $e) {
         unset(\xp::$cl[$class]);
         \xp::$cll--;
         // If class was declared, but loading threw an exception it means
         // a "soft" dependency, one that is only required at runtime, was
         // not loaded, the class itself has been declared.
         if (class_exists($name, false) || interface_exists($name, false) || trait_exists($name, false)) {
             throw new ClassDependencyException($class, [$this], $e);
         }
         // If otherwise, a "hard" dependency could not be loaded, eg. the
         // base class or a required interface and thus the class could not
         // be declared.
         throw new ClassLinkageException($class, [$this], $e);
     }
     \xp::$cll--;
     if (false === $r) {
         unset(\xp::$cl[$class]);
         $e = new ClassNotFoundException($class, [$this]);
         \xp::gc(__FILE__);
         throw $e;
     } else {
         if (!class_exists($name, false) && !interface_exists($name, false) && !trait_exists($name, false)) {
             $details = XPClass::detailsForClass($class);
             $uri = $this->classUri($class);
             unset(\xp::$cl[$class]);
             if (isset($details['class'])) {
                 $reflect = new \ReflectionClass($details['class'][DETAIL_ARGUMENTS]);
                 \xp::$errors[$uri][$reflect->getStartLine()] = ['' => 1];
                 $e = new ClassFormatException('File does not declare type `' . $class . '`, but `' . strtr($reflect->getName(), '\\', '.') . '`');
                 \xp::gc($uri);
                 throw $e;
             } else {
                 throw new ClassFormatException('Loading `' . $class . '`: No types declared in ' . $this->classUri($class));
             }
         }
     }
     method_exists($name, '__static') && (\xp::$cli[] = [$name, '__static']);
     if (0 === \xp::$cll) {
         $invocations = \xp::$cli;
         \xp::$cli = [];
         foreach ($invocations as $inv) {
             $inv($name);
         }
     }
     return $name;
 }
开发者ID:xp-framework,项目名称:core,代码行数:65,代码来源:AbstractClassLoader.class.php

示例2: loadClass0

 /**
  * Load the class by the specified name
  *
  * @param   string class fully qualified class name io.File
  * @return  string class name
  * @throws  lang.ClassNotFoundException in case the class can not be found
  * @throws  lang.ClassFormatException in case the class format is invalud
  */
 public function loadClass0($class)
 {
     $name = strtr($class, '.', '\\');
     if (isset(\xp::$cl[$class])) {
         return $name;
     }
     // Load class
     \xp::$cl[$class] = nameof($this) . '://' . $this->path;
     \xp::$cll++;
     try {
         $r = (include $this->classUri($class));
     } catch (ClassLoadingException $e) {
         unset(\xp::$cl[$class]);
         \xp::$cll--;
         // If class was declared, but loading threw an exception it means
         // a "soft" dependency, one that is only required at runtime, was
         // not loaded, the class itself has been declared.
         if (class_exists($name, false) || interface_exists($name, false) || trait_exists($name, false)) {
             throw new ClassDependencyException($class, [$this], $e);
         }
         // If otherwise, a "hard" dependency could not be loaded, eg. the
         // base class or a required interface and thus the class could not
         // be declared.
         throw new ClassLinkageException($class, [$this], $e);
     }
     \xp::$cll--;
     if (false === $r) {
         unset(\xp::$cl[$class]);
         $e = new ClassNotFoundException($class, [$this]);
         \xp::gc(__FILE__);
         throw $e;
     } else {
         if (!class_exists($name, false) && !interface_exists($name, false) && !trait_exists($name, false)) {
             unset(\xp::$cl[$class]);
             throw new ClassFormatException('Class "' . $class . '" not declared in loaded file');
         }
     }
     method_exists($name, '__static') && (\xp::$cli[] = [$name, '__static']);
     if (0 === \xp::$cll) {
         $invocations = \xp::$cli;
         \xp::$cli = [];
         foreach ($invocations as $inv) {
             $inv($name);
         }
     }
     return $name;
 }
开发者ID:johannes85,项目名称:core,代码行数:55,代码来源:AbstractClassLoader.class.php

示例3: loadClass0

 /**
  * Load the class by the specified name
  *
  * @param   string class fully qualified class name io.File
  * @return  string class name
  * @throws  lang.ClassNotFoundException in case the class can not be found
  * @throws  lang.ClassFormatException in case the class format is invalud
  */
 public function loadClass0($class)
 {
     if (isset(xp::$cl[$class])) {
         return xp::reflect($class);
     }
     // Load class
     $package = NULL;
     xp::$cl[$class] = $this->getClassName() . '://' . $this->path;
     xp::$cll++;
     try {
         $r = (include $this->classUri($class));
     } catch (ClassLoadingException $e) {
         xp::$cll--;
         $decl = NULL;
         if (NULL === $package) {
             $decl = substr($class, FALSE === ($p = strrpos($class, '.')) ? 0 : $p + 1);
         } else {
             $decl = strtr($class, '.', '·');
         }
         // If class was declared, but loading threw an exception it means
         // a "soft" dependency, one that is only required at runtime, was
         // not loaded, the class itself has been declared.
         if (class_exists($decl, FALSE) || interface_exists($decl, FALSE)) {
             raise('lang.ClassDependencyException', $class, array($this), $e);
         }
         // If otherwise, a "hard" dependency could not be loaded, eg. the
         // base class or a required interface and thus the class could not
         // be declared.
         raise('lang.ClassLinkageException', $class, array($this), $e);
     }
     xp::$cll--;
     if (FALSE === $r) {
         unset(xp::$cl[$class]);
         throw new ClassNotFoundException($class, array($this));
     }
     // Register it
     if (NULL === $package) {
         if (FALSE === ($p = strrpos($class, '.'))) {
             $name = $class;
         } else {
             $name = substr($class, $p + 1);
             if (!class_exists($name, FALSE) && !interface_exists($name, FALSE)) {
                 $name = strtr($class, '.', '\\');
                 if (!class_exists($name, FALSE) && !interface_exists($name, FALSE)) {
                     unset(xp::$cl[$class]);
                     raise('lang.ClassFormatException', 'Class "' . $name . '" not declared in loaded file');
                 }
             } else {
                 class_alias($name, strtr($class, '.', '\\'));
             }
         }
     } else {
         $name = strtr($class, '.', '·');
         class_alias($name, strtr($class, '.', '\\'));
     }
     xp::$cn[$name] = $class;
     method_exists($name, '__static') && (xp::$cli[] = array($name, '__static'));
     if (0 === xp::$cll) {
         $invocations = xp::$cli;
         xp::$cli = array();
         foreach ($invocations as $inv) {
             call_user_func($inv);
         }
     }
     return $name;
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:74,代码来源:AbstractClassLoader.class.php

示例4: strtr

 function loadClass0($class)
 {
     $name = strtr($class, '.', '\\');
     if (isset(xp::$cl[$class])) {
         return $name;
     }
     foreach (xp::$classpath as $path) {
         // We rely on paths having been expanded including a trailing directory separator
         // character inside bootstrap(). This way, we can save testing for whether the path
         // entry is a directory with file system stat() calls.
         if (DIRECTORY_SEPARATOR === $path[strlen($path) - 1]) {
             $f = $path . strtr($class, '.', DIRECTORY_SEPARATOR) . xp::CLASS_FILE_EXT;
             $cl = 'lang.FileSystemClassLoader';
         } else {
             $f = 'xar://' . $path . '?' . strtr($class, '.', '/') . xp::CLASS_FILE_EXT;
             $cl = 'lang.archive.ArchiveClassLoader';
         }
         if (!file_exists($f)) {
             continue;
         }
         // Load class
         xp::$cl[$class] = $cl . '://' . $path;
         xp::$cll++;
         $r = (include $f);
         xp::$cll--;
         if (false === $r) {
             unset(xp::$cl[$class]);
             continue;
         }
         // Register class name and call static initializer if available
         method_exists($name, '__static') && (xp::$cli[] = [$name, '__static']);
         if (0 === xp::$cll) {
             $invocations = xp::$cli;
             xp::$cli = [];
             foreach ($invocations as $inv) {
                 $inv($name);
             }
         }
         return $name;
     }
     xp::error('Cannot bootstrap class ' . $class . ' (include_path= ' . get_include_path() . ')');
 }
开发者ID:johannes85,项目名称:core,代码行数:42,代码来源:lang.base.php

示例5: substr

 function loadClass0($class)
 {
     if (isset(xp::$cl[$class])) {
         return substr(array_search($class, xp::$cn, TRUE), 6);
     }
     foreach (xp::$classpath as $path) {
         // If path is a directory and the included file exists, load it
         if (is_dir($path) && file_exists($f = $path . DIRECTORY_SEPARATOR . strtr($class, '.', DIRECTORY_SEPARATOR) . xp::CLASS_FILE_EXT)) {
             $cl = 'FileSystemClassLoader';
         } else {
             if (is_file($path) && file_exists($f = 'xar://' . $path . '?' . strtr($class, '.', '/') . xp::CLASS_FILE_EXT)) {
                 $cl = 'ArchiveClassLoader';
             } else {
                 continue;
             }
         }
         // Load class
         $package = NULL;
         xp::$cl[$class] = $cl . '://' . $path;
         xp::$cll++;
         $r = (include $f);
         xp::$cll--;
         if (FALSE === $r) {
             unset(xp::$cl[$class]);
             continue;
         }
         // Register class name and call static initializer if available
         if (NULL === $package) {
             if (FALSE === ($p = strrpos($class, '.'))) {
                 $name = $class;
             } else {
                 $name = substr($class, $p + 1);
                 if (!class_exists($name, FALSE) && !interface_exists($name, FALSE)) {
                     $name = strtr($class, '.', '\\');
                 } else {
                     class_alias($name, strtr($class, '.', '\\'));
                 }
             }
         } else {
             $name = strtr($class, '.', 'и');
             class_alias($name, strtr($class, '.', '\\'));
         }
         xp::$cn[$name] = $class;
         method_exists($name, '__static') && (xp::$cli[] = array($name, '__static'));
         if (0 === xp::$cll) {
             $invocations = xp::$cli;
             xp::$cli = array();
             foreach ($invocations as $inv) {
                 call_user_func($inv);
             }
         }
         return $name;
     }
     xp::error('Cannot bootstrap class ' . $class . ' (include_path= ' . get_include_path() . ')');
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:55,代码来源:lang.base.php

示例6: loadClass0

 /**
  * Load the class by the specified name
  *
  * @param   string class fully qualified class name io.File
  * @return  string class name
  * @throws  lang.ClassNotFoundException in case the class can not be found
  * @throws  lang.ClassFormatException in case the class format is invalud
  */
 public function loadClass0($class)
 {
     if (isset(xp::$cl[$class])) {
         return xp::reflect($class);
     }
     // Load class
     $package = NULL;
     xp::$cl[$class] = $this->getClassName() . '://' . $this->path;
     xp::$cll++;
     try {
         $r = (include $this->classUri($class));
     } catch (ClassLoadingException $e) {
         xp::$cll--;
         $decl = NULL;
         if (NULL === $package) {
             $decl = substr($class, FALSE === ($p = strrpos($class, '.')) ? 0 : $p + 1);
         } else {
             $decl = strtr($class, '.', '·');
         }
         // If class was declared, but loading threw an exception it means
         // a "soft" dependency, one that is only required at runtime, was
         // not loaded, the class itself has been declared.
         if (class_exists($decl, FALSE) || interface_exists($decl, FALSE)) {
             raise('lang.ClassDependencyException', $class, array($this), $e);
         }
         // If otherwise, a "hard" dependency could not be loaded, eg. the
         // base class or a required interface and thus the class could not
         // be declared.
         raise('lang.ClassLinkageException', $class, array($this), $e);
     }
     xp::$cll--;
     if (FALSE === $r) {
         unset(xp::$cl[$class]);
         $e = new ClassNotFoundException($class, array($this));
         xp::gc(__FILE__);
         throw $e;
     }
     // Register class name / literal mapping, which is one of the following:
     //
     // * No dot in the qualified class name -> ClassName
     // * Dotted version declares $package -> com·example·ClassName
     // * Dotted version resolves to a namespaced class -> com\example\ClassName
     // * Dotted version resolves to class in the global namespace -> ClassName
     //
     // Create aliases for dotted versions not resolving to namespaces
     if (FALSE === ($p = strrpos($class, '.'))) {
         $name = $class;
     } else {
         if (NULL !== $package) {
             $name = strtr($class, '.', '·');
             class_alias($name, strtr($class, '.', '\\'));
         } else {
             if (($ns = strtr($class, '.', '\\')) && (class_exists($ns, FALSE) || interface_exists($ns, FALSE))) {
                 $name = $ns;
             } else {
                 if (($cl = substr($class, $p + 1)) && (class_exists($cl, FALSE) || interface_exists($cl, FALSE))) {
                     $name = $cl;
                     class_alias($name, strtr($class, '.', '\\'));
                 } else {
                     unset(xp::$cl[$class]);
                     raise('lang.ClassFormatException', 'Class "' . $class . '" not declared in loaded file');
                 }
             }
         }
     }
     xp::$cn[$name] = $class;
     method_exists($name, '__static') && (xp::$cli[] = array($name, '__static'));
     if (0 === xp::$cll) {
         $invocations = xp::$cli;
         xp::$cli = array();
         foreach ($invocations as $inv) {
             call_user_func($inv);
         }
     }
     return $name;
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:84,代码来源:AbstractClassLoader.class.php


注:本文中的xp::cli方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。