comparison vendor/consolidation/annotated-command/src/Parser/Internal/BespokeDocBlockParser.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
135 135
136 protected function addOptionOrArgumentTag($tag, DefaultsWithDescriptions $set, $name, $description) 136 protected function addOptionOrArgumentTag($tag, DefaultsWithDescriptions $set, $name, $description)
137 { 137 {
138 $variableName = $this->commandInfo->findMatchingOption($name); 138 $variableName = $this->commandInfo->findMatchingOption($name);
139 $description = static::removeLineBreaks($description); 139 $description = static::removeLineBreaks($description);
140 list($description, $defaultValue) = $this->splitOutDefault($description);
140 $set->add($variableName, $description); 141 $set->add($variableName, $description);
142 if ($defaultValue !== null) {
143 $set->setDefaultValue($variableName, $defaultValue);
144 }
145 }
146
147 protected function splitOutDefault($description)
148 {
149 if (!preg_match('#(.*)(Default: *)(.*)#', trim($description), $matches)) {
150 return [$description, null];
151 }
152
153 return [trim($matches[1]), $this->interpretDefaultValue(trim($matches[3]))];
141 } 154 }
142 155
143 /** 156 /**
144 * Store the data from a @default annotation in our argument or option store, 157 * Store the data from a @default annotation in our argument or option store,
145 * as appropriate. 158 * as appropriate.