File tree 2 files changed +17
-17
lines changed
2 files changed +17
-17
lines changed Original file line number Diff line number Diff line change 4
4
5
5
namespace spec \drupol \phptree \Node ;
6
6
7
- use drupol \phptree \Node \Node ;
8
7
use drupol \phptree \Node \ValueNode ;
9
8
10
9
class ValueNodeSpec extends NodeObjectBehavior
@@ -76,20 +75,6 @@ public function it_can_have_children()
76
75
$ this ->shouldHaveSameGraph ($ tree );
77
76
}
78
77
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
-
93
78
public function it_can_remove ()
94
79
{
95
80
$ this
@@ -104,7 +89,6 @@ public function it_can_remove()
104
89
105
90
$ this ->shouldHaveSameTextExport ('[root [A] [B]] ' );
106
91
107
-
108
92
$ this
109
93
->remove ($ node2 );
110
94
@@ -125,4 +109,16 @@ public function it_can_remove()
125
109
->shouldReturn (0 );
126
110
}
127
111
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
+ }
128
124
}
Original file line number Diff line number Diff line change @@ -55,7 +55,11 @@ private function parse(string $subject)
55
55
56
56
\preg_match_all ('~[^\[\]]+|\[(?<nested>(?R)*)\]~ ' , $ subject , $ matches );
57
57
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 ) {
59
63
$ item = [];
60
64
$ position = \strpos ($ match , '[ ' );
61
65
You can’t perform that action at this time.
0 commit comments