@@ -29,7 +29,7 @@ |
||
| 29 | 29 | public function build(&$parent = null) |
| 30 | 30 | { |
| 31 | 31 | $built = is_null($this->value) ? null : $this->value->build(); |
| 32 | - $stringKey = is_string($built) && Regex::isProperlyQuoted($built) ? trim($built, '\'" '): $built; |
|
| 32 | + $stringKey = is_string($built) && Regex::isProperlyQuoted($built) ? trim($built, '\'" ') : $built; |
|
| 33 | 33 | $key = json_encode($stringKey, JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_UNESCAPED_SLASHES); |
| 34 | 34 | if (empty($key)) throw new \Exception("Cant serialize complex key: ".var_export($this->value, true)); |
| 35 | 35 | $parent->{trim($key, '\'" ')} = null; |
@@ -34,7 +34,9 @@ |
||
| 34 | 34 | $built = is_null($this->value) ? null : $this->value->build(); |
| 35 | 35 | $stringKey = is_string($built) && Regex::isProperlyQuoted($built) ? trim($built, '\'" '): $built; |
| 36 | 36 | $key = json_encode($stringKey, JSON_PARTIAL_OUTPUT_ON_ERROR|JSON_UNESCAPED_SLASHES); |
| 37 | - if (empty($key)) throw new \Exception("Cant serialize complex key: ".var_export($this->value, true)); |
|
| 37 | + if (empty($key)) { |
|
| 38 | + throw new \Exception("Cant serialize complex key: ".var_export($this->value, true)); |
|
| 39 | + } |
|
| 38 | 40 | $parent->{trim($key, '\'" ')} = null; |
| 39 | 41 | return null; |
| 40 | 42 | } |
@@ -21,8 +21,8 @@ |
||
| 21 | 21 | $result = ''; |
| 22 | 22 | $list = $value->filterComment(); |
| 23 | 23 | if ($this->identifier !== '+') { |
| 24 | - self::litteralStripLeading($list); |
|
| 25 | - self::litteralStripTrailing($list); |
|
| 24 | + self::litteralStripLeading($list); |
|
| 25 | + self::litteralStripTrailing($list); |
|
| 26 | 26 | } |
| 27 | 27 | if ($list->count()) { |
| 28 | 28 | $refSeparator = ' '; |
@@ -31,10 +31,10 @@ |
||
| 31 | 31 | $result = $this->getChildValue($first, $indent); |
| 32 | 32 | foreach ($list as $child) { |
| 33 | 33 | $separator = ($result && $result[-1] === "\n") ? '' : $refSeparator; |
| 34 | - if($child->indent > $indent || $child instanceof Blank) { |
|
| 34 | + if ($child->indent > $indent || $child instanceof Blank) { |
|
| 35 | 35 | $separator = "\n"; |
| 36 | 36 | } |
| 37 | - $result .= $separator .$this->getChildValue($child, $indent); |
|
| 37 | + $result .= $separator.$this->getChildValue($child, $indent); |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | return $result; |
@@ -12,6 +12,6 @@ |
||
| 12 | 12 | { |
| 13 | 13 | public function build(&$parent = null) |
| 14 | 14 | { |
| 15 | - return substr(trim($this->raw), 1,-1); |
|
| 15 | + return substr(trim($this->raw), 1, -1); |
|
| 16 | 16 | } |
| 17 | 17 | } |
| 18 | 18 | \ No newline at end of file |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | foreach ($node as $key => $child) { |
| 68 | 68 | $list[] = $this->str($child); |
| 69 | 69 | } |
| 70 | - return new Nodes\Scalar(implode('',$list), 0); |
|
| 70 | + return new Nodes\Scalar(implode('', $list), 0); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
@@ -62,7 +62,6 @@ |
||
| 62 | 62 | %TAG !! tag:example.com,2000:app/ |
| 63 | 63 | %TAG !e! tag:example.com,2000:app/ |
| 64 | 64 | !<tag:yaml.org,2002:str> foo : |
| 65 | - |
|
| 66 | 65 | */ |
| 67 | 66 | /** |
| 68 | 67 | * Add Handlers for legacy Yaml tags |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | if (count(self::$schemas) === 0) { |
| 107 | 107 | self::createCoreSchema(); |
| 108 | 108 | } |
| 109 | - if (!($value instanceof NodeGeneric) && !($value instanceof NodeList) ) { |
|
| 109 | + if (!($value instanceof NodeGeneric) && !($value instanceof NodeList)) { |
|
| 110 | 110 | throw new \Exception(sprintf(self::WRONG_VALUE, $identifier, gettype($value))); |
| 111 | 111 | } else { |
| 112 | 112 | try { |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | $tagname = $matches['tagname']; |
| 119 | 119 | // return; |
| 120 | 120 | if (is_string($handle) && array_key_exists($handle, self::$schemaHandles)) { |
| 121 | - $schemaName = self::$schemaHandles[$handle]; |
|
| 121 | + $schemaName = self::$schemaHandles[$handle]; |
|
| 122 | 122 | if (is_string($schemaName) && array_key_exists($schemaName, self::$schemas)) { |
| 123 | 123 | $schemaObject = self::$schemas[$schemaName]; |
| 124 | 124 | if (is_object($schemaObject) && is_string($tagname)) { |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | } catch (\UnexpectedValueException $e) { |
| 131 | 131 | return new Tagged($identifier, is_null($value) ? null : $value->build($parent)); |
| 132 | 132 | } catch (\Throwable $e) { |
| 133 | - throw new \Exception("Tagged value could not be transformed for tag '$identifier'", 1, $e);; |
|
| 133 | + throw new \Exception("Tagged value could not be transformed for tag '$identifier'", 1, $e); ; |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | // return self::$tagsNamespaces[$identifier]($value); |
@@ -94,7 +94,7 @@ |
||
| 94 | 94 | * @return string The child value. |
| 95 | 95 | * @todo double check behaviour for KEY and ITEM |
| 96 | 96 | */ |
| 97 | - protected function getChildValue(object $child, $refIndent=0):string |
|
| 97 | + protected function getChildValue(object $child, $refIndent = 0):string |
|
| 98 | 98 | { |
| 99 | 99 | $value = $child->value; |
| 100 | 100 | $start = ''; |
@@ -32,7 +32,9 @@ |
||
| 32 | 32 | |
| 33 | 33 | public function add(NodeGeneric $child):NodeGeneric |
| 34 | 34 | { |
| 35 | - if (is_null($this->value)) $this->value = new NodeList(); |
|
| 35 | + if (is_null($this->value)) { |
|
| 36 | + $this->value = new NodeList(); |
|
| 37 | + } |
|
| 36 | 38 | $candidate = $child; |
| 37 | 39 | if (!$child->isOneOf('Scalar', 'Blank', 'Comment', 'Quoted')) { |
| 38 | 40 | $candidate = new Scalar((string) $child->raw, $child->line); |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | throw new \Exception(__METHOD__." expects a YamlObject as parent", 1); |
| 40 | 40 | } |
| 41 | 41 | if (!is_null($this->value)) { |
| 42 | - if ($this->value instanceof Tag){ |
|
| 42 | + if ($this->value instanceof Tag) { |
|
| 43 | 43 | if (!preg_match(Regex::TAG_PARTS, $this->value->raw, $matches)) { |
| 44 | 44 | throw new \InvalidValueException("Tag '$this->value->raw' is invalid", 1); |
| 45 | 45 | } |