@@ -96,7 +96,7 @@ |
||
| 96 | 96 | * @return string The child value. |
| 97 | 97 | * @todo double check behaviour for KEY and ITEM |
| 98 | 98 | */ |
| 99 | - protected function getChildValue($child, $refIndent=0):string |
|
| 99 | + protected function getChildValue($child, $refIndent = 0):string |
|
| 100 | 100 | { |
| 101 | 101 | $value = $child->value; |
| 102 | 102 | $start = ''; |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | elseif ((bool) preg_match(Regex::KEY, $trimmed, $matches)) return new Nodes\Key($nodeString, $line, $matches); |
| 29 | 29 | else { |
| 30 | 30 | $first = $trimmed[0]; |
| 31 | - $stringGroups = ['-', '>|' , '"\'', "#%" , "{[" , ":?" , '*&!']; |
|
| 32 | - $methodGroups = ['Hyphen','Literal','Quoted','Special','Compact','SetElement','NodeAction']; |
|
| 31 | + $stringGroups = ['-', '>|', '"\'', "#%", "{[", ":?", '*&!']; |
|
| 32 | + $methodGroups = ['Hyphen', 'Literal', 'Quoted', 'Special', 'Compact', 'SetElement', 'NodeAction']; |
|
| 33 | 33 | foreach ($stringGroups as $groupIndex => $stringRef) { |
| 34 | 34 | if (is_int(strpos($stringRef, $first))) { |
| 35 | 35 | $methodName = 'on'.$methodGroups[$groupIndex]; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | ini_restore($backtrack_setting); |
| 116 | 116 | |
| 117 | 117 | if (is_bool($isMapping) || is_bool($isSequence)) { |
| 118 | - throw new \Exception("Regex Error for ".(is_bool($isMapping) ? 'mapping:' :'sequence:').preg_last_error()); |
|
| 118 | + throw new \Exception("Regex Error for ".(is_bool($isMapping) ? 'mapping:' : 'sequence:').preg_last_error()); |
|
| 119 | 119 | } |
| 120 | 120 | if ($isMapping) { |
| 121 | 121 | // var_dump(Regex::MAPPING, trim($nodeString)); |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | $buffer->push($child); |
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | - $documents[] = $this->buildDocument($buffer, count($documents) +1); |
|
| 59 | + $documents[] = $this->buildDocument($buffer, count($documents) + 1); |
|
| 60 | 60 | } catch (\Throwable $e) { |
| 61 | 61 | throw new \Exception($e->getMessage(), 1, $e); |
| 62 | 62 | } |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | try { |
| 58 | 58 | return call_user_func_array([$this->__yaml__object__api, $funcName], $arguments); |
| 59 | 59 | } catch (\Throwable $e) { |
| 60 | - throw new \BadMethodCallException(sprintf(self::UNDEFINED_METHOD, $funcName), 1,$e); |
|
| 60 | + throw new \BadMethodCallException(sprintf(self::UNDEFINED_METHOD, $funcName), 1, $e); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | //public |
| 21 | 21 | /* @var null|string */ |
| 22 | 22 | public static $error; |
| 23 | - public const IGNORE_DIRECTIVES = 0b0001;//DONT include_directive |
|
| 24 | - public const IGNORE_COMMENTS = 0b0010;//DONT include_comments |
|
| 25 | - public const NO_PARSING_EXCEPTIONS = 0b0100;//DONT throw Exception on parsing errors |
|
| 26 | - public const NO_OBJECT_FOR_DATE = 0b1000;//DONT import date strings as dateTime Object |
|
| 23 | + public const IGNORE_DIRECTIVES = 0b0001; //DONT include_directive |
|
| 24 | + public const IGNORE_COMMENTS = 0b0010; //DONT include_comments |
|
| 25 | + public const NO_PARSING_EXCEPTIONS = 0b0100; //DONT throw Exception on parsing errors |
|
| 26 | + public const NO_OBJECT_FOR_DATE = 0b1000; //DONT import date strings as dateTime Object |
|
| 27 | 27 | |
| 28 | 28 | //private |
| 29 | 29 | /* @var null|array */ |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | { |
| 179 | 179 | $deepest = $previous->getDeepestNode(); |
| 180 | 180 | if ($deepest instanceof Nodes\Partial) { |
| 181 | - return $deepest->specialProcess($current, $this->_blankBuffer); |
|
| 182 | - } elseif(!($current instanceof Nodes\Partial)) { |
|
| 181 | + return $deepest->specialProcess($current, $this->_blankBuffer); |
|
| 182 | + } elseif (!($current instanceof Nodes\Partial)) { |
|
| 183 | 183 | return $current->specialProcess($previous, $this->_blankBuffer); |
| 184 | 184 | } |
| 185 | 185 | return false; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function str($node, &$parent = null) |
| 59 | 59 | { |
| 60 | - if($node instanceof Nodes\Literals){ |
|
| 60 | + if ($node instanceof Nodes\Literals) { |
|
| 61 | 61 | $node = $node->value; |
| 62 | 62 | } |
| 63 | 63 | if ($node instanceof Nodes\NodeGeneric) { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | $list[] = $this->str($child); |
| 73 | 73 | } |
| 74 | 74 | // return new Nodes\Scalar(implode('',$list), 0); |
| 75 | - return implode('',$list); |
|
| 75 | + return implode('', $list); |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $keyValue = $key->value->build(); |
| 134 | 134 | if (is_null($parent)) { |
| 135 | 135 | return [$keyName => $keyValue]; |
| 136 | - } else{ |
|
| 136 | + } else { |
|
| 137 | 137 | $parent[$keyName] = $keyValue; |
| 138 | 138 | } |
| 139 | 139 | } else { |
@@ -6,18 +6,18 @@ |
||
| 6 | 6 | /** |
| 7 | 7 | * Display some use cases for Yaml library |
| 8 | 8 | */ |
| 9 | -const JSON_OPTIONS = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION | JSON_PARTIAL_OUTPUT_ON_ERROR; |
|
| 9 | +const JSON_OPTIONS = JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_LINE_TERMINATORS|JSON_UNESCAPED_UNICODE|JSON_PRESERVE_ZERO_FRACTION|JSON_PARTIAL_OUTPUT_ON_ERROR; |
|
| 10 | 10 | |
| 11 | 11 | $debug = (int) (isset($argv[1]) ? $argv[1] : null); |
| 12 | 12 | |
| 13 | -echo memory_get_usage() . "\n"; |
|
| 13 | +echo memory_get_usage()."\n"; |
|
| 14 | 14 | /* USE CASE 1 |
| 15 | 15 | * load and parse if file exists |
| 16 | 16 | */ |
| 17 | -$content = file_get_contents('./examples/dummy.yml');//var_dump($content); |
|
| 17 | +$content = file_get_contents('./examples/dummy.yml'); //var_dump($content); |
|
| 18 | 18 | $yaml = Yaml::parse($content, 0, $debug); |
| 19 | 19 | |
| 20 | -echo memory_get_usage() . "\n"; |
|
| 20 | +echo memory_get_usage()."\n"; |
|
| 21 | 21 | // var_dump($yaml); |
| 22 | 22 | var_dump(json_encode($yaml, JSON_OPTIONS)); |
| 23 | 23 | exit(0); |
@@ -6,17 +6,17 @@ |
||
| 6 | 6 | /** |
| 7 | 7 | * Testing/Debugging Loader |
| 8 | 8 | */ |
| 9 | -const JSON_OPTIONS = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_LINE_TERMINATORS | JSON_UNESCAPED_UNICODE | JSON_PRESERVE_ZERO_FRACTION | JSON_PARTIAL_OUTPUT_ON_ERROR; |
|
| 9 | +const JSON_OPTIONS = JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_LINE_TERMINATORS|JSON_UNESCAPED_UNICODE|JSON_PRESERVE_ZERO_FRACTION|JSON_PARTIAL_OUTPUT_ON_ERROR; |
|
| 10 | 10 | |
| 11 | 11 | $debug = (int) (isset($argv[1]) ? $argv[1] : null); |
| 12 | 12 | $file = (string) (isset($argv[2]) ? $argv[2] : null); |
| 13 | -echo memory_get_usage() . "\n"; |
|
| 13 | +echo memory_get_usage()."\n"; |
|
| 14 | 14 | /* USE CASE 1 |
| 15 | 15 | * load and parse if file exists |
| 16 | 16 | */ |
| 17 | -$content = file_get_contents($file);//var_dump($content); |
|
| 17 | +$content = file_get_contents($file); //var_dump($content); |
|
| 18 | 18 | $yaml = Yaml::parse($content, 0, $debug); |
| 19 | 19 | |
| 20 | -echo memory_get_usage() . "\n"; |
|
| 20 | +echo memory_get_usage()."\n"; |
|
| 21 | 21 | // var_dump($yaml); |
| 22 | 22 | var_dump(json_encode($yaml, JSON_OPTIONS)); |
| 23 | 23 | \ No newline at end of file |