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


PHP Properties::containsKey方法代码示例

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


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

示例1: resolveAllProperties

 /**
  * Given a Properties object, this method goes through and resolves
  * any references to properties within the object.
  *
  * @param  Properties $props The collection of Properties that need to be resolved.
  * @throws BuildException
  * @return void
  */
 protected function resolveAllProperties(Properties $props)
 {
     foreach ($props->keys() as $name) {
         // There may be a nice regex/callback way to handle this
         // replacement, but at the moment it is pretty complex, and
         // would probably be a lot uglier to work into a preg_replace_callback()
         // system.  The biggest problem is the fact that a resolution may require
         // multiple passes.
         $value = $props->getProperty($name);
         $resolved = false;
         $resolveStack = array();
         while (!$resolved) {
             $fragments = array();
             $propertyRefs = array();
             // [HL] this was ::parsePropertyString($this->value ...) ... this seems wrong
             self::parsePropertyString($value, $fragments, $propertyRefs);
             $resolved = true;
             if (count($propertyRefs) == 0) {
                 continue;
             }
             $sb = "";
             $j = $propertyRefs;
             foreach ($fragments as $fragment) {
                 if ($fragment !== null) {
                     $sb .= $fragment;
                     continue;
                 }
                 $propertyName = array_shift($j);
                 if (in_array($propertyName, $resolveStack)) {
                     // Should we maybe just log this as an error & move on?
                     // $this->log("Property ".$name." was circularly defined.", Project::MSG_ERR);
                     throw new BuildException("Property " . $propertyName . " was circularly defined.");
                 }
                 $fragment = $this->getProject()->getProperty($propertyName);
                 if ($fragment !== null) {
                     $sb .= $fragment;
                     continue;
                 }
                 if ($props->containsKey($propertyName)) {
                     $fragment = $props->getProperty($propertyName);
                     if (strpos($fragment, '${') !== false) {
                         $resolveStack[] = $propertyName;
                         $resolved = false;
                         // parse again (could have been replaced w/ another var)
                     }
                 } else {
                     $fragment = "\${" . $propertyName . "}";
                 }
                 $sb .= $fragment;
             }
             $this->log("Resolved Property \"{$value}\" to \"{$sb}\"", Project::MSG_DEBUG);
             $value = $sb;
             $props->setProperty($name, $value);
         }
         // while (!$resolved)
     }
     // while (count($keys)
 }
开发者ID:continuousphptest,项目名称:workflow.test,代码行数:66,代码来源:PropertyTask.php


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