@@ -49,7 +49,7 @@ |
||
| 49 | 49 | $dumpHandler = new DumperHandlers($options); |
| 50 | 50 | if (is_scalar($dataType)) { |
| 51 | 51 | // TODO: what to woth comments ??? |
| 52 | - return "--- ".$dumpHandler->dumpScalar($dataType, 0). self::LINEFEED ; |
|
| 52 | + return "--- ".$dumpHandler->dumpScalar($dataType, 0).self::LINEFEED; |
|
| 53 | 53 | } |
| 54 | 54 | return $dumpHandler->dump($dataType, 0); |
| 55 | 55 | } |
@@ -44,7 +44,9 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | public static function toString($dataType, int $options = null):string |
| 46 | 46 | { |
| 47 | - if (empty($dataType)) throw new \Exception(self::class.": No content to convert to Yaml"); |
|
| 47 | + if (empty($dataType)) { |
|
| 48 | + throw new \Exception(self::class.": No content to convert to Yaml"); |
|
| 49 | + } |
|
| 48 | 50 | self::$options = is_int($options) ? $options : self::OPTIONS; |
| 49 | 51 | $dumpHandler = new DumperHandlers($options); |
| 50 | 52 | if (is_scalar($dataType)) { |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | public function __construct(string $nodeString, int $line) |
| 14 | 14 | { |
| 15 | 15 | parent::__construct($nodeString, $line); |
| 16 | - preg_match_all(Regex::MAPPING_VALUES, trim(substr(trim($nodeString), 1,-1)), $matches); |
|
| 16 | + preg_match_all(Regex::MAPPING_VALUES, trim(substr(trim($nodeString), 1, -1)), $matches); |
|
| 17 | 17 | foreach ($matches['k'] as $index => $property) { |
| 18 | 18 | $pair = $property.': '.trim($matches['v'][$index]); |
| 19 | 19 | $child = NodeFactory::get($pair, $line); |
@@ -10,17 +10,17 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class Comment extends NodeGeneric |
| 12 | 12 | { |
| 13 | - public function specialProcess(NodeGeneric &$previous, array &$emptyLines):bool |
|
| 14 | - { |
|
| 13 | + public function specialProcess(NodeGeneric &$previous, array &$emptyLines):bool |
|
| 14 | + { |
|
| 15 | 15 | $previous->getRoot()->add($this); |
| 16 | 16 | return true; |
| 17 | - } |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - public function build(&$parent = null) |
|
| 20 | - { |
|
| 19 | + public function build(&$parent = null) |
|
| 20 | + { |
|
| 21 | 21 | $root = $this->getRoot(); |
| 22 | 22 | $yamlObject = $root->getYamlObject(); |
| 23 | 23 | $yamlObject->addComment($this->line, $this->raw); |
| 24 | 24 | return null; |
| 25 | - } |
|
| 25 | + } |
|
| 26 | 26 | } |
| 27 | 27 | \ No newline at end of file |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | public function __construct(string $nodeString, int $line) |
| 19 | 19 | { |
| 20 | 20 | parent::__construct($nodeString, $line); |
| 21 | - preg_match_all(Regex::SEQUENCE_VALUES, trim(substr(trim($nodeString), 1,-1)), $matches); |
|
| 21 | + preg_match_all(Regex::SEQUENCE_VALUES, trim(substr(trim($nodeString), 1, -1)), $matches); |
|
| 22 | 22 | foreach ($matches['item'] as $key => $item) { |
| 23 | 23 | $i = new Item('', $line); |
| 24 | 24 | $i->indent = null; |
@@ -48,7 +48,7 @@ |
||
| 48 | 48 | |
| 49 | 49 | public function getTargetOnLessIndent(NodeGeneric &$node):NodeGeneric |
| 50 | 50 | { |
| 51 | - if ($node instanceof Scalar || $node instanceof Blank ) { |
|
| 51 | + if ($node instanceof Scalar || $node instanceof Blank) { |
|
| 52 | 52 | return $this->getParent(); |
| 53 | 53 | } else { |
| 54 | 54 | return $this->getParent($node->indent); |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | return false; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - /** |
|
| 156 | + /** |
|
| 157 | 157 | * Find parent target when current Node indentation is lesser than previous node indentation |
| 158 | 158 | * |
| 159 | 159 | * @param NodeGeneric $node |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | return $this->getParent(); |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - /** |
|
| 192 | + /** |
|
| 193 | 193 | * Find parent target when current Node indentation is superior than previous node indentation |
| 194 | 194 | * |
| 195 | 195 | * @param NodeGeneric $node |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function getParent(int $indent = null):NodeGeneric |
| 73 | 73 | { |
| 74 | - if (!is_int($indent)){ |
|
| 74 | + if (!is_int($indent)) { |
|
| 75 | 75 | if ($this->_parent instanceof NodeGeneric) { |
| 76 | 76 | return $this->_parent; |
| 77 | 77 | } else { |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | if ($this->tag) $props['tag'] = "($this->tag)"; |
| 246 | 246 | if ($this->value) $props['value'] = $this->value; |
| 247 | 247 | // $props['value'] = $this->value; |
| 248 | - $props['raw'] = $this->raw; |
|
| 248 | + $props['raw'] = $this->raw; |
|
| 249 | 249 | if (!$this->_parent) $props['parent'] = 'NO PARENT!!!'; |
| 250 | 250 | return $props; |
| 251 | 251 | } |
@@ -226,7 +226,9 @@ discard block |
||
| 226 | 226 | { |
| 227 | 227 | foreach ($classNameList as $className) { |
| 228 | 228 | $fqn = __NAMESPACE__."\\$className"; |
| 229 | - if ($this instanceof $fqn) return true; |
|
| 229 | + if ($this instanceof $fqn) { |
|
| 230 | + return true; |
|
| 231 | + } |
|
| 230 | 232 | } |
| 231 | 233 | return false; |
| 232 | 234 | } |
@@ -240,13 +242,23 @@ discard block |
||
| 240 | 242 | { |
| 241 | 243 | $props = []; |
| 242 | 244 | $props['line->indent'] = "$this->line -> $this->indent"; |
| 243 | - if ($this->identifier) $props['identifier'] = "($this->identifier)"; |
|
| 244 | - if ($this->anchor) $props['anchor'] = "($this->anchor)"; |
|
| 245 | - if ($this->tag) $props['tag'] = "($this->tag)"; |
|
| 246 | - if ($this->value) $props['value'] = $this->value; |
|
| 245 | + if ($this->identifier) { |
|
| 246 | + $props['identifier'] = "($this->identifier)"; |
|
| 247 | + } |
|
| 248 | + if ($this->anchor) { |
|
| 249 | + $props['anchor'] = "($this->anchor)"; |
|
| 250 | + } |
|
| 251 | + if ($this->tag) { |
|
| 252 | + $props['tag'] = "($this->tag)"; |
|
| 253 | + } |
|
| 254 | + if ($this->value) { |
|
| 255 | + $props['value'] = $this->value; |
|
| 256 | + } |
|
| 247 | 257 | // $props['value'] = $this->value; |
| 248 | 258 | $props['raw'] = $this->raw; |
| 249 | - if (!$this->_parent) $props['parent'] = 'NO PARENT!!!'; |
|
| 259 | + if (!$this->_parent) { |
|
| 260 | + $props['parent'] = 'NO PARENT!!!'; |
|
| 261 | + } |
|
| 250 | 262 | return $props; |
| 251 | 263 | } |
| 252 | 264 | } |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | if ($value instanceof Key && $child instanceof Key) { |
| 32 | 32 | if ($value->indent === $child->indent) { |
| 33 | 33 | return parent::add($child); |
| 34 | - } elseif ($value->isAwaitingChild($child)){ |
|
| 34 | + } elseif ($value->isAwaitingChild($child)) { |
|
| 35 | 35 | return $value->add($child); |
| 36 | 36 | } else { |
| 37 | 37 | // throw new \ParseError('key ('.$value->identifier.')@'.$value->line.' has already a value', 1); |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | $result = ''; |
| 18 | 18 | $list = $list->filterComment(); |
| 19 | 19 | if ($this->identifier !== '+') { |
| 20 | - self::litteralStripTrailing($list); |
|
| 20 | + self::litteralStripTrailing($list); |
|
| 21 | 21 | } |
| 22 | 22 | if ($list->count()) { |
| 23 | 23 | $list->setIteratorMode(NodeList::IT_MODE_DELETE); |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | public function setIdentifier(string $keyString) |
| 36 | 36 | { |
| 37 | 37 | if ($keyString === '') { |
| 38 | - throw new \ParseError(sprintf(self::ERROR_NO_KEYNAME, $this->line)); |
|
| 38 | + throw new \ParseError(sprintf(self::ERROR_NO_KEYNAME, $this->line)); |
|
| 39 | 39 | } else { |
| 40 | 40 | $keyNode = NodeFactory::get($keyString); |
| 41 | 41 | if ($keyNode instanceof Tag || $keyNode instanceof Quoted) { |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | public function add(NodeGeneric $child):NodeGeneric |
| 63 | 63 | { |
| 64 | - if ($this->value instanceof NodeGeneric && $this->value->isOneOf('Literal','LiteralFolded', 'Anchor')) { |
|
| 64 | + if ($this->value instanceof NodeGeneric && $this->value->isOneOf('Literal', 'LiteralFolded', 'Anchor')) { |
|
| 65 | 65 | return $this->value->add($child); |
| 66 | 66 | } else { |
| 67 | 67 | return parent::add($child); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | if ($current instanceof Comment) { |
| 97 | 97 | return true; |
| 98 | 98 | } |
| 99 | - if($current instanceof Scalar) { |
|
| 99 | + if ($current instanceof Scalar) { |
|
| 100 | 100 | return $node->isOneOf('Scalar', 'Blank'); |
| 101 | 101 | } |
| 102 | 102 | if ($current instanceof Item) { |