]> granicus.if.org Git - php/commitdiff
fix optional dependencies in reading, validating, and writing of package.xml
authorGreg Beaver <cellog@php.net>
Wed, 13 Aug 2003 21:12:15 +0000 (21:12 +0000)
committerGreg Beaver <cellog@php.net>
Wed, 13 Aug 2003 21:12:15 +0000 (21:12 +0000)
pear/PEAR/Common.php

index 81f88b66431bf16fe4215611f269dc540174800e..4f511a337ca9e70a3e05c2107c985d7445181a21 100644 (file)
@@ -924,6 +924,9 @@ class PEAR_Common extends PEAR
                 if (isset($dep['version'])) {
                     $ret .= " version=\"$dep[version]\"";
                 }
+                if (isset($dep['optional'])) {
+                    $ret .= " optional=\"$dep[optional]\"";
+                }
                 if (isset($dep['name'])) {
                     $ret .= ">$dep[name]</dep>\n";
                 } else {
@@ -1090,6 +1093,11 @@ class PEAR_Common extends PEAR
                 } elseif (!in_array($d['rel'], $_PEAR_Common_dependency_relations)) {
                     $errors[] = "dependency $i: invalid relation, should be one of: ".implode(' ', $_PEAR_Common_dependency_relations);
                 }
+                if (!empty($d['optional'])) {
+                    if (!in_array($d['optional'], array('yes', 'no'))) {
+                        $errors[] = "dependency $i: invalid relation optional attribute, should be one of: yes no";
+                    }
+                }
                 if ($d['rel'] != 'has' && empty($d['version'])) {
                     $warnings[] = "dependency $i: missing version";
                 } elseif ($d['rel'] == 'has' && !empty($d['version'])) {