@@ -79,12 +79,12 @@ |
||
| 79 | 79 | */ |
| 80 | 80 | public function checkTypeCoherence($estimatedType):bool |
| 81 | 81 | { |
| 82 | - // if ($this->type === self::MAPPING) { |
|
| 83 | - // if ($estimatedType === self::SEQUENCE) { |
|
| 84 | - // throw new \ParseError("Error : no coherence in types", 1); |
|
| 85 | - // } |
|
| 86 | - // } |
|
| 87 | - return (bool) $estimatedType; |
|
| 82 | + // if ($this->type === self::MAPPING) { |
|
| 83 | + // if ($estimatedType === self::SEQUENCE) { |
|
| 84 | + // throw new \ParseError("Error : no coherence in types", 1); |
|
| 85 | + // } |
|
| 86 | + // } |
|
| 87 | + return (bool) $estimatedType; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | public function build(&$parent = null) |
@@ -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 |
@@ -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 |
@@ -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); |
@@ -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 = ' '; |
@@ -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 | $node = NodeFactory::get($keyString); |
| 41 | 41 | if ($node->isOneOf('Tag', 'Quoted')) { |
@@ -62,7 +62,6 @@ discard block |
||
| 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 |
@@ -107,16 +106,16 @@ discard block |
||
| 107 | 106 | self::createCoreSchema(); |
| 108 | 107 | } |
| 109 | 108 | if (!($value instanceof NodeGeneric) && !($value instanceof NodeList) ) { |
| 110 | - throw new \Exception(sprintf(self::WRONG_VALUE, $identifier, gettype($value))); |
|
| 109 | + throw new \Exception(sprintf(self::WRONG_VALUE, $identifier, gettype($value))); |
|
| 111 | 110 | } else { |
| 112 | 111 | // try { |
| 113 | 112 | if (!preg_match(Regex::TAG_PARTS, $identifier, $matches)) { |
| 114 | 113 | throw new \UnexpectedValueException("Tag '$identifier' is invalid", 1); |
| 115 | 114 | } |
| 116 | 115 | return self::runHandler($matches['handle'], |
| 117 | - $matches['tagname'], |
|
| 118 | - $value, |
|
| 119 | - $parent); |
|
| 116 | + $matches['tagname'], |
|
| 117 | + $value, |
|
| 118 | + $parent); |
|
| 120 | 119 | // } catch (\UnexpectedValueException $e) { |
| 121 | 120 | // return new Tagged($identifier, is_null($value) ? null : $value->build($parent)); |
| 122 | 121 | // } catch (\Throwable $e) { |
@@ -99,35 +99,35 @@ |
||
| 99 | 99 | if (Regex::isDate($v)) return Builder::$dateAsObject && !$onlyScalar ? date_create($v) : $v; |
| 100 | 100 | if (Regex::isNumber($v)) return self::getNumber($v); |
| 101 | 101 | $types = ['yes' => true, |
| 102 | - 'no' => false, |
|
| 103 | - 'true' => true, |
|
| 104 | - 'false' => false, |
|
| 105 | - 'null' => null, |
|
| 106 | - '.inf' => \INF, |
|
| 107 | - '-.inf' => -\INF, |
|
| 108 | - '.nan' => \NAN |
|
| 102 | + 'no' => false, |
|
| 103 | + 'true' => true, |
|
| 104 | + 'false' => false, |
|
| 105 | + 'null' => null, |
|
| 106 | + '.inf' => \INF, |
|
| 107 | + '-.inf' => -\INF, |
|
| 108 | + '.nan' => \NAN |
|
| 109 | 109 | ]; |
| 110 | 110 | return array_key_exists(strtolower($v), $types) ? $types[strtolower($v)] : self::replaceSequences($v); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | public static function replaceSequences($value='') |
| 114 | 114 | { |
| 115 | - $replaceUnicodeSeq = function ($matches) { |
|
| 115 | + $replaceUnicodeSeq = function ($matches) { |
|
| 116 | 116 | return json_decode('"'.$matches[1].'"'); |
| 117 | - }; |
|
| 118 | - $replaceNonPrintable = function ($matches) { |
|
| 117 | + }; |
|
| 118 | + $replaceNonPrintable = function ($matches) { |
|
| 119 | 119 | // var_dump($matches[1]); |
| 120 | 120 | return $matches[1].""; |
| 121 | - }; |
|
| 121 | + }; |
|
| 122 | 122 | // preg_match( "/[^\x{06F0}-\x{06F9}\x]+/u" , '۱۲۳۴۵۶۷۸۹۰' ); |
| 123 | - return preg_replace_callback_array( |
|
| 124 | - [ |
|
| 125 | - '/((?<![\\\\])\\\\x[0-9a-f]{2})/i' => $replaceUnicodeSeq, |
|
| 126 | - '/((?<![\\\\])\\\\u[0-9a-f]{4,})/i' => $replaceUnicodeSeq, |
|
| 127 | - '/(\\\\b|\\\\n|\\\\t|\\\\r)/' => $replaceNonPrintable |
|
| 128 | - ], |
|
| 129 | - $value |
|
| 130 | - ); |
|
| 123 | + return preg_replace_callback_array( |
|
| 124 | + [ |
|
| 125 | + '/((?<![\\\\])\\\\x[0-9a-f]{2})/i' => $replaceUnicodeSeq, |
|
| 126 | + '/((?<![\\\\])\\\\u[0-9a-f]{4,})/i' => $replaceUnicodeSeq, |
|
| 127 | + '/(\\\\b|\\\\n|\\\\t|\\\\r)/' => $replaceNonPrintable |
|
| 128 | + ], |
|
| 129 | + $value |
|
| 130 | + ); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | public function dumpYamlObject(YamlObject $obj):string |
| 106 | 106 | { |
| 107 | 107 | if ($this->multipleDocs || $obj->hasDocStart() || $obj->isTagged()) { |
| 108 | - $this->multipleDocs = true; |
|
| 109 | - // && $this->$result instanceof DLL) $this->$result->push("---"); |
|
| 108 | + $this->multipleDocs = true; |
|
| 109 | + // && $this->$result instanceof DLL) $this->$result->push("---"); |
|
| 110 | 110 | } |
| 111 | 111 | // $this->insertComments($obj->getComment()); |
| 112 | 112 | if (count($obj) > 0) { |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | |
| 120 | 120 | public function iteratorToString(\Iterator $iterable, |
| 121 | - string $keyMask, string $itemSeparator, int $indent):string |
|
| 121 | + string $keyMask, string $itemSeparator, int $indent):string |
|
| 122 | 122 | { |
| 123 | 123 | $pairs = []; |
| 124 | 124 | $valueIndent = $indent + self::INDENT; |