File tree 2 files changed +6
-5
lines changed
2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 15
15
16
16
error_reporting (E_ALL );
17
17
18
- $ VERSION = '1.2.0 ' ;
18
+ $ VERSION = '1.3.0-dev ' ;
19
19
20
20
/**
21
21
* BEWARE:
Original file line number Diff line number Diff line change @@ -21,15 +21,16 @@ function php_strip_whitespace($file): string
21
21
{
22
22
$ lines = file ($ file , FILE_IGNORE_NEW_LINES );
23
23
24
- // First pass, process inline comments
25
- // We need to rely on the LF chars here
24
+ // First pass, one-line comments
25
+ // Processing is easier using a per-line approach
26
26
$ lines = array_map (function ($ line ) {
27
- if (preg_match ('!^// .*$! ' , $ line )) {
27
+ if (preg_match ('!^(//|#[^\[]) .*$! ' , $ line )) {
28
28
return null ;
29
29
}
30
30
// Prevent processing non-comment lines (eg: containing php:// or http:// uris)
31
31
// to be mistakenly treated as such
32
- return preg_replace ('!\s//.*$! ' , '' , $ line );
32
+ return preg_replace ('!\s(//|#[^\[]).*$! ' , '' , $ line );
33
+ //return preg_replace('!([^:])' . '(//|#[^\[])' . '.*$!', '$1', $line);
33
34
}, $ lines );
34
35
35
36
// Second pass: multi-line comments
You can’t perform that action at this time.
0 commit comments