@@ -101,7 +101,7 @@ public function clean(string $contents, int $maxMatches): string
101
101
continue ;
102
102
}
103
103
104
- if ($ char === '< ' && $ this ->peek ('< ' ) && $ this ->match ('{<<<[ \t]*+([ \'"]?)([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*+) \\1(?:\r\n|\n|\r)}A ' , $ match )) {
104
+ if ($ char === '< ' && $ this ->peek ('< ' ) && $ this ->match ('{<<<[ \t]*+([ \'"]?)([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*+) \\1(?:\r\n|\n|\r)}A ' , $ match ) && $ match !== null ) {
105
105
$ this ->index += strlen ($ match [0 ]);
106
106
$ this ->skipHeredoc ($ match [2 ]);
107
107
$ clean .= 'null ' ;
@@ -123,14 +123,15 @@ public function clean(string $contents, int $maxMatches): string
123
123
$ inType
124
124
&& $ char === 'c '
125
125
&& $ this ->match ('~.\b(?<![\$:>])const(\s++[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff\-]*+)~Ais ' , $ match , $ this ->index - 1 )
126
+ && $ match !== null
126
127
) {
127
128
// It's invalid PHP but it does not matter
128
129
$ clean .= 'class_const ' . $ match [1 ];
129
130
$ this ->index += strlen ($ match [0 ]) - 1 ;
130
131
continue ;
131
132
}
132
133
133
- if ($ char === 'd ' && $ this ->match ('~.\b(?<![\$:>])define\s*+\(~Ais ' , $ match , $ this ->index - 1 )) {
134
+ if ($ char === 'd ' && $ this ->match ('~.\b(?<![\$:>])define\s*+\(~Ais ' , $ match , $ this ->index - 1 ) && $ match !== null ) {
134
135
$ inDefine = true ;
135
136
$ clean .= $ match [0 ];
136
137
$ this ->index += strlen ($ match [0 ]) - 1 ;
@@ -141,7 +142,7 @@ public function clean(string $contents, int $maxMatches): string
141
142
$ type = $ this ->typeConfig [$ char ];
142
143
143
144
if (substr ($ this ->contents , $ this ->index , $ type ['length ' ]) === $ type ['name ' ]) {
144
- if ($ maxMatches === 1 && $ this ->match ($ type ['pattern ' ], $ match , $ this ->index - 1 )) {
145
+ if ($ maxMatches === 1 && $ this ->match ($ type ['pattern ' ], $ match , $ this ->index - 1 ) && $ match !== null ) {
145
146
return $ clean . $ match [0 ];
146
147
}
147
148
@@ -150,7 +151,7 @@ public function clean(string $contents, int $maxMatches): string
150
151
}
151
152
152
153
$ this ->index += 1 ;
153
- if ($ this ->match ($ this ->restPattern , $ match )) {
154
+ if ($ this ->match ($ this ->restPattern , $ match ) && $ match !== null ) {
154
155
$ clean .= $ char . $ match [0 ];
155
156
$ this ->index += strlen ($ match [0 ]);
156
157
} else {
0 commit comments