@@ -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); |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | { |
| 13 | 13 | public function add(NodeGeneric $child):NodeGeneric |
| 14 | 14 | { |
| 15 | - if($this->_parent instanceof NodeGeneric) { |
|
| 15 | + if ($this->_parent instanceof NodeGeneric) { |
|
| 16 | 16 | return $this->_parent->add($child); |
| 17 | 17 | } else { |
| 18 | 18 | throw new \ParseError(__METHOD__." no parent to add to", 1); |
@@ -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; |
@@ -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 |
@@ -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 = ''; |
@@ -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) { |
@@ -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). self::LINEFEED ; |
|
| 52 | + return "--- ".$dumpHandler->dumpScalar($dataType).self::LINEFEED; |
|
| 53 | 53 | } |
| 54 | 54 | return $dumpHandler->dump($dataType, 0); |
| 55 | 55 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | define('PROJECT_ROOT', __DIR__."/../"); |
| 3 | 3 | |
| 4 | -require_once PROJECT_ROOT . 'vendor/autoload.php'; |
|
| 4 | +require_once PROJECT_ROOT.'vendor/autoload.php'; |
|
| 5 | 5 | |
| 6 | 6 | use Dallgoot\Yaml; |
| 7 | 7 | // use Dallgoot\Yaml\{Loader, Dumper}; |
@@ -14,10 +14,10 @@ discard block |
||
| 14 | 14 | // $yaml = (new Loader('./dummy.yml', null, 0))->parse(); |
| 15 | 15 | // var_dump($yaml); |
| 16 | 16 | $testName = 'yamlObject_properties'; |
| 17 | -$yamlObject = (include PROJECT_ROOT . "tests/cases/dumping/$testName.php"); |
|
| 17 | +$yamlObject = (include PROJECT_ROOT."tests/cases/dumping/$testName.php"); |
|
| 18 | 18 | $text = Yaml::dump($yamlObject, 0); |
| 19 | 19 | |
| 20 | -$nameResultPair = get_object_vars(/** @scrutinizer ignore-type */ Yaml::parseFile(PROJECT_ROOT . 'tests/definitions/dumping_tests.yml')); |
|
| 20 | +$nameResultPair = get_object_vars(/** @scrutinizer ignore-type */ Yaml::parseFile(PROJECT_ROOT.'tests/definitions/dumping_tests.yml')); |
|
| 21 | 21 | |
| 22 | 22 | // var_dump($nameResultPair); |
| 23 | 23 | |