@@ -80,11 +80,6 @@ class PHP_CodeCoverage
80
80
*/
81
81
private $ ignoredLines = array ();
82
82
83
- /**
84
- * @var bool
85
- */
86
- private $ disableIgnoredLines = false ;
87
-
88
83
/**
89
84
* Test data.
90
85
*
@@ -104,11 +99,13 @@ public function __construct(PHP_CodeCoverage_Driver $driver = null, PHP_CodeCove
104
99
if ($ driver === null ) {
105
100
$ runtime = new Runtime ;
106
101
107
- if (!$ runtime ->hasXdebug ()) {
102
+ if ($ runtime ->isHHVM ()) {
103
+ $ driver = new PHP_CodeCoverage_Driver_HHVM ;
104
+ } elseif ($ runtime ->hasXdebug ()) {
105
+ $ driver = new PHP_CodeCoverage_Driver_Xdebug ;
106
+ } else {
108
107
throw new PHP_CodeCoverage_Exception ('No code coverage driver available ' );
109
108
}
110
-
111
- $ driver = new PHP_CodeCoverage_Driver_Xdebug ;
112
109
}
113
110
114
111
if ($ filter === null ) {
@@ -231,9 +228,35 @@ public function start($id, $clear = false)
231
228
232
229
$ this ->currentId = $ id ;
233
230
234
- $ this ->driver ->start ();
231
+ $ this ->driver ->start_new ();
235
232
}
233
+
234
+ /**
235
+ * Start collection of code coverage information.
236
+ *
237
+ * @param mixed $id
238
+ * @param boolean $clear
239
+ * @throws PHP_CodeCoverage_Exception
240
+ */
241
+ public function start_new ($ id , $ clear = false )
242
+ {
243
+ "CodeCoveage.php : echo Start success \n" ;
244
+
245
+ if (!is_bool ($ clear )) {
246
+ throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory (
247
+ 1 ,
248
+ 'boolean '
249
+ );
250
+ }
236
251
252
+ if ($ clear ) {
253
+ $ this ->clear ();
254
+ }
255
+
256
+ $ this ->currentId = $ id ;
257
+ "CodeCoveage.php : echo Start success \n" ;
258
+ $ this ->driver ->start_new ();
259
+ }
237
260
/**
238
261
* Stop collection of code coverage information.
239
262
*
@@ -260,10 +283,49 @@ public function stop($append = true, $linesToBeCovered = array(), array $linesTo
260
283
}
261
284
262
285
$ data = $ this ->driver ->stop ();
263
- $ this ->append ($ data , null , $ append , $ linesToBeCovered , $ linesToBeUsed );
264
-
286
+ $ data2 = array ();
287
+
288
+ foreach ($ data as $ key => $ arr_data ){
289
+ if (isset ($ arr_data ['lines ' ])){
290
+ //var_dump(strstr($key , "/vendor/"));
291
+ if (strstr ($ key , "vendor " )){
292
+ continue ;
293
+ } else {
294
+ //echo "$key\n\n";
295
+ $ data2 [$ key ] = $ arr_data ['lines ' ];
296
+ }
297
+ }
298
+
299
+ }
300
+ $ this ->append ($ data2 , null , $ append , $ linesToBeCovered , $ linesToBeUsed );
265
301
$ this ->currentId = null ;
266
302
303
+
304
+ $ arr_data = array ();
305
+
306
+ if (file_exists (dirname (__FILE__ ) . "/data.json " )){
307
+ $ str_data = file_get_contents (dirname (__FILE__ ) . "/data.json " );
308
+ $ arr_data = json_decode ($ str_data , true );
309
+ }
310
+ if (is_array ($ arr_data )){
311
+ //$data2 = array_merge($arr_data, $data2);
312
+ foreach ($ data as $ key => $ value ) {
313
+ if (!isset ($ arr_data [$ key ])){
314
+ $ arr_data [$ key ] = $ value ;
315
+ } else {
316
+ $ arr_data [$ key ] = $ value ;
317
+ }
318
+
319
+ }
320
+
321
+ }
322
+
323
+ $ fp = fopen (dirname (__FILE__ ) . "/data.json " , "w+ " );
324
+ //var_dump($arr_data);
325
+ //echo "\n\n\n\n";
326
+ $ str = json_encode ($ arr_data );
327
+ fwrite ($ fp , $ str );
328
+ fclose ($ fp );
267
329
return $ data ;
268
330
}
269
331
@@ -294,7 +356,8 @@ public function append(array $data, $id = null, $append = true, $linesToBeCovere
294
356
if (!$ append ) {
295
357
return ;
296
358
}
297
-
359
+ //var_dump($data);
360
+
298
361
if ($ id != 'UNCOVERED_FILES_FROM_WHITELIST ' ) {
299
362
$ this ->applyCoversAnnotationFilter (
300
363
$ data ,
@@ -343,6 +406,7 @@ public function append(array $data, $id = null, $append = true, $linesToBeCovere
343
406
}
344
407
}
345
408
}
409
+ //var_dump($data);
346
410
}
347
411
348
412
/**
@@ -375,14 +439,6 @@ public function merge(PHP_CodeCoverage $that)
375
439
}
376
440
377
441
$ this ->tests = array_merge ($ this ->tests , $ that ->getTests ());
378
-
379
- $ this ->filter ->setBlacklistedFiles (
380
- array_merge ($ this ->filter ->getBlacklistedFiles (), $ that ->filter ()->getBlacklistedFiles ())
381
- );
382
-
383
- $ this ->filter ->setWhitelistedFiles (
384
- array_merge ($ this ->filter ->getWhitelistedFiles (), $ that ->filter ()->getWhitelistedFiles ())
385
- );
386
442
}
387
443
388
444
/**
@@ -491,22 +547,6 @@ public function setProcessUncoveredFilesFromWhitelist($flag)
491
547
$ this ->processUncoveredFilesFromWhitelist = $ flag ;
492
548
}
493
549
494
- /**
495
- * @param boolean $flag
496
- * @throws PHP_CodeCoverage_Exception
497
- */
498
- public function setDisableIgnoredLines ($ flag )
499
- {
500
- if (!is_bool ($ flag )) {
501
- throw PHP_CodeCoverage_Util_InvalidArgumentHelper::factory (
502
- 1 ,
503
- 'boolean '
504
- );
505
- }
506
-
507
- $ this ->disableIgnoredLines = $ flag ;
508
- }
509
-
510
550
/**
511
551
* Applies the @covers annotation filtering.
512
552
*
@@ -682,10 +722,6 @@ private function getLinesToBeIgnored($filename)
682
722
$ lines = file ($ filename );
683
723
$ numLines = count ($ lines );
684
724
685
- if ($ this ->disableIgnoredLines ) {
686
- return $ this ->ignoredLines [$ filename ];
687
- }
688
-
689
725
foreach ($ lines as $ index => $ line ) {
690
726
if (!trim ($ line )) {
691
727
$ this ->ignoredLines [$ filename ][] = $ index + 1 ;
@@ -736,7 +772,7 @@ private function getLinesToBeIgnored($filename)
736
772
737
773
// A DOC_COMMENT token or a COMMENT token starting with "/*"
738
774
// does not contain the final \n character in its text
739
- if (isset ( $ lines [ $ i - 1 ]) && 0 === strpos ($ _token , '/* ' ) && '*/ ' === substr (trim ($ lines [$ i -1 ]), -2 )) {
775
+ if (0 === strpos ($ _token , '/* ' ) && '*/ ' === substr (trim ($ lines [$ i -1 ]), -2 )) {
740
776
$ this ->ignoredLines [$ filename ][] = $ i ;
741
777
}
742
778
}
0 commit comments