File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 1- /vendor /
1+ /vendor /
2+ .idea /
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public static function parse_simple($value)
4040 {
4141 $ tokens = new tokens ($ value );
4242 $ parser = new parser ($ tokens );
43- $ result = $ parser ->parse_array ();
43+ $ result = $ parser ->parse_array ($ tokens -> does_match ( ' [ ' ) );
4444
4545 return $ result ;
4646 }
Original file line number Diff line number Diff line change @@ -47,6 +47,28 @@ public function testCanParseSimpleString()
4747 $ this ->assertArraySubset ($ expected_simple_output , $ result );
4848 }
4949
50+ /**
51+ * Test starting arrays with a short syntax
52+ * Discovered by qg0 at https://github.com/battye/php-array-parser/issues/1
53+ */
54+ public function testParseStringStartingWithShortSyntax ()
55+ {
56+ // Start with a square bracket
57+ $ string = "[0 => array('one' => 1, 'two' => 'two', 3 => [1])]; " ;
58+ $ result = parser::parse_simple ($ string );
59+
60+ // Expected output
61+ $ expected_simple_output = array (
62+ 0 => array (
63+ 'one ' => 1 ,
64+ 'two ' => 'two ' ,
65+ 3 => array (1 ),
66+ )
67+ );
68+
69+ $ this ->assertArraySubset ($ expected_simple_output , $ result );
70+ }
71+
5072 /**
5173 * Test that variables can be picked up
5274 */
You can’t perform that action at this time.
0 commit comments