@@ -510,21 +510,34 @@ public function start($contents=null)
510
510
// Remove errors and warnings for ignored lines.
511
511
foreach ($ this ->_ignoredLines as $ line => $ ignore ) {
512
512
if (isset ($ this ->_errors [$ line ]) === true ) {
513
- foreach ($ this ->_errors [$ line ] as $ col => $ errors ) {
514
- $ this ->_errorCount -= count ($ errors );
513
+ if ($ this ->_recordErrors === false ) {
514
+ $ this ->_errorCount -= $ this ->_errors [$ line ];
515
+ } else {
516
+ foreach ($ this ->_errors [$ line ] as $ col => $ errors ) {
517
+ $ this ->_errorCount -= count ($ errors );
518
+ }
515
519
}
516
520
517
521
unset($ this ->_errors [$ line ]);
518
522
}
519
523
520
524
if (isset ($ this ->_warnings [$ line ]) === true ) {
521
- foreach ($ this ->_warnings [$ line ] as $ col => $ warnings ) {
522
- $ this ->_warningCount -= count ($ warnings );
525
+ if ($ this ->_recordErrors === false ) {
526
+ $ this ->_errorCount -= $ this ->_warnings [$ line ];
527
+ } else {
528
+ foreach ($ this ->_warnings [$ line ] as $ col => $ warnings ) {
529
+ $ this ->_warningCount -= count ($ warnings );
530
+ }
523
531
}
524
532
525
533
unset($ this ->_warnings [$ line ]);
526
534
}
527
535
}
536
+
537
+ if ($ this ->_recordErrors === false ) {
538
+ $ this ->_errors = array ();
539
+ $ this ->_warnings = array ();
540
+ }
528
541
529
542
// If short open tags are off but the file being checked uses
530
543
// short open tags, the whole content will be inline HTML
@@ -768,8 +781,20 @@ public function addError($error, $stackPtr, $code='', $data=array(), $severity=0
768
781
}
769
782
}
770
783
784
+ if ($ stackPtr === null ) {
785
+ $ lineNum = 1 ;
786
+ $ column = 1 ;
787
+ } else {
788
+ $ lineNum = $ this ->_tokens [$ stackPtr ]['line ' ];
789
+ $ column = $ this ->_tokens [$ stackPtr ]['column ' ];
790
+ }
791
+
771
792
$ this ->_errorCount ++;
772
793
if ($ this ->_recordErrors === false ) {
794
+ if (isset ($ this ->_errors [$ lineNum ]) === false ) {
795
+ $ this ->_errors [$ lineNum ] = 0 ;
796
+ }
797
+ $ this ->_errors [$ lineNum ]++;
773
798
return ;
774
799
}
775
800
@@ -784,14 +809,6 @@ public function addError($error, $stackPtr, $code='', $data=array(), $severity=0
784
809
$ message = vsprintf ($ error , $ data );
785
810
}
786
811
787
- if ($ stackPtr === null ) {
788
- $ lineNum = 1 ;
789
- $ column = 1 ;
790
- } else {
791
- $ lineNum = $ this ->_tokens [$ stackPtr ]['line ' ];
792
- $ column = $ this ->_tokens [$ stackPtr ]['column ' ];
793
- }
794
-
795
812
if (isset ($ this ->_errors [$ lineNum ]) === false ) {
796
813
$ this ->_errors [$ lineNum ] = array ();
797
814
}
@@ -885,8 +902,20 @@ public function addWarning($warning, $stackPtr, $code='', $data=array(), $severi
885
902
}
886
903
}
887
904
905
+ if ($ stackPtr === null ) {
906
+ $ lineNum = 1 ;
907
+ $ column = 1 ;
908
+ } else {
909
+ $ lineNum = $ this ->_tokens [$ stackPtr ]['line ' ];
910
+ $ column = $ this ->_tokens [$ stackPtr ]['column ' ];
911
+ }
912
+
888
913
$ this ->_warningCount ++;
889
914
if ($ this ->_recordErrors === false ) {
915
+ if (isset ($ this ->_warnings [$ lineNum ]) === false ) {
916
+ $ this ->_warnings [$ lineNum ] = 0 ;
917
+ }
918
+ $ this ->_warnings [$ lineNum ]++;
890
919
return ;
891
920
}
892
921
@@ -901,14 +930,6 @@ public function addWarning($warning, $stackPtr, $code='', $data=array(), $severi
901
930
$ message = vsprintf ($ warning , $ data );
902
931
}
903
932
904
- if ($ stackPtr === null ) {
905
- $ lineNum = 1 ;
906
- $ column = 1 ;
907
- } else {
908
- $ lineNum = $ this ->_tokens [$ stackPtr ]['line ' ];
909
- $ column = $ this ->_tokens [$ stackPtr ]['column ' ];
910
- }
911
-
912
933
if (isset ($ this ->_warnings [$ lineNum ]) === false ) {
913
934
$ this ->_warnings [$ lineNum ] = array ();
914
935
}
0 commit comments