Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some refactoring

  • Loading branch information...
commit 0ceefd71cc92ad9d8df779a2979f330bc4b74a18 1 parent 569e320
@mrook mrook authored
Showing with 43 additions and 42 deletions.
  1. +43 −42 classes/phing/tasks/system/PropertyTask.php
View
85 classes/phing/tasks/system/PropertyTask.php
@@ -342,20 +342,17 @@ protected function loadFile(PhingFile $file) {
*/
protected function resolveAllProperties(Properties $props) {
- $keys = $props->keys();
-
- while(count($keys)) {
-
+ 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.
- $name = array_shift($keys);
$value = $props->getProperty($name);
$resolved = false;
$resolveStack = array();
+
while(!$resolved) {
$fragments = array();
@@ -365,45 +362,49 @@ protected function resolveAllProperties(Properties $props) {
self::parsePropertyString($value, $fragments, $propertyRefs);
$resolved = true;
- if (count($propertyRefs) !== 0) {
-
- $sb = "";
-
- $i = $fragments;
- $j = $propertyRefs;
- while(count($i)) {
- $fragment = array_shift($i);
- if ($fragment === null) {
- $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) {
- 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."}";
- }
- }
- }
+ 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.");
}
-
- $this->log("Resolved Property \"$value\" to \"$sb\"", Project::MSG_DEBUG);
- $value = $sb;
- $props->setProperty($name, $value);
-
- } // if (count($propertyRefs))
-
+
+ $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)
Please sign in to comment.
Something went wrong with that request. Please try again.