@@ -147,11 +147,14 @@ public function start(string $id, TestSize $size = null, bool $clear = false): v
147147 $ this ->driver ->start ();
148148 }
149149
150- public function stop (bool $ append = true , TestStatus $ status = null , array |false $ linesToBeCovered = [], array $ linesToBeUsed = []): RawCodeCoverageData
150+ /**
151+ * @psalm-param array<string,list<int>> $linesToBeIgnored
152+ */
153+ public function stop (bool $ append = true , TestStatus $ status = null , array |false $ linesToBeCovered = [], array $ linesToBeUsed = [], array $ linesToBeIgnored = []): RawCodeCoverageData
151154 {
152155 $ data = $ this ->driver ->stop ();
153156
154- $ this ->append ($ data , null , $ append , $ status , $ linesToBeCovered , $ linesToBeUsed );
157+ $ this ->append ($ data , null , $ append , $ status , $ linesToBeCovered , $ linesToBeUsed, $ linesToBeIgnored );
155158
156159 $ this ->currentId = null ;
157160 $ this ->currentSize = null ;
@@ -160,11 +163,13 @@ public function stop(bool $append = true, TestStatus $status = null, array|false
160163 }
161164
162165 /**
166+ * @psalm-param array<string,list<int>> $linesToBeIgnored
167+ *
163168 * @throws ReflectionException
164169 * @throws TestIdMissingException
165170 * @throws UnintentionallyCoveredCodeException
166171 */
167- public function append (RawCodeCoverageData $ rawData , string $ id = null , bool $ append = true , TestStatus $ status = null , array |false $ linesToBeCovered = [], array $ linesToBeUsed = []): void
172+ public function append (RawCodeCoverageData $ rawData , string $ id = null , bool $ append = true , TestStatus $ status = null , array |false $ linesToBeCovered = [], array $ linesToBeUsed = [], array $ linesToBeIgnored = [] ): void
168173 {
169174 if ($ id === null ) {
170175 $ id = $ this ->currentId ;
@@ -189,7 +194,7 @@ public function append(RawCodeCoverageData $rawData, string $id = null, bool $ap
189194 $ this ->applyExecutableLinesFilter ($ rawData );
190195
191196 if ($ this ->useAnnotationsForIgnoringCode ) {
192- $ this ->applyIgnoredLinesFilter ($ rawData );
197+ $ this ->applyIgnoredLinesFilter ($ rawData, $ linesToBeIgnored );
193198 }
194199
195200 $ this ->data ->initializeUnseenData ($ rawData );
@@ -402,13 +407,23 @@ private function applyExecutableLinesFilter(RawCodeCoverageData $data): void
402407 }
403408 }
404409
405- private function applyIgnoredLinesFilter (RawCodeCoverageData $ data ): void
410+ /**
411+ * @psalm-param array<string,list<int>> $linesToBeIgnored
412+ */
413+ private function applyIgnoredLinesFilter (RawCodeCoverageData $ data , array $ linesToBeIgnored ): void
406414 {
407415 foreach (array_keys ($ data ->lineCoverage ()) as $ filename ) {
408416 if (!$ this ->filter ->isFile ($ filename )) {
409417 continue ;
410418 }
411419
420+ if (isset ($ linesToBeIgnored [$ filename ])) {
421+ $ data ->removeCoverageDataForLines (
422+ $ filename ,
423+ $ linesToBeIgnored [$ filename ]
424+ );
425+ }
426+
412427 $ data ->removeCoverageDataForLines (
413428 $ filename ,
414429 $ this ->analyser ()->ignoredLinesFor ($ filename )
0 commit comments