Skip to content

Commit 0ff1ff7

Browse files
committed
Fix PHPStan errors.
1 parent 2fd392d commit 0ff1ff7

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

spec/drupol/phptree/Node/ValueNodeSpec.php

+12-16
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace spec\drupol\phptree\Node;
66

7-
use drupol\phptree\Node\Node;
87
use drupol\phptree\Node\ValueNode;
98

109
class ValueNodeSpec extends NodeObjectBehavior
@@ -76,20 +75,6 @@ public function it_can_have_children()
7675
$this->shouldHaveSameGraph($tree);
7776
}
7877

79-
public function it_is_initializable()
80-
{
81-
$this
82-
->beConstructedWith('root');
83-
84-
$this->shouldHaveType(ValueNode::class);
85-
86-
$this->children()->shouldYield(new \ArrayIterator([]));
87-
88-
$export = '[root]';
89-
$this->shouldHaveSameTextExport($export);
90-
}
91-
92-
9378
public function it_can_remove()
9479
{
9580
$this
@@ -104,7 +89,6 @@ public function it_can_remove()
10489

10590
$this->shouldHaveSameTextExport('[root [A] [B]]');
10691

107-
10892
$this
10993
->remove($node2);
11094

@@ -125,4 +109,16 @@ public function it_can_remove()
125109
->shouldReturn(0);
126110
}
127111

112+
public function it_is_initializable()
113+
{
114+
$this
115+
->beConstructedWith('root');
116+
117+
$this->shouldHaveType(ValueNode::class);
118+
119+
$this->children()->shouldYield(new \ArrayIterator([]));
120+
121+
$export = '[root]';
122+
$this->shouldHaveSameTextExport($export);
123+
}
128124
}

src/Importer/Text.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ private function parse(string $subject)
5555

5656
\preg_match_all('~[^\[\]]+|\[(?<nested>(?R)*)\]~', $subject, $matches);
5757

58-
foreach (\array_filter($matches['nested']) as $match) {
58+
if (null === $matches = \array_filter($matches['nested'])) {
59+
$matches = [];
60+
}
61+
62+
foreach ($matches as $match) {
5963
$item = [];
6064
$position = \strpos($match, '[');
6165

0 commit comments

Comments
 (0)