@@ -22,14 +22,14 @@ public function __construct( WP_Parser_Grammar $grammar, array $tokens ) {
22
22
public function parse () {
23
23
// @TODO: Make the starting rule lookup non-grammar-specific.
24
24
$ query_rule_id = $ this ->grammar ->get_rule_id ( 'query ' );
25
- return $ this ->parse_recursive ( $ query_rule_id );
25
+ return $ this ->parse_recursive ( $ query_rule_id ) ?: null ;
26
26
}
27
27
28
28
private function parse_recursive ( $ rule_id ) {
29
29
$ is_terminal = $ rule_id <= $ this ->grammar ->highest_terminal_id ;
30
30
if ( $ is_terminal ) {
31
31
if ( $ this ->position >= count ( $ this ->tokens ) ) {
32
- return null ;
32
+ return false ;
33
33
}
34
34
35
35
if ( WP_Parser_Grammar::EMPTY_RULE_ID === $ rule_id ) {
@@ -40,12 +40,12 @@ private function parse_recursive( $rule_id ) {
40
40
++$ this ->position ;
41
41
return $ this ->tokens [ $ this ->position - 1 ];
42
42
}
43
- return null ;
43
+ return false ;
44
44
}
45
45
46
46
$ branches = $ this ->grammar ->rules [ $ rule_id ];
47
47
if ( ! count ( $ branches ) ) {
48
- return null ;
48
+ return false ;
49
49
}
50
50
51
51
// Bale out from processing the current branch if none of its rules can
@@ -56,7 +56,7 @@ private function parse_recursive( $rule_id ) {
56
56
! isset ( $ this ->grammar ->lookahead_is_match_possible [ $ rule_id ][ $ token_id ] ) &&
57
57
! isset ( $ this ->grammar ->lookahead_is_match_possible [ $ rule_id ][ WP_Parser_Grammar::EMPTY_RULE_ID ] )
58
58
) {
59
- return null ;
59
+ return false ;
60
60
}
61
61
}
62
62
@@ -68,7 +68,7 @@ private function parse_recursive( $rule_id ) {
68
68
$ branch_matches = true ;
69
69
foreach ( $ branch as $ subrule_id ) {
70
70
$ subnode = $ this ->parse_recursive ( $ subrule_id );
71
- if ( null === $ subnode ) {
71
+ if ( false === $ subnode ) {
72
72
$ branch_matches = false ;
73
73
break ;
74
74
} elseif ( true === $ subnode ) {
@@ -111,7 +111,7 @@ private function parse_recursive( $rule_id ) {
111
111
112
112
if ( ! $ branch_matches ) {
113
113
$ this ->position = $ starting_position ;
114
- return null ;
114
+ return false ;
115
115
}
116
116
117
117
if ( 0 === count ( $ node ->children ) ) {
0 commit comments