本文整理汇总了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)
}