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


PHP StringHelper::unqualify方法代码示例

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


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

示例1: addLocation

 /**
  * Add a dot-notation or PEAR-notation class (and optionally
  * classpath) to the list of locations
  * 
  * @param string $classname
  * @param string $classpath
  * @return string
  */
 public static function addLocation($classname, $classpath = null)
 {
     /// check if this is a PEAR-style path (@see http://pear.php.net/manual/en/standards.naming.php)
     if (strpos($classname, '.') === false && strpos($classname, '_') !== false) {
         $cls = $classname;
         $classname = str_replace('_', '.', $classname);
     } else {
         $cls = StringHelper::unqualify($classname);
     }
     // 1- temporarily replace escaped '.' with another illegal char (#)
     $tmp = str_replace('\\.', '##', $classname);
     // 2- swap out the remaining '.' with DIR_SEP
     $tmp = strtr($tmp, '.', DIRECTORY_SEPARATOR);
     // 3- swap back the escaped '.'
     $tmp = str_replace('##', '.', $tmp);
     $path = dirname($tmp);
     if (!empty($classpath)) {
         $path = $classpath . DIRECTORY_SEPARATOR . $path;
     }
     self::$locations[$path] = true;
     return $cls;
 }
开发者ID:hkilter,项目名称:OpenSupplyChains,代码行数:30,代码来源:PhingAutoLoader.php

示例2: createDataType

 /**
  * Create a datatype instance and return reference to it
  * See createTask() for explanation how this works
  *
  * @param  string         $typeName Type name
  * @return object         A datatype object
  * @throws BuildException
  *                                 Exception
  */
 public function createDataType($typeName)
 {
     try {
         $cls = "";
         $typelwr = strtolower($typeName);
         foreach ($this->typedefs as $name => $class) {
             if (strtolower($name) === $typelwr) {
                 $cls = StringHelper::unqualify($class);
                 break;
             }
         }
         if ($cls === "") {
             return null;
         }
         if (!class_exists($cls)) {
             throw new BuildException("Could not instantiate class {$cls}, even though a class was specified. (Make sure that the specified class file contains a class with the correct name.)");
         }
         $type = new $cls();
         $this->log("  +Type: {$typeName}", Project::MSG_DEBUG);
         if (!$type instanceof DataType) {
             throw new Exception("{$class} is not an instance of phing.types.DataType");
         }
         if ($type instanceof ProjectComponent) {
             $type->setProject($this);
         }
     } catch (Exception $t) {
         throw new BuildException("Could not create type: {$typeName}", $t);
     }
     // everything fine return reference
     return $type;
 }
开发者ID:Ingewikkeld,项目名称:phing,代码行数:40,代码来源:Project.php

示例3: import

 /**
  * Import a path, supporting the following conventions:
  * - PEAR style (@link http://pear.php.net/manual/en/standards.naming.php)
  * - PSR-0 (@link https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md)
  * - dot-path
  *
  * @param string $dotPath   Path
  * @param mixed  $classpath String or object supporting __toString()
  *
  * @return string         The unqualified classname (which can be instantiated).
  *
  * @throws BuildException - if cannot find the specified file
  */
 public static function import($dotPath, $classpath = null)
 {
     if (strpos($dotPath, '.') !== false) {
         $classname = StringHelper::unqualify($dotPath);
     } else {
         $classname = $dotPath;
         $dotPath = '';
         $shortClassName = $classname;
         if ($lastNsPos = strripos($shortClassName, '\\')) {
             $namespace = substr($shortClassName, 0, $lastNsPos);
             $shortClassName = substr($shortClassName, $lastNsPos + 1);
             $dotPath = str_replace('\\', '.', $namespace) . '.';
         }
         $dotPath .= str_replace('_', '.', $shortClassName);
     }
     // first check to see that the class specified hasn't already been included.
     // (this also handles case where this method is called w/ a classname rather than dotpath)
     if (class_exists($classname)) {
         return $classname;
     }
     $dotClassname = basename($dotPath);
     $dotClassnamePos = strlen($dotPath) - strlen($dotClassname);
     // 1- temporarily replace escaped '.' with another illegal char (#)
     $tmp = str_replace('\\.', '##', $dotClassname);
     // 2- swap out the remaining '.' with DIR_SEP
     $tmp = strtr($tmp, '.', DIRECTORY_SEPARATOR);
     // 3- swap back the escaped '.'
     $tmp = str_replace('##', '.', $tmp);
     $classFile = $tmp . ".php";
     $path = substr_replace($dotPath, $classFile, $dotClassnamePos);
     Phing::__import($path, $classpath);
     return $classname;
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:46,代码来源:Phing.php

示例4: import

 /**
  * Import a dot-path notation class path.
  * @param string $dotPath
  * @param mixed $classpath String or object supporting __toString()
  * @return string The unqualified classname (which can be instantiated).
  * @throws BuildException - if cannot find the specified file
  */
 public static function import($dotPath, $classpath = null)
 {
     /// check if this is a PEAR-style path (@link http://pear.php.net/manual/en/standards.naming.php)
     if (strpos($dotPath, '.') === false && strpos($dotPath, '_') !== false) {
         $classname = $dotPath;
         $dotPath = str_replace('_', '.', $dotPath);
     } else {
         $classname = StringHelper::unqualify($dotPath);
     }
     // first check to see that the class specified hasn't already been included.
     // (this also handles case where this method is called w/ a classname rather than dotpath)
     if (class_exists($classname)) {
         return $classname;
     }
     $dotClassname = basename($dotPath);
     $dotClassnamePos = strlen($dotPath) - strlen($dotClassname);
     // 1- temporarily replace escaped '.' with another illegal char (#)
     $tmp = str_replace('\\.', '##', $dotClassname);
     // 2- swap out the remaining '.' with DIR_SEP
     $tmp = strtr($tmp, '.', DIRECTORY_SEPARATOR);
     // 3- swap back the escaped '.'
     $tmp = str_replace('##', '.', $tmp);
     $classFile = $tmp . ".php";
     $path = substr_replace($dotPath, $classFile, $dotClassnamePos);
     Phing::__import($path, $classpath);
     return $classname;
 }
开发者ID:altesien,项目名称:FinalProject,代码行数:34,代码来源:Phing.php

示例5: getElementName

 /**
  * Get the the name for an element.
  * When possible the full classnam (phing.tasks.system.PropertyTask) will
  * be returned.  If not available (loaded in taskdefs or typedefs) then the
  * XML element name will be returned.
  *
  * @param Project $project
  * @param object $element The Task or type element.
  * @return string Fully qualified class name of element when possible.
  */
 function getElementName(Project $project, $element)
 {
     $taskdefs = $project->getTaskDefinitions();
     $typedefs = $project->getDataTypeDefinitions();
     // check if class of element is registered with project (tasks & types)
     // most element types don't have a getTag() method
     $elClass = get_class($element);
     if (!in_array('getTag', get_class_methods($elClass))) {
         // loop through taskdefs and typesdefs and see if the class name
         // matches (case-insensitive) any of the classes in there
         foreach (array_merge($taskdefs, $typedefs) as $elName => $class) {
             if (0 === strcasecmp($elClass, StringHelper::unqualify($class))) {
                 return $class;
             }
         }
         return "{$elClass} (unknown)";
     } else {
         // ->getTag() method does exist, so use it
         $elName = $element->getTag();
         if (isset($taskdefs[$elName])) {
             return $taskdefs[$elName];
         } elseif (isset($typedefs[$elName])) {
             return $typedefs[$elName];
         } else {
             return "{$elName} (unknown)";
         }
     }
 }
开发者ID:taryono,项目名称:school,代码行数:38,代码来源:IntrospectionHelper.php

示例6: import

 /**
  * Import a dot-path notation class path.
  * @param string $dotPath
  * @param mixed $classpath String or object supporting __toString()
  * @return string The unqualified classname (which can be instantiated).
  * @throws BuildException - if cannot find the specified file
  */
 public static function import($dotPath, $classpath = null)
 {
     // first check to see that the class specified hasn't already been included.
     // (this also handles case where this method is called w/ a classname rather than dotpath)
     $classname = StringHelper::unqualify($dotPath);
     if (class_exists($classname, false)) {
         return $classname;
     }
     $dotClassname = basename($dotPath);
     $dotClassnamePos = strlen($dotPath) - strlen($dotClassname);
     $classFile = strtr($dotClassname, '.', DIRECTORY_SEPARATOR) . ".php";
     $path = substr_replace($dotPath, $classFile, $dotClassnamePos);
     Phing::__import($path, $classpath);
     return $classname;
 }
开发者ID:domenypl,项目名称:symfony1-legacy,代码行数:22,代码来源:Phing.php


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