Skip to content

Commit 16129ac

Browse files
Merge pull request #73 from wgevaert/5.0.0-typing-and-consistency
Check if map is empty before adding to node
2 parents 149f383 + 61e0793 commit 16129ac

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/Expressions/Literals/List_.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ public function getExpressions(): array
7171
return $this->expressions;
7272
}
7373

74+
/**
75+
* Returns whether this list is empty.
76+
*
77+
* @return bool
78+
*/
79+
public function isEmpty(): bool
80+
{
81+
return empty($this->expressions);
82+
}
83+
7484
/**
7585
* @inheritDoc
7686
*/

src/Expressions/Literals/Map.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ public function getElements(): array
8888
return $this->elements;
8989
}
9090

91+
/**
92+
* Checks if this map is empty
93+
*
94+
* @return bool
95+
*/
96+
public function isEmpty(): bool
97+
{
98+
return empty($this->elements);
99+
}
100+
91101
/**
92102
* @inheritDoc
93103
*/

src/Patterns/Node.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private function nodeInnerToString(): string
150150
}
151151
}
152152

153-
if (isset($this->properties)) {
153+
if (isset($this->properties) && !$this->properties->isEmpty()) {
154154
if ($nodeInner !== "") {
155155
$nodeInner .= " ";
156156
}

0 commit comments

Comments
 (0)