@@ -283,6 +283,7 @@ public function start($id, $clear = false)
283283 *
284284 * @return array
285285 *
286+ * @throws \SebastianBergmann\CodeCoverage\RuntimeException
286287 * @throws InvalidArgumentException
287288 */
288289 public function stop ($ append = true , $ linesToBeCovered = [], array $ linesToBeUsed = [])
@@ -318,6 +319,11 @@ public function stop($append = true, $linesToBeCovered = [], array $linesToBeUse
318319 * @param mixed $linesToBeCovered
319320 * @param array $linesToBeUsed
320321 *
322+ * @throws \SebastianBergmann\CodeCoverage\UnintentionallyCoveredCodeException
323+ * @throws \SebastianBergmann\CodeCoverage\MissingCoversAnnotationException
324+ * @throws \SebastianBergmann\CodeCoverage\CoveredCodeNotExecutedException
325+ * @throws \ReflectionException
326+ * @throws \SebastianBergmann\CodeCoverage\InvalidArgumentException
321327 * @throws RuntimeException
322328 */
323329 public function append (array $ data , $ id = null , $ append = true , $ linesToBeCovered = [], array $ linesToBeUsed = [])
@@ -338,7 +344,7 @@ public function append(array $data, $id = null, $append = true, $linesToBeCovere
338344 return ;
339345 }
340346
341- if ($ id != 'UNCOVERED_FILES_FROM_WHITELIST ' ) {
347+ if ($ id !== 'UNCOVERED_FILES_FROM_WHITELIST ' ) {
342348 $ this ->applyCoversAnnotationFilter (
343349 $ data ,
344350 $ linesToBeCovered ,
@@ -356,11 +362,11 @@ public function append(array $data, $id = null, $append = true, $linesToBeCovere
356362 if ($ id instanceof TestCase) {
357363 $ _size = $ id ->getSize ();
358364
359- if ($ _size == \PHPUnit \Util \Test::SMALL ) {
365+ if ($ _size === \PHPUnit \Util \Test::SMALL ) {
360366 $ size = 'small ' ;
361- } elseif ($ _size == \PHPUnit \Util \Test::MEDIUM ) {
367+ } elseif ($ _size === \PHPUnit \Util \Test::MEDIUM ) {
362368 $ size = 'medium ' ;
363- } elseif ($ _size == \PHPUnit \Util \Test::LARGE ) {
369+ } elseif ($ _size === \PHPUnit \Util \Test::LARGE ) {
364370 $ size = 'large ' ;
365371 }
366372
@@ -379,7 +385,7 @@ public function append(array $data, $id = null, $append = true, $linesToBeCovere
379385 }
380386
381387 foreach ($ lines as $ k => $ v ) {
382- if ($ v == Driver::LINE_EXECUTED ) {
388+ if ($ v === Driver::LINE_EXECUTED ) {
383389 if (empty ($ this ->data [$ file ][$ k ]) || !\in_array ($ id , $ this ->data [$ file ][$ k ])) {
384390 $ this ->data [$ file ][$ k ][] = $ id ;
385391 }
@@ -614,6 +620,8 @@ public function setUnintentionallyCoveredSubclassesWhitelist(array $whitelist)
614620 * @param mixed $linesToBeCovered
615621 * @param array $linesToBeUsed
616622 *
623+ * @throws \SebastianBergmann\CodeCoverage\CoveredCodeNotExecutedException
624+ * @throws \ReflectionException
617625 * @throws MissingCoversAnnotationException
618626 * @throws UnintentionallyCoveredCodeException
619627 */
@@ -637,11 +645,7 @@ private function applyCoversAnnotationFilter(array &$data, $linesToBeCovered, ar
637645 if ($ this ->checkForUnintentionallyCoveredCode &&
638646 (!$ this ->currentId instanceof TestCase ||
639647 (!$ this ->currentId ->isMedium () && !$ this ->currentId ->isLarge ()))) {
640- $ this ->performUnintentionallyCoveredCodeCheck (
641- $ data ,
642- $ linesToBeCovered ,
643- $ linesToBeUsed
644- );
648+ $ this ->performUnintentionallyCoveredCodeCheck ($ data , $ linesToBeCovered , $ linesToBeUsed );
645649 }
646650
647651 if ($ this ->checkForUnexecutedCoveredCode ) {
@@ -652,11 +656,7 @@ private function applyCoversAnnotationFilter(array &$data, $linesToBeCovered, ar
652656
653657 foreach (\array_keys ($ data ) as $ filename ) {
654658 $ _linesToBeCovered = \array_flip ($ linesToBeCovered [$ filename ]);
655-
656- $ data [$ filename ] = \array_intersect_key (
657- $ data [$ filename ],
658- $ _linesToBeCovered
659- );
659+ $ data [$ filename ] = \array_intersect_key ($ data [$ filename ], $ _linesToBeCovered );
660660 }
661661 }
662662
@@ -678,6 +678,8 @@ private function applyListsFilter(array &$data)
678678 * Applies the "ignored lines" filtering.
679679 *
680680 * @param array $data
681+ *
682+ * @throws \SebastianBergmann\CodeCoverage\InvalidArgumentException
681683 */
682684 private function applyIgnoredLinesFilter (array &$ data )
683685 {
@@ -698,11 +700,11 @@ private function applyIgnoredLinesFilter(array &$data)
698700 private function initializeFilesThatAreSeenTheFirstTime (array $ data )
699701 {
700702 foreach ($ data as $ file => $ lines ) {
701- if ($ this ->filter -> isFile ( $ file ) && ! isset ( $ this ->data [ $ file] )) {
703+ if (! isset ( $ this ->data [ $ file] ) && $ this ->filter -> isFile ( $ file )) {
702704 $ this ->data [$ file ] = [];
703705
704706 foreach ($ lines as $ k => $ v ) {
705- $ this ->data [$ file ][$ k ] = $ v == -2 ? null : [];
707+ $ this ->data [$ file ][$ k ] = $ v === -2 ? null : [];
706708 }
707709 }
708710 }
@@ -790,15 +792,15 @@ private function getLinesToBeIgnored($filename)
790792 $ _token = \trim ($ token );
791793 $ _line = \trim ($ lines [$ token ->getLine () - 1 ]);
792794
793- if ($ _token == '// @codeCoverageIgnore ' ||
794- $ _token == '//@codeCoverageIgnore ' ) {
795+ if ($ _token === '// @codeCoverageIgnore ' ||
796+ $ _token === '//@codeCoverageIgnore ' ) {
795797 $ ignore = true ;
796798 $ stop = true ;
797- } elseif ($ _token == '// @codeCoverageIgnoreStart ' ||
798- $ _token == '//@codeCoverageIgnoreStart ' ) {
799+ } elseif ($ _token === '// @codeCoverageIgnoreStart ' ||
800+ $ _token === '//@codeCoverageIgnoreStart ' ) {
799801 $ ignore = true ;
800- } elseif ($ _token == '// @codeCoverageIgnoreEnd ' ||
801- $ _token == '//@codeCoverageIgnoreEnd ' ) {
802+ } elseif ($ _token === '// @codeCoverageIgnoreEnd ' ||
803+ $ _token === '//@codeCoverageIgnoreEnd ' ) {
802804 $ stop = true ;
803805 }
804806
@@ -845,9 +847,7 @@ private function getLinesToBeIgnored($filename)
845847 $ token instanceof \PHP_Token_TRAIT ||
846848 $ token instanceof \PHP_Token_CLASS) {
847849 if (empty ($ classes [$ token ->getName ()]['methods ' ])) {
848- for ($ i = $ token ->getLine ();
849- $ i <= $ token ->getEndLine ();
850- $ i ++) {
850+ for ($ i = $ token ->getLine (); $ i <= $ token ->getEndLine (); $ i ++) {
851851 $ this ->ignoredLines [$ filename ][] = $ i ;
852852 }
853853 } else {
@@ -859,22 +859,17 @@ private function getLinesToBeIgnored($filename)
859859 $ lastMethod = \array_pop (
860860 $ classes [$ token ->getName ()]['methods ' ]
861861 );
862- } while ($ lastMethod !== null &&
863- \substr ($ lastMethod ['signature ' ], 0 , 18 ) == 'anonymous function ' );
862+ } while ($ lastMethod !== null && 0 === \strpos ($ lastMethod ['signature ' ], 'anonymous function ' ));
864863
865864 if ($ lastMethod === null ) {
866865 $ lastMethod = $ firstMethod ;
867866 }
868867
869- for ($ i = $ token ->getLine ();
870- $ i < $ firstMethod ['startLine ' ];
871- $ i ++) {
868+ for ($ i = $ token ->getLine (); $ i < $ firstMethod ['startLine ' ]; $ i ++) {
872869 $ this ->ignoredLines [$ filename ][] = $ i ;
873870 }
874871
875- for ($ i = $ token ->getEndLine ();
876- $ i > $ lastMethod ['endLine ' ];
877- $ i --) {
872+ for ($ i = $ token ->getEndLine (); $ i > $ lastMethod ['endLine ' ]; $ i --) {
878873 $ this ->ignoredLines [$ filename ][] = $ i ;
879874 }
880875 }
@@ -927,6 +922,7 @@ private function getLinesToBeIgnored($filename)
927922 * @param array $linesToBeCovered
928923 * @param array $linesToBeUsed
929924 *
925+ * @throws \ReflectionException
930926 * @throws UnintentionallyCoveredCodeException
931927 */
932928 private function performUnintentionallyCoveredCodeCheck (array &$ data , array $ linesToBeCovered , array $ linesToBeUsed )
@@ -940,7 +936,7 @@ private function performUnintentionallyCoveredCodeCheck(array &$data, array $lin
940936
941937 foreach ($ data as $ file => $ _data ) {
942938 foreach ($ _data as $ line => $ flag ) {
943- if ($ flag == 1 && !isset ($ allowedLines [$ file ][$ line ])) {
939+ if ($ flag === 1 && !isset ($ allowedLines [$ file ][$ line ])) {
944940 $ unintentionallyCoveredUnits [] = $ this ->wizard ->lookup ($ file , $ line );
945941 }
946942 }
@@ -1046,17 +1042,21 @@ private function selectDriver()
10461042
10471043 if ($ runtime ->isHHVM ()) {
10481044 return new HHVM ;
1049- } elseif ($ runtime ->isPHPDBG ()) {
1045+ }
1046+
1047+ if ($ runtime ->isPHPDBG ()) {
10501048 return new PHPDBG ;
1051- } else {
1052- return new Xdebug ;
10531049 }
1050+
1051+ return new Xdebug ;
10541052 }
10551053
10561054 /**
10571055 * @param array $unintentionallyCoveredUnits
10581056 *
10591057 * @return array
1058+ *
1059+ * @throws \ReflectionException
10601060 */
10611061 private function processUnintentionallyCoveredUnits (array $ unintentionallyCoveredUnits )
10621062 {
@@ -1066,7 +1066,7 @@ private function processUnintentionallyCoveredUnits(array $unintentionallyCovere
10661066 foreach (\array_keys ($ unintentionallyCoveredUnits ) as $ k => $ v ) {
10671067 $ unit = \explode (':: ' , $ unintentionallyCoveredUnits [$ k ]);
10681068
1069- if (\count ($ unit ) != 2 ) {
1069+ if (\count ($ unit ) !== 2 ) {
10701070 continue ;
10711071 }
10721072
@@ -1087,6 +1087,8 @@ private function processUnintentionallyCoveredUnits(array $unintentionallyCovere
10871087 /**
10881088 * If we are processing uncovered files from whitelist,
10891089 * we can initialize the data before we start to speed up the tests
1090+ *
1091+ * @throws \SebastianBergmann\CodeCoverage\RuntimeException
10901092 */
10911093 protected function initializeData ()
10921094 {
@@ -1112,7 +1114,7 @@ protected function initializeData()
11121114 }
11131115
11141116 foreach (\array_keys ($ fileCoverage ) as $ key ) {
1115- if ($ fileCoverage [$ key ] == Driver::LINE_EXECUTED ) {
1117+ if ($ fileCoverage [$ key ] === Driver::LINE_EXECUTED ) {
11161118 $ fileCoverage [$ key ] = Driver::LINE_NOT_EXECUTED ;
11171119 }
11181120 }
@@ -1135,7 +1137,7 @@ private function coverageToCodeUnits(array $data)
11351137
11361138 foreach ($ data as $ filename => $ lines ) {
11371139 foreach ($ lines as $ line => $ flag ) {
1138- if ($ flag == 1 ) {
1140+ if ($ flag === 1 ) {
11391141 $ codeUnits [] = $ this ->wizard ->lookup ($ filename , $ line );
11401142 }
11411143 }
0 commit comments