@@ -35,7 +35,7 @@ |
||
35 | 35 | */ |
36 | 36 | public function __set(string $name, $value) |
37 | 37 | { |
38 | - if (! isset($this->properties[$name])) { |
|
38 | + if (!isset($this->properties[$name])) { |
|
39 | 39 | $this->properties[$name] = $value; |
40 | 40 | } else { |
41 | 41 | if (is_array($this->properties[$name])) { |
@@ -28,7 +28,7 @@ |
||
28 | 28 | $this->path = $path; |
29 | 29 | |
30 | 30 | clearstatcache(); |
31 | - if (! file_exists($path)) { |
|
31 | + if (!file_exists($path)) { |
|
32 | 32 | touch($path); |
33 | 33 | } else { |
34 | 34 | $this->values = (array)json_decode(file_get_contents($path)); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | private string $tagsPattern = '/@([a-z]+[a-z0-9_]*)(.*)\s{1,}/i'; |
22 | 22 | |
23 | - /** |
|
23 | + /** |
|
24 | 24 | * The regexp pattern to identify numbers, integer or double. |
25 | 25 | * @var string |
26 | 26 | */ |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * AnnotationParser constructor. |
34 | 34 | */ |
35 | - public function __construct() |
|
35 | + public function __construct() |
|
36 | 36 | { |
37 | 37 | $this->initializeAnnotationParsed(); |
38 | 38 | } |
@@ -51,22 +51,22 @@ discard block |
||
51 | 51 | * @param string $docBlock |
52 | 52 | * @return ParsedAnnotation |
53 | 53 | */ |
54 | - public function parse(string $docBlock) : ParsedAnnotation |
|
54 | + public function parse(string $docBlock) : ParsedAnnotation |
|
55 | 55 | { |
56 | 56 | // Have to initialize every parse to clean the previous parsed values, to not "add" values that don't exist. |
57 | 57 | $this->initializeAnnotationParsed(); |
58 | 58 | |
59 | 59 | // Separate the annotations tags (position 1) and it's values (position 2) |
60 | - $matches = []; |
|
61 | - preg_match_all($this->tagsPattern, $docBlock, $matches); |
|
60 | + $matches = []; |
|
61 | + preg_match_all($this->tagsPattern, $docBlock, $matches); |
|
62 | 62 | |
63 | - // Iterate then and parse each one |
|
64 | - foreach ($matches[1] as $key => $value) { |
|
65 | - $this->annotationParsed->{$value} = $this->parseAnnotationValue(trim($matches[2][$key])); |
|
66 | - } |
|
63 | + // Iterate then and parse each one |
|
64 | + foreach ($matches[1] as $key => $value) { |
|
65 | + $this->annotationParsed->{$value} = $this->parseAnnotationValue(trim($matches[2][$key])); |
|
66 | + } |
|
67 | 67 | |
68 | - return $this->annotationParsed; |
|
69 | - } |
|
68 | + return $this->annotationParsed; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * The method that effectively parse the annotation values. |
@@ -74,30 +74,30 @@ discard block |
||
74 | 74 | * @param string $value |
75 | 75 | * @return bool|string|double|array|object|null |
76 | 76 | */ |
77 | - private function parseAnnotationValue(string $value = '') |
|
77 | + private function parseAnnotationValue(string $value = '') |
|
78 | 78 | { |
79 | 79 | // The annotation just exists (true value) |
80 | 80 | if (empty($value)) { |
81 | 81 | return true; |
82 | 82 | } |
83 | 83 | |
84 | - $firstLetter = $value[0]; |
|
85 | - $lastLetter = StringManipulator::getLastLetter($value); |
|
84 | + $firstLetter = $value[0]; |
|
85 | + $lastLetter = StringManipulator::getLastLetter($value); |
|
86 | 86 | |
87 | - if ($firstLetter === '[' && $lastLetter === ']') { // ARRAY |
|
87 | + if ($firstLetter === '[' && $lastLetter === ']') { // ARRAY |
|
88 | 88 | $value = $this->parseArray($value); |
89 | - } elseif ($firstLetter === '{' && $lastLetter === '}') { // JSON / OBJECT |
|
89 | + } elseif ($firstLetter === '{' && $lastLetter === '}') { // JSON / OBJECT |
|
90 | 90 | $value = $this->parseJson($value); |
91 | - } else { |
|
92 | - if (preg_match($this->numberPattern, $value)) { // NUMERIC |
|
93 | - $value = $this->parseNumeric($value); |
|
94 | - } else { // BOOL, NULL and STRING |
|
95 | - $value = $this->parseBoolNullAndString($value); |
|
96 | - } |
|
97 | - } |
|
91 | + } else { |
|
92 | + if (preg_match($this->numberPattern, $value)) { // NUMERIC |
|
93 | + $value = $this->parseNumeric($value); |
|
94 | + } else { // BOOL, NULL and STRING |
|
95 | + $value = $this->parseBoolNullAndString($value); |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | - return $value; |
|
100 | - } |
|
99 | + return $value; |
|
100 | + } |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * Parse a string representation of an one dimensional array into an array. |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param string $value |
106 | 106 | * @return array |
107 | 107 | */ |
108 | - private function parseArray(string $value) : array |
|
108 | + private function parseArray(string $value) : array |
|
109 | 109 | { |
110 | 110 | // Mount the array |
111 | 111 | $value = explode(',', Sanitizer::removeFirstAndLastCharacters($value)); |