@@ -38,638 +38,638 @@ |
||
| 38 | 38 | */ |
| 39 | 39 | final class CodeCoverage |
| 40 | 40 | { |
| 41 | - private const UNCOVERED_FILES = 'UNCOVERED_FILES'; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var Driver |
|
| 45 | - */ |
|
| 46 | - private $driver; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var Filter |
|
| 50 | - */ |
|
| 51 | - private $filter; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @var Wizard |
|
| 55 | - */ |
|
| 56 | - private $wizard; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @var bool |
|
| 60 | - */ |
|
| 61 | - private $checkForUnintentionallyCoveredCode = false; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * @var bool |
|
| 65 | - */ |
|
| 66 | - private $includeUncoveredFiles = true; |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * @var bool |
|
| 70 | - */ |
|
| 71 | - private $processUncoveredFiles = false; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * @var bool |
|
| 75 | - */ |
|
| 76 | - private $ignoreDeprecatedCode = false; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @var null|PhptTestCase|string|TestCase |
|
| 80 | - */ |
|
| 81 | - private $currentId; |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Code coverage data. |
|
| 85 | - * |
|
| 86 | - * @var ProcessedCodeCoverageData |
|
| 87 | - */ |
|
| 88 | - private $data; |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @var bool |
|
| 92 | - */ |
|
| 93 | - private $useAnnotationsForIgnoringCode = true; |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * Test data. |
|
| 97 | - * |
|
| 98 | - * @var array |
|
| 99 | - */ |
|
| 100 | - private $tests = []; |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @psalm-var list<class-string> |
|
| 104 | - */ |
|
| 105 | - private $parentClassesExcludedFromUnintentionallyCoveredCodeCheck = []; |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * @var ?FileAnalyser |
|
| 109 | - */ |
|
| 110 | - private $analyser; |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @var ?string |
|
| 114 | - */ |
|
| 115 | - private $cacheDirectory; |
|
| 116 | - |
|
| 117 | - public function __construct(Driver $driver, Filter $filter) |
|
| 118 | - { |
|
| 119 | - $this->driver = $driver; |
|
| 120 | - $this->filter = $filter; |
|
| 121 | - $this->data = new ProcessedCodeCoverageData; |
|
| 122 | - $this->wizard = new Wizard; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * Returns the code coverage information as a graph of node objects. |
|
| 127 | - */ |
|
| 128 | - public function getReport(): Directory |
|
| 129 | - { |
|
| 130 | - return (new Builder($this->analyser()))->build($this); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * Clears collected code coverage data. |
|
| 135 | - */ |
|
| 136 | - public function clear(): void |
|
| 137 | - { |
|
| 138 | - $this->currentId = null; |
|
| 139 | - $this->data = new ProcessedCodeCoverageData; |
|
| 140 | - $this->tests = []; |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Returns the filter object used. |
|
| 145 | - */ |
|
| 146 | - public function filter(): Filter |
|
| 147 | - { |
|
| 148 | - return $this->filter; |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Returns the collected code coverage data. |
|
| 153 | - */ |
|
| 154 | - public function getData(bool $raw = false): ProcessedCodeCoverageData |
|
| 155 | - { |
|
| 156 | - if (!$raw) { |
|
| 157 | - if ($this->processUncoveredFiles) { |
|
| 158 | - $this->processUncoveredFilesFromFilter(); |
|
| 159 | - } elseif ($this->includeUncoveredFiles) { |
|
| 160 | - $this->addUncoveredFilesFromFilter(); |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - return $this->data; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * Sets the coverage data. |
|
| 169 | - */ |
|
| 170 | - public function setData(ProcessedCodeCoverageData $data): void |
|
| 171 | - { |
|
| 172 | - $this->data = $data; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Returns the test data. |
|
| 177 | - */ |
|
| 178 | - public function getTests(): array |
|
| 179 | - { |
|
| 180 | - return $this->tests; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * Sets the test data. |
|
| 185 | - */ |
|
| 186 | - public function setTests(array $tests): void |
|
| 187 | - { |
|
| 188 | - $this->tests = $tests; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - /** |
|
| 192 | - * Start collection of code coverage information. |
|
| 193 | - * |
|
| 194 | - * @param PhptTestCase|string|TestCase $id |
|
| 195 | - */ |
|
| 196 | - public function start($id, bool $clear = false): void |
|
| 197 | - { |
|
| 198 | - if ($clear) { |
|
| 199 | - $this->clear(); |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - $this->currentId = $id; |
|
| 203 | - |
|
| 204 | - $this->driver->start(); |
|
| 205 | - } |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * Stop collection of code coverage information. |
|
| 209 | - * |
|
| 210 | - * @param array|false $linesToBeCovered |
|
| 211 | - */ |
|
| 212 | - public function stop(bool $append = true, $linesToBeCovered = [], array $linesToBeUsed = []): RawCodeCoverageData |
|
| 213 | - { |
|
| 214 | - if (!is_array($linesToBeCovered) && $linesToBeCovered !== false) { |
|
| 215 | - throw new InvalidArgumentException( |
|
| 216 | - '$linesToBeCovered must be an array or false' |
|
| 217 | - ); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - $data = $this->driver->stop(); |
|
| 221 | - $this->append($data, null, $append, $linesToBeCovered, $linesToBeUsed); |
|
| 222 | - |
|
| 223 | - $this->currentId = null; |
|
| 224 | - |
|
| 225 | - return $data; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - /** |
|
| 229 | - * Appends code coverage data. |
|
| 230 | - * |
|
| 231 | - * @param PhptTestCase|string|TestCase $id |
|
| 232 | - * @param array|false $linesToBeCovered |
|
| 233 | - * |
|
| 234 | - * @throws ReflectionException |
|
| 235 | - * @throws TestIdMissingException |
|
| 236 | - * @throws UnintentionallyCoveredCodeException |
|
| 237 | - */ |
|
| 238 | - public function append(RawCodeCoverageData $rawData, $id = null, bool $append = true, $linesToBeCovered = [], array $linesToBeUsed = []): void |
|
| 239 | - { |
|
| 240 | - if ($id === null) { |
|
| 241 | - $id = $this->currentId; |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - if ($id === null) { |
|
| 245 | - throw new TestIdMissingException; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - $this->applyFilter($rawData); |
|
| 249 | - |
|
| 250 | - $this->applyExecutableLinesFilter($rawData); |
|
| 251 | - |
|
| 252 | - if ($this->useAnnotationsForIgnoringCode) { |
|
| 253 | - $this->applyIgnoredLinesFilter($rawData); |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - $this->data->initializeUnseenData($rawData); |
|
| 257 | - |
|
| 258 | - if (!$append) { |
|
| 259 | - return; |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - if ($id !== self::UNCOVERED_FILES) { |
|
| 263 | - $this->applyCoversAnnotationFilter( |
|
| 264 | - $rawData, |
|
| 265 | - $linesToBeCovered, |
|
| 266 | - $linesToBeUsed |
|
| 267 | - ); |
|
| 268 | - |
|
| 269 | - if (empty($rawData->lineCoverage())) { |
|
| 270 | - return; |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - $size = 'unknown'; |
|
| 274 | - $status = -1; |
|
| 275 | - $fromTestcase = false; |
|
| 276 | - |
|
| 277 | - if ($id instanceof TestCase) { |
|
| 278 | - $fromTestcase = true; |
|
| 279 | - $_size = $id->getSize(); |
|
| 280 | - |
|
| 281 | - if ($_size === Test::SMALL) { |
|
| 282 | - $size = 'small'; |
|
| 283 | - } elseif ($_size === Test::MEDIUM) { |
|
| 284 | - $size = 'medium'; |
|
| 285 | - } elseif ($_size === Test::LARGE) { |
|
| 286 | - $size = 'large'; |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - $status = $id->getStatus(); |
|
| 290 | - $id = get_class($id) . '::' . $id->getName(); |
|
| 291 | - } elseif ($id instanceof PhptTestCase) { |
|
| 292 | - $fromTestcase = true; |
|
| 293 | - $size = 'large'; |
|
| 294 | - $id = $id->getName(); |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - $this->tests[$id] = ['size' => $size, 'status' => $status, 'fromTestcase' => $fromTestcase]; |
|
| 298 | - |
|
| 299 | - $this->data->markCodeAsExecutedByTestCase($id, $rawData); |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * Merges the data from another instance. |
|
| 305 | - */ |
|
| 306 | - public function merge(self $that): void |
|
| 307 | - { |
|
| 308 | - $this->filter->includeFiles( |
|
| 309 | - $that->filter()->files() |
|
| 310 | - ); |
|
| 311 | - |
|
| 312 | - $this->data->merge($that->data); |
|
| 313 | - |
|
| 314 | - $this->tests = array_merge($this->tests, $that->getTests()); |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - public function enableCheckForUnintentionallyCoveredCode(): void |
|
| 318 | - { |
|
| 319 | - $this->checkForUnintentionallyCoveredCode = true; |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - public function disableCheckForUnintentionallyCoveredCode(): void |
|
| 323 | - { |
|
| 324 | - $this->checkForUnintentionallyCoveredCode = false; |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - public function includeUncoveredFiles(): void |
|
| 328 | - { |
|
| 329 | - $this->includeUncoveredFiles = true; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - public function excludeUncoveredFiles(): void |
|
| 333 | - { |
|
| 334 | - $this->includeUncoveredFiles = false; |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - public function processUncoveredFiles(): void |
|
| 338 | - { |
|
| 339 | - $this->processUncoveredFiles = true; |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - public function doNotProcessUncoveredFiles(): void |
|
| 343 | - { |
|
| 344 | - $this->processUncoveredFiles = false; |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - public function enableAnnotationsForIgnoringCode(): void |
|
| 348 | - { |
|
| 349 | - $this->useAnnotationsForIgnoringCode = true; |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - public function disableAnnotationsForIgnoringCode(): void |
|
| 353 | - { |
|
| 354 | - $this->useAnnotationsForIgnoringCode = false; |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - public function ignoreDeprecatedCode(): void |
|
| 358 | - { |
|
| 359 | - $this->ignoreDeprecatedCode = true; |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - public function doNotIgnoreDeprecatedCode(): void |
|
| 363 | - { |
|
| 364 | - $this->ignoreDeprecatedCode = false; |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * @psalm-assert-if-true !null $this->cacheDirectory |
|
| 369 | - */ |
|
| 370 | - public function cachesStaticAnalysis(): bool |
|
| 371 | - { |
|
| 372 | - return $this->cacheDirectory !== null; |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - public function cacheStaticAnalysis(string $directory): void |
|
| 376 | - { |
|
| 377 | - $this->cacheDirectory = $directory; |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - public function doNotCacheStaticAnalysis(): void |
|
| 381 | - { |
|
| 382 | - $this->cacheDirectory = null; |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * @throws StaticAnalysisCacheNotConfiguredException |
|
| 387 | - */ |
|
| 388 | - public function cacheDirectory(): string |
|
| 389 | - { |
|
| 390 | - if (!$this->cachesStaticAnalysis()) { |
|
| 391 | - throw new StaticAnalysisCacheNotConfiguredException( |
|
| 392 | - 'The static analysis cache is not configured' |
|
| 393 | - ); |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - return $this->cacheDirectory; |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - /** |
|
| 400 | - * @psalm-param class-string $className |
|
| 401 | - */ |
|
| 402 | - public function excludeSubclassesOfThisClassFromUnintentionallyCoveredCodeCheck(string $className): void |
|
| 403 | - { |
|
| 404 | - $this->parentClassesExcludedFromUnintentionallyCoveredCodeCheck[] = $className; |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - public function enableBranchAndPathCoverage(): void |
|
| 408 | - { |
|
| 409 | - $this->driver->enableBranchAndPathCoverage(); |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - public function disableBranchAndPathCoverage(): void |
|
| 413 | - { |
|
| 414 | - $this->driver->disableBranchAndPathCoverage(); |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - public function collectsBranchAndPathCoverage(): bool |
|
| 418 | - { |
|
| 419 | - return $this->driver->collectsBranchAndPathCoverage(); |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - public function detectsDeadCode(): bool |
|
| 423 | - { |
|
| 424 | - return $this->driver->detectsDeadCode(); |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - /** |
|
| 428 | - * Applies the @covers annotation filtering. |
|
| 429 | - * |
|
| 430 | - * @param array|false $linesToBeCovered |
|
| 431 | - * |
|
| 432 | - * @throws ReflectionException |
|
| 433 | - * @throws UnintentionallyCoveredCodeException |
|
| 434 | - */ |
|
| 435 | - private function applyCoversAnnotationFilter(RawCodeCoverageData $rawData, $linesToBeCovered, array $linesToBeUsed): void |
|
| 436 | - { |
|
| 437 | - if ($linesToBeCovered === false) { |
|
| 438 | - $rawData->clear(); |
|
| 439 | - |
|
| 440 | - return; |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - if (empty($linesToBeCovered)) { |
|
| 444 | - return; |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - if ($this->checkForUnintentionallyCoveredCode && |
|
| 448 | - (!$this->currentId instanceof TestCase || |
|
| 449 | - (!$this->currentId->isMedium() && !$this->currentId->isLarge()))) { |
|
| 450 | - $this->performUnintentionallyCoveredCodeCheck($rawData, $linesToBeCovered, $linesToBeUsed); |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - $rawLineData = $rawData->lineCoverage(); |
|
| 454 | - $filesWithNoCoverage = array_diff_key($rawLineData, $linesToBeCovered); |
|
| 455 | - |
|
| 456 | - foreach (array_keys($filesWithNoCoverage) as $fileWithNoCoverage) { |
|
| 457 | - $rawData->removeCoverageDataForFile($fileWithNoCoverage); |
|
| 458 | - } |
|
| 459 | - |
|
| 460 | - if (is_array($linesToBeCovered)) { |
|
| 461 | - foreach ($linesToBeCovered as $fileToBeCovered => $includedLines) { |
|
| 462 | - $rawData->keepLineCoverageDataOnlyForLines($fileToBeCovered, $includedLines); |
|
| 463 | - $rawData->keepFunctionCoverageDataOnlyForLines($fileToBeCovered, $includedLines); |
|
| 464 | - } |
|
| 465 | - } |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - private function applyFilter(RawCodeCoverageData $data): void |
|
| 469 | - { |
|
| 470 | - if ($this->filter->isEmpty()) { |
|
| 471 | - return; |
|
| 472 | - } |
|
| 473 | - |
|
| 474 | - foreach (array_keys($data->lineCoverage()) as $filename) { |
|
| 475 | - if ($this->filter->isExcluded($filename)) { |
|
| 476 | - $data->removeCoverageDataForFile($filename); |
|
| 477 | - } |
|
| 478 | - } |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - private function applyExecutableLinesFilter(RawCodeCoverageData $data): void |
|
| 482 | - { |
|
| 483 | - foreach (array_keys($data->lineCoverage()) as $filename) { |
|
| 484 | - if (!$this->filter->isFile($filename)) { |
|
| 485 | - continue; |
|
| 486 | - } |
|
| 487 | - |
|
| 488 | - $data->keepLineCoverageDataOnlyForLines( |
|
| 489 | - $filename, |
|
| 490 | - $this->analyser()->executableLinesIn($filename) |
|
| 491 | - ); |
|
| 492 | - } |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - private function applyIgnoredLinesFilter(RawCodeCoverageData $data): void |
|
| 496 | - { |
|
| 497 | - foreach (array_keys($data->lineCoverage()) as $filename) { |
|
| 498 | - if (!$this->filter->isFile($filename)) { |
|
| 499 | - continue; |
|
| 500 | - } |
|
| 501 | - |
|
| 502 | - $data->removeCoverageDataForLines( |
|
| 503 | - $filename, |
|
| 504 | - $this->analyser()->ignoredLinesFor($filename) |
|
| 505 | - ); |
|
| 506 | - } |
|
| 507 | - } |
|
| 508 | - |
|
| 509 | - /** |
|
| 510 | - * @throws UnintentionallyCoveredCodeException |
|
| 511 | - */ |
|
| 512 | - private function addUncoveredFilesFromFilter(): void |
|
| 513 | - { |
|
| 514 | - $uncoveredFiles = array_diff( |
|
| 515 | - $this->filter->files(), |
|
| 516 | - $this->data->coveredFiles() |
|
| 517 | - ); |
|
| 518 | - |
|
| 519 | - foreach ($uncoveredFiles as $uncoveredFile) { |
|
| 520 | - if ($this->filter->isFile($uncoveredFile)) { |
|
| 521 | - $this->append( |
|
| 522 | - RawCodeCoverageData::fromUncoveredFile( |
|
| 523 | - $uncoveredFile, |
|
| 524 | - $this->analyser() |
|
| 525 | - ), |
|
| 526 | - self::UNCOVERED_FILES |
|
| 527 | - ); |
|
| 528 | - } |
|
| 529 | - } |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - /** |
|
| 533 | - * @throws UnintentionallyCoveredCodeException |
|
| 534 | - */ |
|
| 535 | - private function processUncoveredFilesFromFilter(): void |
|
| 536 | - { |
|
| 537 | - $uncoveredFiles = array_diff( |
|
| 538 | - $this->filter->files(), |
|
| 539 | - $this->data->coveredFiles() |
|
| 540 | - ); |
|
| 541 | - |
|
| 542 | - $this->driver->start(); |
|
| 543 | - |
|
| 544 | - foreach ($uncoveredFiles as $uncoveredFile) { |
|
| 545 | - if ($this->filter->isFile($uncoveredFile)) { |
|
| 546 | - include_once $uncoveredFile; |
|
| 547 | - } |
|
| 548 | - } |
|
| 549 | - |
|
| 550 | - $this->append($this->driver->stop(), self::UNCOVERED_FILES); |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - /** |
|
| 554 | - * @throws ReflectionException |
|
| 555 | - * @throws UnintentionallyCoveredCodeException |
|
| 556 | - */ |
|
| 557 | - private function performUnintentionallyCoveredCodeCheck(RawCodeCoverageData $data, array $linesToBeCovered, array $linesToBeUsed): void |
|
| 558 | - { |
|
| 559 | - $allowedLines = $this->getAllowedLines( |
|
| 560 | - $linesToBeCovered, |
|
| 561 | - $linesToBeUsed |
|
| 562 | - ); |
|
| 563 | - |
|
| 564 | - $unintentionallyCoveredUnits = []; |
|
| 565 | - |
|
| 566 | - foreach ($data->lineCoverage() as $file => $_data) { |
|
| 567 | - foreach ($_data as $line => $flag) { |
|
| 568 | - if ($flag === 1 && !isset($allowedLines[$file][$line])) { |
|
| 569 | - $unintentionallyCoveredUnits[] = $this->wizard->lookup($file, $line); |
|
| 570 | - } |
|
| 571 | - } |
|
| 572 | - } |
|
| 573 | - |
|
| 574 | - $unintentionallyCoveredUnits = $this->processUnintentionallyCoveredUnits($unintentionallyCoveredUnits); |
|
| 575 | - |
|
| 576 | - if (!empty($unintentionallyCoveredUnits)) { |
|
| 577 | - throw new UnintentionallyCoveredCodeException( |
|
| 578 | - $unintentionallyCoveredUnits |
|
| 579 | - ); |
|
| 580 | - } |
|
| 581 | - } |
|
| 582 | - |
|
| 583 | - private function getAllowedLines(array $linesToBeCovered, array $linesToBeUsed): array |
|
| 584 | - { |
|
| 585 | - $allowedLines = []; |
|
| 586 | - |
|
| 587 | - foreach (array_keys($linesToBeCovered) as $file) { |
|
| 588 | - if (!isset($allowedLines[$file])) { |
|
| 589 | - $allowedLines[$file] = []; |
|
| 590 | - } |
|
| 591 | - |
|
| 592 | - $allowedLines[$file] = array_merge( |
|
| 593 | - $allowedLines[$file], |
|
| 594 | - $linesToBeCovered[$file] |
|
| 595 | - ); |
|
| 596 | - } |
|
| 597 | - |
|
| 598 | - foreach (array_keys($linesToBeUsed) as $file) { |
|
| 599 | - if (!isset($allowedLines[$file])) { |
|
| 600 | - $allowedLines[$file] = []; |
|
| 601 | - } |
|
| 602 | - |
|
| 603 | - $allowedLines[$file] = array_merge( |
|
| 604 | - $allowedLines[$file], |
|
| 605 | - $linesToBeUsed[$file] |
|
| 606 | - ); |
|
| 607 | - } |
|
| 608 | - |
|
| 609 | - foreach (array_keys($allowedLines) as $file) { |
|
| 610 | - $allowedLines[$file] = array_flip( |
|
| 611 | - array_unique($allowedLines[$file]) |
|
| 612 | - ); |
|
| 613 | - } |
|
| 614 | - |
|
| 615 | - return $allowedLines; |
|
| 616 | - } |
|
| 617 | - |
|
| 618 | - /** |
|
| 619 | - * @throws ReflectionException |
|
| 620 | - */ |
|
| 621 | - private function processUnintentionallyCoveredUnits(array $unintentionallyCoveredUnits): array |
|
| 622 | - { |
|
| 623 | - $unintentionallyCoveredUnits = array_unique($unintentionallyCoveredUnits); |
|
| 624 | - sort($unintentionallyCoveredUnits); |
|
| 625 | - |
|
| 626 | - foreach (array_keys($unintentionallyCoveredUnits) as $k => $v) { |
|
| 627 | - $unit = explode('::', $unintentionallyCoveredUnits[$k]); |
|
| 628 | - |
|
| 629 | - if (count($unit) !== 2) { |
|
| 630 | - continue; |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - try { |
|
| 634 | - $class = new ReflectionClass($unit[0]); |
|
| 635 | - |
|
| 636 | - foreach ($this->parentClassesExcludedFromUnintentionallyCoveredCodeCheck as $parentClass) { |
|
| 637 | - if ($class->isSubclassOf($parentClass)) { |
|
| 638 | - unset($unintentionallyCoveredUnits[$k]); |
|
| 639 | - |
|
| 640 | - break; |
|
| 641 | - } |
|
| 642 | - } |
|
| 643 | - } catch (\ReflectionException $e) { |
|
| 644 | - throw new ReflectionException( |
|
| 645 | - $e->getMessage(), |
|
| 646 | - (int) $e->getCode(), |
|
| 647 | - $e |
|
| 648 | - ); |
|
| 649 | - } |
|
| 650 | - } |
|
| 651 | - |
|
| 652 | - return array_values($unintentionallyCoveredUnits); |
|
| 653 | - } |
|
| 654 | - |
|
| 655 | - private function analyser(): FileAnalyser |
|
| 656 | - { |
|
| 657 | - if ($this->analyser !== null) { |
|
| 658 | - return $this->analyser; |
|
| 659 | - } |
|
| 660 | - |
|
| 661 | - $this->analyser = new ParsingFileAnalyser( |
|
| 662 | - $this->useAnnotationsForIgnoringCode, |
|
| 663 | - $this->ignoreDeprecatedCode |
|
| 664 | - ); |
|
| 665 | - |
|
| 666 | - if ($this->cachesStaticAnalysis()) { |
|
| 667 | - $this->analyser = new CachingFileAnalyser( |
|
| 668 | - $this->cacheDirectory, |
|
| 669 | - $this->analyser |
|
| 670 | - ); |
|
| 671 | - } |
|
| 672 | - |
|
| 673 | - return $this->analyser; |
|
| 674 | - } |
|
| 41 | + private const UNCOVERED_FILES = 'UNCOVERED_FILES'; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var Driver |
|
| 45 | + */ |
|
| 46 | + private $driver; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var Filter |
|
| 50 | + */ |
|
| 51 | + private $filter; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @var Wizard |
|
| 55 | + */ |
|
| 56 | + private $wizard; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @var bool |
|
| 60 | + */ |
|
| 61 | + private $checkForUnintentionallyCoveredCode = false; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @var bool |
|
| 65 | + */ |
|
| 66 | + private $includeUncoveredFiles = true; |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * @var bool |
|
| 70 | + */ |
|
| 71 | + private $processUncoveredFiles = false; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * @var bool |
|
| 75 | + */ |
|
| 76 | + private $ignoreDeprecatedCode = false; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @var null|PhptTestCase|string|TestCase |
|
| 80 | + */ |
|
| 81 | + private $currentId; |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Code coverage data. |
|
| 85 | + * |
|
| 86 | + * @var ProcessedCodeCoverageData |
|
| 87 | + */ |
|
| 88 | + private $data; |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * @var bool |
|
| 92 | + */ |
|
| 93 | + private $useAnnotationsForIgnoringCode = true; |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * Test data. |
|
| 97 | + * |
|
| 98 | + * @var array |
|
| 99 | + */ |
|
| 100 | + private $tests = []; |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @psalm-var list<class-string> |
|
| 104 | + */ |
|
| 105 | + private $parentClassesExcludedFromUnintentionallyCoveredCodeCheck = []; |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * @var ?FileAnalyser |
|
| 109 | + */ |
|
| 110 | + private $analyser; |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @var ?string |
|
| 114 | + */ |
|
| 115 | + private $cacheDirectory; |
|
| 116 | + |
|
| 117 | + public function __construct(Driver $driver, Filter $filter) |
|
| 118 | + { |
|
| 119 | + $this->driver = $driver; |
|
| 120 | + $this->filter = $filter; |
|
| 121 | + $this->data = new ProcessedCodeCoverageData; |
|
| 122 | + $this->wizard = new Wizard; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * Returns the code coverage information as a graph of node objects. |
|
| 127 | + */ |
|
| 128 | + public function getReport(): Directory |
|
| 129 | + { |
|
| 130 | + return (new Builder($this->analyser()))->build($this); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * Clears collected code coverage data. |
|
| 135 | + */ |
|
| 136 | + public function clear(): void |
|
| 137 | + { |
|
| 138 | + $this->currentId = null; |
|
| 139 | + $this->data = new ProcessedCodeCoverageData; |
|
| 140 | + $this->tests = []; |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Returns the filter object used. |
|
| 145 | + */ |
|
| 146 | + public function filter(): Filter |
|
| 147 | + { |
|
| 148 | + return $this->filter; |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Returns the collected code coverage data. |
|
| 153 | + */ |
|
| 154 | + public function getData(bool $raw = false): ProcessedCodeCoverageData |
|
| 155 | + { |
|
| 156 | + if (!$raw) { |
|
| 157 | + if ($this->processUncoveredFiles) { |
|
| 158 | + $this->processUncoveredFilesFromFilter(); |
|
| 159 | + } elseif ($this->includeUncoveredFiles) { |
|
| 160 | + $this->addUncoveredFilesFromFilter(); |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + return $this->data; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * Sets the coverage data. |
|
| 169 | + */ |
|
| 170 | + public function setData(ProcessedCodeCoverageData $data): void |
|
| 171 | + { |
|
| 172 | + $this->data = $data; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Returns the test data. |
|
| 177 | + */ |
|
| 178 | + public function getTests(): array |
|
| 179 | + { |
|
| 180 | + return $this->tests; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * Sets the test data. |
|
| 185 | + */ |
|
| 186 | + public function setTests(array $tests): void |
|
| 187 | + { |
|
| 188 | + $this->tests = $tests; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + /** |
|
| 192 | + * Start collection of code coverage information. |
|
| 193 | + * |
|
| 194 | + * @param PhptTestCase|string|TestCase $id |
|
| 195 | + */ |
|
| 196 | + public function start($id, bool $clear = false): void |
|
| 197 | + { |
|
| 198 | + if ($clear) { |
|
| 199 | + $this->clear(); |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + $this->currentId = $id; |
|
| 203 | + |
|
| 204 | + $this->driver->start(); |
|
| 205 | + } |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * Stop collection of code coverage information. |
|
| 209 | + * |
|
| 210 | + * @param array|false $linesToBeCovered |
|
| 211 | + */ |
|
| 212 | + public function stop(bool $append = true, $linesToBeCovered = [], array $linesToBeUsed = []): RawCodeCoverageData |
|
| 213 | + { |
|
| 214 | + if (!is_array($linesToBeCovered) && $linesToBeCovered !== false) { |
|
| 215 | + throw new InvalidArgumentException( |
|
| 216 | + '$linesToBeCovered must be an array or false' |
|
| 217 | + ); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + $data = $this->driver->stop(); |
|
| 221 | + $this->append($data, null, $append, $linesToBeCovered, $linesToBeUsed); |
|
| 222 | + |
|
| 223 | + $this->currentId = null; |
|
| 224 | + |
|
| 225 | + return $data; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + /** |
|
| 229 | + * Appends code coverage data. |
|
| 230 | + * |
|
| 231 | + * @param PhptTestCase|string|TestCase $id |
|
| 232 | + * @param array|false $linesToBeCovered |
|
| 233 | + * |
|
| 234 | + * @throws ReflectionException |
|
| 235 | + * @throws TestIdMissingException |
|
| 236 | + * @throws UnintentionallyCoveredCodeException |
|
| 237 | + */ |
|
| 238 | + public function append(RawCodeCoverageData $rawData, $id = null, bool $append = true, $linesToBeCovered = [], array $linesToBeUsed = []): void |
|
| 239 | + { |
|
| 240 | + if ($id === null) { |
|
| 241 | + $id = $this->currentId; |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + if ($id === null) { |
|
| 245 | + throw new TestIdMissingException; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + $this->applyFilter($rawData); |
|
| 249 | + |
|
| 250 | + $this->applyExecutableLinesFilter($rawData); |
|
| 251 | + |
|
| 252 | + if ($this->useAnnotationsForIgnoringCode) { |
|
| 253 | + $this->applyIgnoredLinesFilter($rawData); |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + $this->data->initializeUnseenData($rawData); |
|
| 257 | + |
|
| 258 | + if (!$append) { |
|
| 259 | + return; |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + if ($id !== self::UNCOVERED_FILES) { |
|
| 263 | + $this->applyCoversAnnotationFilter( |
|
| 264 | + $rawData, |
|
| 265 | + $linesToBeCovered, |
|
| 266 | + $linesToBeUsed |
|
| 267 | + ); |
|
| 268 | + |
|
| 269 | + if (empty($rawData->lineCoverage())) { |
|
| 270 | + return; |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + $size = 'unknown'; |
|
| 274 | + $status = -1; |
|
| 275 | + $fromTestcase = false; |
|
| 276 | + |
|
| 277 | + if ($id instanceof TestCase) { |
|
| 278 | + $fromTestcase = true; |
|
| 279 | + $_size = $id->getSize(); |
|
| 280 | + |
|
| 281 | + if ($_size === Test::SMALL) { |
|
| 282 | + $size = 'small'; |
|
| 283 | + } elseif ($_size === Test::MEDIUM) { |
|
| 284 | + $size = 'medium'; |
|
| 285 | + } elseif ($_size === Test::LARGE) { |
|
| 286 | + $size = 'large'; |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + $status = $id->getStatus(); |
|
| 290 | + $id = get_class($id) . '::' . $id->getName(); |
|
| 291 | + } elseif ($id instanceof PhptTestCase) { |
|
| 292 | + $fromTestcase = true; |
|
| 293 | + $size = 'large'; |
|
| 294 | + $id = $id->getName(); |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + $this->tests[$id] = ['size' => $size, 'status' => $status, 'fromTestcase' => $fromTestcase]; |
|
| 298 | + |
|
| 299 | + $this->data->markCodeAsExecutedByTestCase($id, $rawData); |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * Merges the data from another instance. |
|
| 305 | + */ |
|
| 306 | + public function merge(self $that): void |
|
| 307 | + { |
|
| 308 | + $this->filter->includeFiles( |
|
| 309 | + $that->filter()->files() |
|
| 310 | + ); |
|
| 311 | + |
|
| 312 | + $this->data->merge($that->data); |
|
| 313 | + |
|
| 314 | + $this->tests = array_merge($this->tests, $that->getTests()); |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + public function enableCheckForUnintentionallyCoveredCode(): void |
|
| 318 | + { |
|
| 319 | + $this->checkForUnintentionallyCoveredCode = true; |
|
| 320 | + } |
|
| 321 | + |
|
| 322 | + public function disableCheckForUnintentionallyCoveredCode(): void |
|
| 323 | + { |
|
| 324 | + $this->checkForUnintentionallyCoveredCode = false; |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + public function includeUncoveredFiles(): void |
|
| 328 | + { |
|
| 329 | + $this->includeUncoveredFiles = true; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + public function excludeUncoveredFiles(): void |
|
| 333 | + { |
|
| 334 | + $this->includeUncoveredFiles = false; |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + public function processUncoveredFiles(): void |
|
| 338 | + { |
|
| 339 | + $this->processUncoveredFiles = true; |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + public function doNotProcessUncoveredFiles(): void |
|
| 343 | + { |
|
| 344 | + $this->processUncoveredFiles = false; |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + public function enableAnnotationsForIgnoringCode(): void |
|
| 348 | + { |
|
| 349 | + $this->useAnnotationsForIgnoringCode = true; |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + public function disableAnnotationsForIgnoringCode(): void |
|
| 353 | + { |
|
| 354 | + $this->useAnnotationsForIgnoringCode = false; |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + public function ignoreDeprecatedCode(): void |
|
| 358 | + { |
|
| 359 | + $this->ignoreDeprecatedCode = true; |
|
| 360 | + } |
|
| 361 | + |
|
| 362 | + public function doNotIgnoreDeprecatedCode(): void |
|
| 363 | + { |
|
| 364 | + $this->ignoreDeprecatedCode = false; |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * @psalm-assert-if-true !null $this->cacheDirectory |
|
| 369 | + */ |
|
| 370 | + public function cachesStaticAnalysis(): bool |
|
| 371 | + { |
|
| 372 | + return $this->cacheDirectory !== null; |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + public function cacheStaticAnalysis(string $directory): void |
|
| 376 | + { |
|
| 377 | + $this->cacheDirectory = $directory; |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + public function doNotCacheStaticAnalysis(): void |
|
| 381 | + { |
|
| 382 | + $this->cacheDirectory = null; |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * @throws StaticAnalysisCacheNotConfiguredException |
|
| 387 | + */ |
|
| 388 | + public function cacheDirectory(): string |
|
| 389 | + { |
|
| 390 | + if (!$this->cachesStaticAnalysis()) { |
|
| 391 | + throw new StaticAnalysisCacheNotConfiguredException( |
|
| 392 | + 'The static analysis cache is not configured' |
|
| 393 | + ); |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + return $this->cacheDirectory; |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + /** |
|
| 400 | + * @psalm-param class-string $className |
|
| 401 | + */ |
|
| 402 | + public function excludeSubclassesOfThisClassFromUnintentionallyCoveredCodeCheck(string $className): void |
|
| 403 | + { |
|
| 404 | + $this->parentClassesExcludedFromUnintentionallyCoveredCodeCheck[] = $className; |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + public function enableBranchAndPathCoverage(): void |
|
| 408 | + { |
|
| 409 | + $this->driver->enableBranchAndPathCoverage(); |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + public function disableBranchAndPathCoverage(): void |
|
| 413 | + { |
|
| 414 | + $this->driver->disableBranchAndPathCoverage(); |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + public function collectsBranchAndPathCoverage(): bool |
|
| 418 | + { |
|
| 419 | + return $this->driver->collectsBranchAndPathCoverage(); |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + public function detectsDeadCode(): bool |
|
| 423 | + { |
|
| 424 | + return $this->driver->detectsDeadCode(); |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + /** |
|
| 428 | + * Applies the @covers annotation filtering. |
|
| 429 | + * |
|
| 430 | + * @param array|false $linesToBeCovered |
|
| 431 | + * |
|
| 432 | + * @throws ReflectionException |
|
| 433 | + * @throws UnintentionallyCoveredCodeException |
|
| 434 | + */ |
|
| 435 | + private function applyCoversAnnotationFilter(RawCodeCoverageData $rawData, $linesToBeCovered, array $linesToBeUsed): void |
|
| 436 | + { |
|
| 437 | + if ($linesToBeCovered === false) { |
|
| 438 | + $rawData->clear(); |
|
| 439 | + |
|
| 440 | + return; |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + if (empty($linesToBeCovered)) { |
|
| 444 | + return; |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + if ($this->checkForUnintentionallyCoveredCode && |
|
| 448 | + (!$this->currentId instanceof TestCase || |
|
| 449 | + (!$this->currentId->isMedium() && !$this->currentId->isLarge()))) { |
|
| 450 | + $this->performUnintentionallyCoveredCodeCheck($rawData, $linesToBeCovered, $linesToBeUsed); |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + $rawLineData = $rawData->lineCoverage(); |
|
| 454 | + $filesWithNoCoverage = array_diff_key($rawLineData, $linesToBeCovered); |
|
| 455 | + |
|
| 456 | + foreach (array_keys($filesWithNoCoverage) as $fileWithNoCoverage) { |
|
| 457 | + $rawData->removeCoverageDataForFile($fileWithNoCoverage); |
|
| 458 | + } |
|
| 459 | + |
|
| 460 | + if (is_array($linesToBeCovered)) { |
|
| 461 | + foreach ($linesToBeCovered as $fileToBeCovered => $includedLines) { |
|
| 462 | + $rawData->keepLineCoverageDataOnlyForLines($fileToBeCovered, $includedLines); |
|
| 463 | + $rawData->keepFunctionCoverageDataOnlyForLines($fileToBeCovered, $includedLines); |
|
| 464 | + } |
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + private function applyFilter(RawCodeCoverageData $data): void |
|
| 469 | + { |
|
| 470 | + if ($this->filter->isEmpty()) { |
|
| 471 | + return; |
|
| 472 | + } |
|
| 473 | + |
|
| 474 | + foreach (array_keys($data->lineCoverage()) as $filename) { |
|
| 475 | + if ($this->filter->isExcluded($filename)) { |
|
| 476 | + $data->removeCoverageDataForFile($filename); |
|
| 477 | + } |
|
| 478 | + } |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + private function applyExecutableLinesFilter(RawCodeCoverageData $data): void |
|
| 482 | + { |
|
| 483 | + foreach (array_keys($data->lineCoverage()) as $filename) { |
|
| 484 | + if (!$this->filter->isFile($filename)) { |
|
| 485 | + continue; |
|
| 486 | + } |
|
| 487 | + |
|
| 488 | + $data->keepLineCoverageDataOnlyForLines( |
|
| 489 | + $filename, |
|
| 490 | + $this->analyser()->executableLinesIn($filename) |
|
| 491 | + ); |
|
| 492 | + } |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + private function applyIgnoredLinesFilter(RawCodeCoverageData $data): void |
|
| 496 | + { |
|
| 497 | + foreach (array_keys($data->lineCoverage()) as $filename) { |
|
| 498 | + if (!$this->filter->isFile($filename)) { |
|
| 499 | + continue; |
|
| 500 | + } |
|
| 501 | + |
|
| 502 | + $data->removeCoverageDataForLines( |
|
| 503 | + $filename, |
|
| 504 | + $this->analyser()->ignoredLinesFor($filename) |
|
| 505 | + ); |
|
| 506 | + } |
|
| 507 | + } |
|
| 508 | + |
|
| 509 | + /** |
|
| 510 | + * @throws UnintentionallyCoveredCodeException |
|
| 511 | + */ |
|
| 512 | + private function addUncoveredFilesFromFilter(): void |
|
| 513 | + { |
|
| 514 | + $uncoveredFiles = array_diff( |
|
| 515 | + $this->filter->files(), |
|
| 516 | + $this->data->coveredFiles() |
|
| 517 | + ); |
|
| 518 | + |
|
| 519 | + foreach ($uncoveredFiles as $uncoveredFile) { |
|
| 520 | + if ($this->filter->isFile($uncoveredFile)) { |
|
| 521 | + $this->append( |
|
| 522 | + RawCodeCoverageData::fromUncoveredFile( |
|
| 523 | + $uncoveredFile, |
|
| 524 | + $this->analyser() |
|
| 525 | + ), |
|
| 526 | + self::UNCOVERED_FILES |
|
| 527 | + ); |
|
| 528 | + } |
|
| 529 | + } |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + /** |
|
| 533 | + * @throws UnintentionallyCoveredCodeException |
|
| 534 | + */ |
|
| 535 | + private function processUncoveredFilesFromFilter(): void |
|
| 536 | + { |
|
| 537 | + $uncoveredFiles = array_diff( |
|
| 538 | + $this->filter->files(), |
|
| 539 | + $this->data->coveredFiles() |
|
| 540 | + ); |
|
| 541 | + |
|
| 542 | + $this->driver->start(); |
|
| 543 | + |
|
| 544 | + foreach ($uncoveredFiles as $uncoveredFile) { |
|
| 545 | + if ($this->filter->isFile($uncoveredFile)) { |
|
| 546 | + include_once $uncoveredFile; |
|
| 547 | + } |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + $this->append($this->driver->stop(), self::UNCOVERED_FILES); |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + /** |
|
| 554 | + * @throws ReflectionException |
|
| 555 | + * @throws UnintentionallyCoveredCodeException |
|
| 556 | + */ |
|
| 557 | + private function performUnintentionallyCoveredCodeCheck(RawCodeCoverageData $data, array $linesToBeCovered, array $linesToBeUsed): void |
|
| 558 | + { |
|
| 559 | + $allowedLines = $this->getAllowedLines( |
|
| 560 | + $linesToBeCovered, |
|
| 561 | + $linesToBeUsed |
|
| 562 | + ); |
|
| 563 | + |
|
| 564 | + $unintentionallyCoveredUnits = []; |
|
| 565 | + |
|
| 566 | + foreach ($data->lineCoverage() as $file => $_data) { |
|
| 567 | + foreach ($_data as $line => $flag) { |
|
| 568 | + if ($flag === 1 && !isset($allowedLines[$file][$line])) { |
|
| 569 | + $unintentionallyCoveredUnits[] = $this->wizard->lookup($file, $line); |
|
| 570 | + } |
|
| 571 | + } |
|
| 572 | + } |
|
| 573 | + |
|
| 574 | + $unintentionallyCoveredUnits = $this->processUnintentionallyCoveredUnits($unintentionallyCoveredUnits); |
|
| 575 | + |
|
| 576 | + if (!empty($unintentionallyCoveredUnits)) { |
|
| 577 | + throw new UnintentionallyCoveredCodeException( |
|
| 578 | + $unintentionallyCoveredUnits |
|
| 579 | + ); |
|
| 580 | + } |
|
| 581 | + } |
|
| 582 | + |
|
| 583 | + private function getAllowedLines(array $linesToBeCovered, array $linesToBeUsed): array |
|
| 584 | + { |
|
| 585 | + $allowedLines = []; |
|
| 586 | + |
|
| 587 | + foreach (array_keys($linesToBeCovered) as $file) { |
|
| 588 | + if (!isset($allowedLines[$file])) { |
|
| 589 | + $allowedLines[$file] = []; |
|
| 590 | + } |
|
| 591 | + |
|
| 592 | + $allowedLines[$file] = array_merge( |
|
| 593 | + $allowedLines[$file], |
|
| 594 | + $linesToBeCovered[$file] |
|
| 595 | + ); |
|
| 596 | + } |
|
| 597 | + |
|
| 598 | + foreach (array_keys($linesToBeUsed) as $file) { |
|
| 599 | + if (!isset($allowedLines[$file])) { |
|
| 600 | + $allowedLines[$file] = []; |
|
| 601 | + } |
|
| 602 | + |
|
| 603 | + $allowedLines[$file] = array_merge( |
|
| 604 | + $allowedLines[$file], |
|
| 605 | + $linesToBeUsed[$file] |
|
| 606 | + ); |
|
| 607 | + } |
|
| 608 | + |
|
| 609 | + foreach (array_keys($allowedLines) as $file) { |
|
| 610 | + $allowedLines[$file] = array_flip( |
|
| 611 | + array_unique($allowedLines[$file]) |
|
| 612 | + ); |
|
| 613 | + } |
|
| 614 | + |
|
| 615 | + return $allowedLines; |
|
| 616 | + } |
|
| 617 | + |
|
| 618 | + /** |
|
| 619 | + * @throws ReflectionException |
|
| 620 | + */ |
|
| 621 | + private function processUnintentionallyCoveredUnits(array $unintentionallyCoveredUnits): array |
|
| 622 | + { |
|
| 623 | + $unintentionallyCoveredUnits = array_unique($unintentionallyCoveredUnits); |
|
| 624 | + sort($unintentionallyCoveredUnits); |
|
| 625 | + |
|
| 626 | + foreach (array_keys($unintentionallyCoveredUnits) as $k => $v) { |
|
| 627 | + $unit = explode('::', $unintentionallyCoveredUnits[$k]); |
|
| 628 | + |
|
| 629 | + if (count($unit) !== 2) { |
|
| 630 | + continue; |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + try { |
|
| 634 | + $class = new ReflectionClass($unit[0]); |
|
| 635 | + |
|
| 636 | + foreach ($this->parentClassesExcludedFromUnintentionallyCoveredCodeCheck as $parentClass) { |
|
| 637 | + if ($class->isSubclassOf($parentClass)) { |
|
| 638 | + unset($unintentionallyCoveredUnits[$k]); |
|
| 639 | + |
|
| 640 | + break; |
|
| 641 | + } |
|
| 642 | + } |
|
| 643 | + } catch (\ReflectionException $e) { |
|
| 644 | + throw new ReflectionException( |
|
| 645 | + $e->getMessage(), |
|
| 646 | + (int) $e->getCode(), |
|
| 647 | + $e |
|
| 648 | + ); |
|
| 649 | + } |
|
| 650 | + } |
|
| 651 | + |
|
| 652 | + return array_values($unintentionallyCoveredUnits); |
|
| 653 | + } |
|
| 654 | + |
|
| 655 | + private function analyser(): FileAnalyser |
|
| 656 | + { |
|
| 657 | + if ($this->analyser !== null) { |
|
| 658 | + return $this->analyser; |
|
| 659 | + } |
|
| 660 | + |
|
| 661 | + $this->analyser = new ParsingFileAnalyser( |
|
| 662 | + $this->useAnnotationsForIgnoringCode, |
|
| 663 | + $this->ignoreDeprecatedCode |
|
| 664 | + ); |
|
| 665 | + |
|
| 666 | + if ($this->cachesStaticAnalysis()) { |
|
| 667 | + $this->analyser = new CachingFileAnalyser( |
|
| 668 | + $this->cacheDirectory, |
|
| 669 | + $this->analyser |
|
| 670 | + ); |
|
| 671 | + } |
|
| 672 | + |
|
| 673 | + return $this->analyser; |
|
| 674 | + } |
|
| 675 | 675 | } |
@@ -17,74 +17,74 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | final class Iterator implements RecursiveIterator |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @var int |
|
| 22 | - */ |
|
| 23 | - private $position; |
|
| 20 | + /** |
|
| 21 | + * @var int |
|
| 22 | + */ |
|
| 23 | + private $position; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var AbstractNode[] |
|
| 27 | - */ |
|
| 28 | - private $nodes; |
|
| 25 | + /** |
|
| 26 | + * @var AbstractNode[] |
|
| 27 | + */ |
|
| 28 | + private $nodes; |
|
| 29 | 29 | |
| 30 | - public function __construct(Directory $node) |
|
| 31 | - { |
|
| 32 | - $this->nodes = $node->children(); |
|
| 33 | - } |
|
| 30 | + public function __construct(Directory $node) |
|
| 31 | + { |
|
| 32 | + $this->nodes = $node->children(); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Rewinds the Iterator to the first element. |
|
| 37 | - */ |
|
| 38 | - public function rewind(): void |
|
| 39 | - { |
|
| 40 | - $this->position = 0; |
|
| 41 | - } |
|
| 35 | + /** |
|
| 36 | + * Rewinds the Iterator to the first element. |
|
| 37 | + */ |
|
| 38 | + public function rewind(): void |
|
| 39 | + { |
|
| 40 | + $this->position = 0; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Checks if there is a current element after calls to rewind() or next(). |
|
| 45 | - */ |
|
| 46 | - public function valid(): bool |
|
| 47 | - { |
|
| 48 | - return $this->position < count($this->nodes); |
|
| 49 | - } |
|
| 43 | + /** |
|
| 44 | + * Checks if there is a current element after calls to rewind() or next(). |
|
| 45 | + */ |
|
| 46 | + public function valid(): bool |
|
| 47 | + { |
|
| 48 | + return $this->position < count($this->nodes); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Returns the key of the current element. |
|
| 53 | - */ |
|
| 54 | - public function key(): int |
|
| 55 | - { |
|
| 56 | - return $this->position; |
|
| 57 | - } |
|
| 51 | + /** |
|
| 52 | + * Returns the key of the current element. |
|
| 53 | + */ |
|
| 54 | + public function key(): int |
|
| 55 | + { |
|
| 56 | + return $this->position; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Returns the current element. |
|
| 61 | - */ |
|
| 62 | - public function current(): ?AbstractNode |
|
| 63 | - { |
|
| 64 | - return $this->valid() ? $this->nodes[$this->position] : null; |
|
| 65 | - } |
|
| 59 | + /** |
|
| 60 | + * Returns the current element. |
|
| 61 | + */ |
|
| 62 | + public function current(): ?AbstractNode |
|
| 63 | + { |
|
| 64 | + return $this->valid() ? $this->nodes[$this->position] : null; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * Moves forward to next element. |
|
| 69 | - */ |
|
| 70 | - public function next(): void |
|
| 71 | - { |
|
| 72 | - $this->position++; |
|
| 73 | - } |
|
| 67 | + /** |
|
| 68 | + * Moves forward to next element. |
|
| 69 | + */ |
|
| 70 | + public function next(): void |
|
| 71 | + { |
|
| 72 | + $this->position++; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Returns the sub iterator for the current element. |
|
| 77 | - */ |
|
| 78 | - public function getChildren(): self |
|
| 79 | - { |
|
| 80 | - return new self($this->nodes[$this->position]); |
|
| 81 | - } |
|
| 75 | + /** |
|
| 76 | + * Returns the sub iterator for the current element. |
|
| 77 | + */ |
|
| 78 | + public function getChildren(): self |
|
| 79 | + { |
|
| 80 | + return new self($this->nodes[$this->position]); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Checks whether the current element has children. |
|
| 85 | - */ |
|
| 86 | - public function hasChildren(): bool |
|
| 87 | - { |
|
| 88 | - return $this->nodes[$this->position] instanceof Directory; |
|
| 89 | - } |
|
| 83 | + /** |
|
| 84 | + * Checks whether the current element has children. |
|
| 85 | + */ |
|
| 86 | + public function hasChildren(): bool |
|
| 87 | + { |
|
| 88 | + return $this->nodes[$this->position] instanceof Directory; |
|
| 89 | + } |
|
| 90 | 90 | } |
@@ -14,17 +14,17 @@ |
||
| 14 | 14 | |
| 15 | 15 | final class Version |
| 16 | 16 | { |
| 17 | - /** |
|
| 18 | - * @var string |
|
| 19 | - */ |
|
| 20 | - private static $version; |
|
| 17 | + /** |
|
| 18 | + * @var string |
|
| 19 | + */ |
|
| 20 | + private static $version; |
|
| 21 | 21 | |
| 22 | - public static function id(): string |
|
| 23 | - { |
|
| 24 | - if (self::$version === null) { |
|
| 25 | - self::$version = (new VersionId('9.2.18', dirname(__DIR__)))->getVersion(); |
|
| 26 | - } |
|
| 22 | + public static function id(): string |
|
| 23 | + { |
|
| 24 | + if (self::$version === null) { |
|
| 25 | + self::$version = (new VersionId('9.2.18', dirname(__DIR__)))->getVersion(); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - return self::$version; |
|
| 29 | - } |
|
| 28 | + return self::$version; |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -22,282 +22,282 @@ |
||
| 22 | 22 | |
| 23 | 23 | final class Cobertura |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * @throws WriteOperationFailedException |
|
| 27 | - */ |
|
| 28 | - public function process(CodeCoverage $coverage, ?string $target = null): string |
|
| 29 | - { |
|
| 30 | - $time = (string) time(); |
|
| 25 | + /** |
|
| 26 | + * @throws WriteOperationFailedException |
|
| 27 | + */ |
|
| 28 | + public function process(CodeCoverage $coverage, ?string $target = null): string |
|
| 29 | + { |
|
| 30 | + $time = (string) time(); |
|
| 31 | 31 | |
| 32 | - $report = $coverage->getReport(); |
|
| 32 | + $report = $coverage->getReport(); |
|
| 33 | 33 | |
| 34 | - $implementation = new DOMImplementation; |
|
| 34 | + $implementation = new DOMImplementation; |
|
| 35 | 35 | |
| 36 | - $documentType = $implementation->createDocumentType( |
|
| 37 | - 'coverage', |
|
| 38 | - '', |
|
| 39 | - 'http://cobertura.sourceforge.net/xml/coverage-04.dtd' |
|
| 40 | - ); |
|
| 36 | + $documentType = $implementation->createDocumentType( |
|
| 37 | + 'coverage', |
|
| 38 | + '', |
|
| 39 | + 'http://cobertura.sourceforge.net/xml/coverage-04.dtd' |
|
| 40 | + ); |
|
| 41 | 41 | |
| 42 | - $document = $implementation->createDocument('', '', $documentType); |
|
| 43 | - $document->xmlVersion = '1.0'; |
|
| 44 | - $document->encoding = 'UTF-8'; |
|
| 45 | - $document->formatOutput = true; |
|
| 42 | + $document = $implementation->createDocument('', '', $documentType); |
|
| 43 | + $document->xmlVersion = '1.0'; |
|
| 44 | + $document->encoding = 'UTF-8'; |
|
| 45 | + $document->formatOutput = true; |
|
| 46 | 46 | |
| 47 | - $coverageElement = $document->createElement('coverage'); |
|
| 47 | + $coverageElement = $document->createElement('coverage'); |
|
| 48 | 48 | |
| 49 | - $linesValid = $report->numberOfExecutableLines(); |
|
| 50 | - $linesCovered = $report->numberOfExecutedLines(); |
|
| 51 | - $lineRate = $linesValid === 0 ? 0 : ($linesCovered / $linesValid); |
|
| 52 | - $coverageElement->setAttribute('line-rate', (string) $lineRate); |
|
| 49 | + $linesValid = $report->numberOfExecutableLines(); |
|
| 50 | + $linesCovered = $report->numberOfExecutedLines(); |
|
| 51 | + $lineRate = $linesValid === 0 ? 0 : ($linesCovered / $linesValid); |
|
| 52 | + $coverageElement->setAttribute('line-rate', (string) $lineRate); |
|
| 53 | 53 | |
| 54 | - $branchesValid = $report->numberOfExecutableBranches(); |
|
| 55 | - $branchesCovered = $report->numberOfExecutedBranches(); |
|
| 56 | - $branchRate = $branchesValid === 0 ? 0 : ($branchesCovered / $branchesValid); |
|
| 57 | - $coverageElement->setAttribute('branch-rate', (string) $branchRate); |
|
| 54 | + $branchesValid = $report->numberOfExecutableBranches(); |
|
| 55 | + $branchesCovered = $report->numberOfExecutedBranches(); |
|
| 56 | + $branchRate = $branchesValid === 0 ? 0 : ($branchesCovered / $branchesValid); |
|
| 57 | + $coverageElement->setAttribute('branch-rate', (string) $branchRate); |
|
| 58 | 58 | |
| 59 | - $coverageElement->setAttribute('lines-covered', (string) $report->numberOfExecutedLines()); |
|
| 60 | - $coverageElement->setAttribute('lines-valid', (string) $report->numberOfExecutableLines()); |
|
| 61 | - $coverageElement->setAttribute('branches-covered', (string) $report->numberOfExecutedBranches()); |
|
| 62 | - $coverageElement->setAttribute('branches-valid', (string) $report->numberOfExecutableBranches()); |
|
| 63 | - $coverageElement->setAttribute('complexity', ''); |
|
| 64 | - $coverageElement->setAttribute('version', '0.4'); |
|
| 65 | - $coverageElement->setAttribute('timestamp', $time); |
|
| 59 | + $coverageElement->setAttribute('lines-covered', (string) $report->numberOfExecutedLines()); |
|
| 60 | + $coverageElement->setAttribute('lines-valid', (string) $report->numberOfExecutableLines()); |
|
| 61 | + $coverageElement->setAttribute('branches-covered', (string) $report->numberOfExecutedBranches()); |
|
| 62 | + $coverageElement->setAttribute('branches-valid', (string) $report->numberOfExecutableBranches()); |
|
| 63 | + $coverageElement->setAttribute('complexity', ''); |
|
| 64 | + $coverageElement->setAttribute('version', '0.4'); |
|
| 65 | + $coverageElement->setAttribute('timestamp', $time); |
|
| 66 | 66 | |
| 67 | - $document->appendChild($coverageElement); |
|
| 67 | + $document->appendChild($coverageElement); |
|
| 68 | 68 | |
| 69 | - $sourcesElement = $document->createElement('sources'); |
|
| 70 | - $coverageElement->appendChild($sourcesElement); |
|
| 69 | + $sourcesElement = $document->createElement('sources'); |
|
| 70 | + $coverageElement->appendChild($sourcesElement); |
|
| 71 | 71 | |
| 72 | - $sourceElement = $document->createElement('source', $report->pathAsString()); |
|
| 73 | - $sourcesElement->appendChild($sourceElement); |
|
| 72 | + $sourceElement = $document->createElement('source', $report->pathAsString()); |
|
| 73 | + $sourcesElement->appendChild($sourceElement); |
|
| 74 | 74 | |
| 75 | - $packagesElement = $document->createElement('packages'); |
|
| 76 | - $coverageElement->appendChild($packagesElement); |
|
| 75 | + $packagesElement = $document->createElement('packages'); |
|
| 76 | + $coverageElement->appendChild($packagesElement); |
|
| 77 | 77 | |
| 78 | - $complexity = 0; |
|
| 78 | + $complexity = 0; |
|
| 79 | 79 | |
| 80 | - foreach ($report as $item) { |
|
| 81 | - if (!$item instanceof File) { |
|
| 82 | - continue; |
|
| 83 | - } |
|
| 80 | + foreach ($report as $item) { |
|
| 81 | + if (!$item instanceof File) { |
|
| 82 | + continue; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - $packageElement = $document->createElement('package'); |
|
| 86 | - $packageComplexity = 0; |
|
| 85 | + $packageElement = $document->createElement('package'); |
|
| 86 | + $packageComplexity = 0; |
|
| 87 | 87 | |
| 88 | - $packageElement->setAttribute('name', str_replace($report->pathAsString() . DIRECTORY_SEPARATOR, '', $item->pathAsString())); |
|
| 88 | + $packageElement->setAttribute('name', str_replace($report->pathAsString() . DIRECTORY_SEPARATOR, '', $item->pathAsString())); |
|
| 89 | 89 | |
| 90 | - $linesValid = $item->numberOfExecutableLines(); |
|
| 91 | - $linesCovered = $item->numberOfExecutedLines(); |
|
| 92 | - $lineRate = $linesValid === 0 ? 0 : ($linesCovered / $linesValid); |
|
| 90 | + $linesValid = $item->numberOfExecutableLines(); |
|
| 91 | + $linesCovered = $item->numberOfExecutedLines(); |
|
| 92 | + $lineRate = $linesValid === 0 ? 0 : ($linesCovered / $linesValid); |
|
| 93 | 93 | |
| 94 | - $packageElement->setAttribute('line-rate', (string) $lineRate); |
|
| 94 | + $packageElement->setAttribute('line-rate', (string) $lineRate); |
|
| 95 | 95 | |
| 96 | - $branchesValid = $item->numberOfExecutableBranches(); |
|
| 97 | - $branchesCovered = $item->numberOfExecutedBranches(); |
|
| 98 | - $branchRate = $branchesValid === 0 ? 0 : ($branchesCovered / $branchesValid); |
|
| 96 | + $branchesValid = $item->numberOfExecutableBranches(); |
|
| 97 | + $branchesCovered = $item->numberOfExecutedBranches(); |
|
| 98 | + $branchRate = $branchesValid === 0 ? 0 : ($branchesCovered / $branchesValid); |
|
| 99 | 99 | |
| 100 | - $packageElement->setAttribute('branch-rate', (string) $branchRate); |
|
| 100 | + $packageElement->setAttribute('branch-rate', (string) $branchRate); |
|
| 101 | 101 | |
| 102 | - $packageElement->setAttribute('complexity', ''); |
|
| 103 | - $packagesElement->appendChild($packageElement); |
|
| 102 | + $packageElement->setAttribute('complexity', ''); |
|
| 103 | + $packagesElement->appendChild($packageElement); |
|
| 104 | 104 | |
| 105 | - $classesElement = $document->createElement('classes'); |
|
| 105 | + $classesElement = $document->createElement('classes'); |
|
| 106 | 106 | |
| 107 | - $packageElement->appendChild($classesElement); |
|
| 107 | + $packageElement->appendChild($classesElement); |
|
| 108 | 108 | |
| 109 | - $classes = $item->classesAndTraits(); |
|
| 110 | - $coverageData = $item->lineCoverageData(); |
|
| 109 | + $classes = $item->classesAndTraits(); |
|
| 110 | + $coverageData = $item->lineCoverageData(); |
|
| 111 | 111 | |
| 112 | - foreach ($classes as $className => $class) { |
|
| 113 | - $complexity += $class['ccn']; |
|
| 114 | - $packageComplexity += $class['ccn']; |
|
| 112 | + foreach ($classes as $className => $class) { |
|
| 113 | + $complexity += $class['ccn']; |
|
| 114 | + $packageComplexity += $class['ccn']; |
|
| 115 | 115 | |
| 116 | - if (!empty($class['package']['namespace'])) { |
|
| 117 | - $className = $class['package']['namespace'] . '\\' . $className; |
|
| 118 | - } |
|
| 116 | + if (!empty($class['package']['namespace'])) { |
|
| 117 | + $className = $class['package']['namespace'] . '\\' . $className; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - $linesValid = $class['executableLines']; |
|
| 121 | - $linesCovered = $class['executedLines']; |
|
| 122 | - $lineRate = $linesValid === 0 ? 0 : ($linesCovered / $linesValid); |
|
| 120 | + $linesValid = $class['executableLines']; |
|
| 121 | + $linesCovered = $class['executedLines']; |
|
| 122 | + $lineRate = $linesValid === 0 ? 0 : ($linesCovered / $linesValid); |
|
| 123 | 123 | |
| 124 | - $branchesValid = $class['executableBranches']; |
|
| 125 | - $branchesCovered = $class['executedBranches']; |
|
| 126 | - $branchRate = $branchesValid === 0 ? 0 : ($branchesCovered / $branchesValid); |
|
| 124 | + $branchesValid = $class['executableBranches']; |
|
| 125 | + $branchesCovered = $class['executedBranches']; |
|
| 126 | + $branchRate = $branchesValid === 0 ? 0 : ($branchesCovered / $branchesValid); |
|
| 127 | 127 | |
| 128 | - $classElement = $document->createElement('class'); |
|
| 128 | + $classElement = $document->createElement('class'); |
|
| 129 | 129 | |
| 130 | - $classElement->setAttribute('name', $className); |
|
| 131 | - $classElement->setAttribute('filename', str_replace($report->pathAsString() . DIRECTORY_SEPARATOR, '', $item->pathAsString())); |
|
| 132 | - $classElement->setAttribute('line-rate', (string) $lineRate); |
|
| 133 | - $classElement->setAttribute('branch-rate', (string) $branchRate); |
|
| 134 | - $classElement->setAttribute('complexity', (string) $class['ccn']); |
|
| 130 | + $classElement->setAttribute('name', $className); |
|
| 131 | + $classElement->setAttribute('filename', str_replace($report->pathAsString() . DIRECTORY_SEPARATOR, '', $item->pathAsString())); |
|
| 132 | + $classElement->setAttribute('line-rate', (string) $lineRate); |
|
| 133 | + $classElement->setAttribute('branch-rate', (string) $branchRate); |
|
| 134 | + $classElement->setAttribute('complexity', (string) $class['ccn']); |
|
| 135 | 135 | |
| 136 | - $classesElement->appendChild($classElement); |
|
| 136 | + $classesElement->appendChild($classElement); |
|
| 137 | 137 | |
| 138 | - $methodsElement = $document->createElement('methods'); |
|
| 138 | + $methodsElement = $document->createElement('methods'); |
|
| 139 | 139 | |
| 140 | - $classElement->appendChild($methodsElement); |
|
| 140 | + $classElement->appendChild($methodsElement); |
|
| 141 | 141 | |
| 142 | - $classLinesElement = $document->createElement('lines'); |
|
| 142 | + $classLinesElement = $document->createElement('lines'); |
|
| 143 | 143 | |
| 144 | - $classElement->appendChild($classLinesElement); |
|
| 144 | + $classElement->appendChild($classLinesElement); |
|
| 145 | 145 | |
| 146 | - foreach ($class['methods'] as $methodName => $method) { |
|
| 147 | - if ($method['executableLines'] === 0) { |
|
| 148 | - continue; |
|
| 149 | - } |
|
| 146 | + foreach ($class['methods'] as $methodName => $method) { |
|
| 147 | + if ($method['executableLines'] === 0) { |
|
| 148 | + continue; |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - preg_match("/\((.*?)\)/", $method['signature'], $signature); |
|
| 151 | + preg_match("/\((.*?)\)/", $method['signature'], $signature); |
|
| 152 | 152 | |
| 153 | - $linesValid = $method['executableLines']; |
|
| 154 | - $linesCovered = $method['executedLines']; |
|
| 155 | - $lineRate = $linesValid === 0 ? 0 : ($linesCovered / $linesValid); |
|
| 153 | + $linesValid = $method['executableLines']; |
|
| 154 | + $linesCovered = $method['executedLines']; |
|
| 155 | + $lineRate = $linesValid === 0 ? 0 : ($linesCovered / $linesValid); |
|
| 156 | 156 | |
| 157 | - $branchesValid = $method['executableBranches']; |
|
| 158 | - $branchesCovered = $method['executedBranches']; |
|
| 159 | - $branchRate = $branchesValid === 0 ? 0 : ($branchesCovered / $branchesValid); |
|
| 157 | + $branchesValid = $method['executableBranches']; |
|
| 158 | + $branchesCovered = $method['executedBranches']; |
|
| 159 | + $branchRate = $branchesValid === 0 ? 0 : ($branchesCovered / $branchesValid); |
|
| 160 | 160 | |
| 161 | - $methodElement = $document->createElement('method'); |
|
| 161 | + $methodElement = $document->createElement('method'); |
|
| 162 | 162 | |
| 163 | - $methodElement->setAttribute('name', $methodName); |
|
| 164 | - $methodElement->setAttribute('signature', $signature[1]); |
|
| 165 | - $methodElement->setAttribute('line-rate', (string) $lineRate); |
|
| 166 | - $methodElement->setAttribute('branch-rate', (string) $branchRate); |
|
| 167 | - $methodElement->setAttribute('complexity', (string) $method['ccn']); |
|
| 163 | + $methodElement->setAttribute('name', $methodName); |
|
| 164 | + $methodElement->setAttribute('signature', $signature[1]); |
|
| 165 | + $methodElement->setAttribute('line-rate', (string) $lineRate); |
|
| 166 | + $methodElement->setAttribute('branch-rate', (string) $branchRate); |
|
| 167 | + $methodElement->setAttribute('complexity', (string) $method['ccn']); |
|
| 168 | 168 | |
| 169 | - $methodLinesElement = $document->createElement('lines'); |
|
| 169 | + $methodLinesElement = $document->createElement('lines'); |
|
| 170 | 170 | |
| 171 | - $methodElement->appendChild($methodLinesElement); |
|
| 171 | + $methodElement->appendChild($methodLinesElement); |
|
| 172 | 172 | |
| 173 | - foreach (range($method['startLine'], $method['endLine']) as $line) { |
|
| 174 | - if (!isset($coverageData[$line]) || $coverageData[$line] === null) { |
|
| 175 | - continue; |
|
| 176 | - } |
|
| 177 | - $methodLineElement = $document->createElement('line'); |
|
| 173 | + foreach (range($method['startLine'], $method['endLine']) as $line) { |
|
| 174 | + if (!isset($coverageData[$line]) || $coverageData[$line] === null) { |
|
| 175 | + continue; |
|
| 176 | + } |
|
| 177 | + $methodLineElement = $document->createElement('line'); |
|
| 178 | 178 | |
| 179 | - $methodLineElement->setAttribute('number', (string) $line); |
|
| 180 | - $methodLineElement->setAttribute('hits', (string) count($coverageData[$line])); |
|
| 179 | + $methodLineElement->setAttribute('number', (string) $line); |
|
| 180 | + $methodLineElement->setAttribute('hits', (string) count($coverageData[$line])); |
|
| 181 | 181 | |
| 182 | - $methodLinesElement->appendChild($methodLineElement); |
|
| 182 | + $methodLinesElement->appendChild($methodLineElement); |
|
| 183 | 183 | |
| 184 | - $classLineElement = $methodLineElement->cloneNode(); |
|
| 184 | + $classLineElement = $methodLineElement->cloneNode(); |
|
| 185 | 185 | |
| 186 | - $classLinesElement->appendChild($classLineElement); |
|
| 187 | - } |
|
| 186 | + $classLinesElement->appendChild($classLineElement); |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - $methodsElement->appendChild($methodElement); |
|
| 190 | - } |
|
| 191 | - } |
|
| 189 | + $methodsElement->appendChild($methodElement); |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - if ($report->numberOfFunctions() === 0) { |
|
| 194 | - $packageElement->setAttribute('complexity', (string) $packageComplexity); |
|
| 193 | + if ($report->numberOfFunctions() === 0) { |
|
| 194 | + $packageElement->setAttribute('complexity', (string) $packageComplexity); |
|
| 195 | 195 | |
| 196 | - continue; |
|
| 197 | - } |
|
| 196 | + continue; |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - $functionsComplexity = 0; |
|
| 200 | - $functionsLinesValid = 0; |
|
| 201 | - $functionsLinesCovered = 0; |
|
| 202 | - $functionsBranchesValid = 0; |
|
| 203 | - $functionsBranchesCovered = 0; |
|
| 199 | + $functionsComplexity = 0; |
|
| 200 | + $functionsLinesValid = 0; |
|
| 201 | + $functionsLinesCovered = 0; |
|
| 202 | + $functionsBranchesValid = 0; |
|
| 203 | + $functionsBranchesCovered = 0; |
|
| 204 | 204 | |
| 205 | - $classElement = $document->createElement('class'); |
|
| 206 | - $classElement->setAttribute('name', basename($item->pathAsString())); |
|
| 207 | - $classElement->setAttribute('filename', str_replace($report->pathAsString() . DIRECTORY_SEPARATOR, '', $item->pathAsString())); |
|
| 205 | + $classElement = $document->createElement('class'); |
|
| 206 | + $classElement->setAttribute('name', basename($item->pathAsString())); |
|
| 207 | + $classElement->setAttribute('filename', str_replace($report->pathAsString() . DIRECTORY_SEPARATOR, '', $item->pathAsString())); |
|
| 208 | 208 | |
| 209 | - $methodsElement = $document->createElement('methods'); |
|
| 209 | + $methodsElement = $document->createElement('methods'); |
|
| 210 | 210 | |
| 211 | - $classElement->appendChild($methodsElement); |
|
| 211 | + $classElement->appendChild($methodsElement); |
|
| 212 | 212 | |
| 213 | - $classLinesElement = $document->createElement('lines'); |
|
| 213 | + $classLinesElement = $document->createElement('lines'); |
|
| 214 | 214 | |
| 215 | - $classElement->appendChild($classLinesElement); |
|
| 215 | + $classElement->appendChild($classLinesElement); |
|
| 216 | 216 | |
| 217 | - $functions = $report->functions(); |
|
| 217 | + $functions = $report->functions(); |
|
| 218 | 218 | |
| 219 | - foreach ($functions as $functionName => $function) { |
|
| 220 | - if ($function['executableLines'] === 0) { |
|
| 221 | - continue; |
|
| 222 | - } |
|
| 219 | + foreach ($functions as $functionName => $function) { |
|
| 220 | + if ($function['executableLines'] === 0) { |
|
| 221 | + continue; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - $complexity += $function['ccn']; |
|
| 225 | - $packageComplexity += $function['ccn']; |
|
| 226 | - $functionsComplexity += $function['ccn']; |
|
| 224 | + $complexity += $function['ccn']; |
|
| 225 | + $packageComplexity += $function['ccn']; |
|
| 226 | + $functionsComplexity += $function['ccn']; |
|
| 227 | 227 | |
| 228 | - $linesValid = $function['executableLines']; |
|
| 229 | - $linesCovered = $function['executedLines']; |
|
| 230 | - $lineRate = $linesValid === 0 ? 0 : ($linesCovered / $linesValid); |
|
| 228 | + $linesValid = $function['executableLines']; |
|
| 229 | + $linesCovered = $function['executedLines']; |
|
| 230 | + $lineRate = $linesValid === 0 ? 0 : ($linesCovered / $linesValid); |
|
| 231 | 231 | |
| 232 | - $functionsLinesValid += $linesValid; |
|
| 233 | - $functionsLinesCovered += $linesCovered; |
|
| 232 | + $functionsLinesValid += $linesValid; |
|
| 233 | + $functionsLinesCovered += $linesCovered; |
|
| 234 | 234 | |
| 235 | - $branchesValid = $function['executableBranches']; |
|
| 236 | - $branchesCovered = $function['executedBranches']; |
|
| 237 | - $branchRate = $branchesValid === 0 ? 0 : ($branchesCovered / $branchesValid); |
|
| 235 | + $branchesValid = $function['executableBranches']; |
|
| 236 | + $branchesCovered = $function['executedBranches']; |
|
| 237 | + $branchRate = $branchesValid === 0 ? 0 : ($branchesCovered / $branchesValid); |
|
| 238 | 238 | |
| 239 | - $functionsBranchesValid += $branchesValid; |
|
| 240 | - $functionsBranchesCovered += $branchesValid; |
|
| 239 | + $functionsBranchesValid += $branchesValid; |
|
| 240 | + $functionsBranchesCovered += $branchesValid; |
|
| 241 | 241 | |
| 242 | - $methodElement = $document->createElement('method'); |
|
| 242 | + $methodElement = $document->createElement('method'); |
|
| 243 | 243 | |
| 244 | - $methodElement->setAttribute('name', $functionName); |
|
| 245 | - $methodElement->setAttribute('signature', $function['signature']); |
|
| 246 | - $methodElement->setAttribute('line-rate', (string) $lineRate); |
|
| 247 | - $methodElement->setAttribute('branch-rate', (string) $branchRate); |
|
| 248 | - $methodElement->setAttribute('complexity', (string) $function['ccn']); |
|
| 244 | + $methodElement->setAttribute('name', $functionName); |
|
| 245 | + $methodElement->setAttribute('signature', $function['signature']); |
|
| 246 | + $methodElement->setAttribute('line-rate', (string) $lineRate); |
|
| 247 | + $methodElement->setAttribute('branch-rate', (string) $branchRate); |
|
| 248 | + $methodElement->setAttribute('complexity', (string) $function['ccn']); |
|
| 249 | 249 | |
| 250 | - $methodLinesElement = $document->createElement('lines'); |
|
| 250 | + $methodLinesElement = $document->createElement('lines'); |
|
| 251 | 251 | |
| 252 | - $methodElement->appendChild($methodLinesElement); |
|
| 252 | + $methodElement->appendChild($methodLinesElement); |
|
| 253 | 253 | |
| 254 | - foreach (range($function['startLine'], $function['endLine']) as $line) { |
|
| 255 | - if (!isset($coverageData[$line]) || $coverageData[$line] === null) { |
|
| 256 | - continue; |
|
| 257 | - } |
|
| 258 | - $methodLineElement = $document->createElement('line'); |
|
| 254 | + foreach (range($function['startLine'], $function['endLine']) as $line) { |
|
| 255 | + if (!isset($coverageData[$line]) || $coverageData[$line] === null) { |
|
| 256 | + continue; |
|
| 257 | + } |
|
| 258 | + $methodLineElement = $document->createElement('line'); |
|
| 259 | 259 | |
| 260 | - $methodLineElement->setAttribute('number', (string) $line); |
|
| 261 | - $methodLineElement->setAttribute('hits', (string) count($coverageData[$line])); |
|
| 260 | + $methodLineElement->setAttribute('number', (string) $line); |
|
| 261 | + $methodLineElement->setAttribute('hits', (string) count($coverageData[$line])); |
|
| 262 | 262 | |
| 263 | - $methodLinesElement->appendChild($methodLineElement); |
|
| 263 | + $methodLinesElement->appendChild($methodLineElement); |
|
| 264 | 264 | |
| 265 | - $classLineElement = $methodLineElement->cloneNode(); |
|
| 265 | + $classLineElement = $methodLineElement->cloneNode(); |
|
| 266 | 266 | |
| 267 | - $classLinesElement->appendChild($classLineElement); |
|
| 268 | - } |
|
| 267 | + $classLinesElement->appendChild($classLineElement); |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - $methodsElement->appendChild($methodElement); |
|
| 271 | - } |
|
| 270 | + $methodsElement->appendChild($methodElement); |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - $packageElement->setAttribute('complexity', (string) $packageComplexity); |
|
| 273 | + $packageElement->setAttribute('complexity', (string) $packageComplexity); |
|
| 274 | 274 | |
| 275 | - if ($functionsLinesValid === 0) { |
|
| 276 | - continue; |
|
| 277 | - } |
|
| 275 | + if ($functionsLinesValid === 0) { |
|
| 276 | + continue; |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - $lineRate = $functionsLinesCovered / $functionsLinesValid; |
|
| 280 | - $branchRate = $functionsBranchesValid === 0 ? 0 : ($functionsBranchesCovered / $functionsBranchesValid); |
|
| 279 | + $lineRate = $functionsLinesCovered / $functionsLinesValid; |
|
| 280 | + $branchRate = $functionsBranchesValid === 0 ? 0 : ($functionsBranchesCovered / $functionsBranchesValid); |
|
| 281 | 281 | |
| 282 | - $classElement->setAttribute('line-rate', (string) $lineRate); |
|
| 283 | - $classElement->setAttribute('branch-rate', (string) $branchRate); |
|
| 284 | - $classElement->setAttribute('complexity', (string) $functionsComplexity); |
|
| 282 | + $classElement->setAttribute('line-rate', (string) $lineRate); |
|
| 283 | + $classElement->setAttribute('branch-rate', (string) $branchRate); |
|
| 284 | + $classElement->setAttribute('complexity', (string) $functionsComplexity); |
|
| 285 | 285 | |
| 286 | - $classesElement->appendChild($classElement); |
|
| 287 | - } |
|
| 286 | + $classesElement->appendChild($classElement); |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - $coverageElement->setAttribute('complexity', (string) $complexity); |
|
| 289 | + $coverageElement->setAttribute('complexity', (string) $complexity); |
|
| 290 | 290 | |
| 291 | - $buffer = $document->saveXML(); |
|
| 291 | + $buffer = $document->saveXML(); |
|
| 292 | 292 | |
| 293 | - if ($target !== null) { |
|
| 294 | - Filesystem::createDirectory(dirname($target)); |
|
| 293 | + if ($target !== null) { |
|
| 294 | + Filesystem::createDirectory(dirname($target)); |
|
| 295 | 295 | |
| 296 | - if (@file_put_contents($target, $buffer) === false) { |
|
| 297 | - throw new WriteOperationFailedException($target); |
|
| 298 | - } |
|
| 299 | - } |
|
| 296 | + if (@file_put_contents($target, $buffer) === false) { |
|
| 297 | + throw new WriteOperationFailedException($target); |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - return $buffer; |
|
| 302 | - } |
|
| 301 | + return $buffer; |
|
| 302 | + } |
|
| 303 | 303 | } |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | $complexity = 0; |
| 79 | 79 | |
| 80 | 80 | foreach ($report as $item) { |
| 81 | - if (!$item instanceof File) { |
|
| 81 | + if ( ! $item instanceof File) { |
|
| 82 | 82 | continue; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | $packageElement = $document->createElement('package'); |
| 86 | 86 | $packageComplexity = 0; |
| 87 | 87 | |
| 88 | - $packageElement->setAttribute('name', str_replace($report->pathAsString() . DIRECTORY_SEPARATOR, '', $item->pathAsString())); |
|
| 88 | + $packageElement->setAttribute('name', str_replace($report->pathAsString().DIRECTORY_SEPARATOR, '', $item->pathAsString())); |
|
| 89 | 89 | |
| 90 | 90 | $linesValid = $item->numberOfExecutableLines(); |
| 91 | 91 | $linesCovered = $item->numberOfExecutedLines(); |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | $complexity += $class['ccn']; |
| 114 | 114 | $packageComplexity += $class['ccn']; |
| 115 | 115 | |
| 116 | - if (!empty($class['package']['namespace'])) { |
|
| 117 | - $className = $class['package']['namespace'] . '\\' . $className; |
|
| 116 | + if ( ! empty($class['package']['namespace'])) { |
|
| 117 | + $className = $class['package']['namespace'].'\\'.$className; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | $linesValid = $class['executableLines']; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $classElement = $document->createElement('class'); |
| 129 | 129 | |
| 130 | 130 | $classElement->setAttribute('name', $className); |
| 131 | - $classElement->setAttribute('filename', str_replace($report->pathAsString() . DIRECTORY_SEPARATOR, '', $item->pathAsString())); |
|
| 131 | + $classElement->setAttribute('filename', str_replace($report->pathAsString().DIRECTORY_SEPARATOR, '', $item->pathAsString())); |
|
| 132 | 132 | $classElement->setAttribute('line-rate', (string) $lineRate); |
| 133 | 133 | $classElement->setAttribute('branch-rate', (string) $branchRate); |
| 134 | 134 | $classElement->setAttribute('complexity', (string) $class['ccn']); |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | $methodElement->appendChild($methodLinesElement); |
| 172 | 172 | |
| 173 | 173 | foreach (range($method['startLine'], $method['endLine']) as $line) { |
| 174 | - if (!isset($coverageData[$line]) || $coverageData[$line] === null) { |
|
| 174 | + if ( ! isset($coverageData[$line]) || $coverageData[$line] === null) { |
|
| 175 | 175 | continue; |
| 176 | 176 | } |
| 177 | 177 | $methodLineElement = $document->createElement('line'); |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | |
| 205 | 205 | $classElement = $document->createElement('class'); |
| 206 | 206 | $classElement->setAttribute('name', basename($item->pathAsString())); |
| 207 | - $classElement->setAttribute('filename', str_replace($report->pathAsString() . DIRECTORY_SEPARATOR, '', $item->pathAsString())); |
|
| 207 | + $classElement->setAttribute('filename', str_replace($report->pathAsString().DIRECTORY_SEPARATOR, '', $item->pathAsString())); |
|
| 208 | 208 | |
| 209 | 209 | $methodsElement = $document->createElement('methods'); |
| 210 | 210 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $methodElement->appendChild($methodLinesElement); |
| 253 | 253 | |
| 254 | 254 | foreach (range($function['startLine'], $function['endLine']) as $line) { |
| 255 | - if (!isset($coverageData[$line]) || $coverageData[$line] === null) { |
|
| 255 | + if ( ! isset($coverageData[$line]) || $coverageData[$line] === null) { |
|
| 256 | 256 | continue; |
| 257 | 257 | } |
| 258 | 258 | $methodLineElement = $document->createElement('line'); |
@@ -104,1054 +104,1054 @@ |
||
| 104 | 104 | */ |
| 105 | 105 | final class File extends Renderer |
| 106 | 106 | { |
| 107 | - /** |
|
| 108 | - * @psalm-var array<int,true> |
|
| 109 | - */ |
|
| 110 | - private static $keywordTokens = []; |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @var array |
|
| 114 | - */ |
|
| 115 | - private static $formattedSourceCache = []; |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @var int |
|
| 119 | - */ |
|
| 120 | - private $htmlSpecialCharsFlags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE; |
|
| 121 | - |
|
| 122 | - public function render(FileNode $node, string $file): void |
|
| 123 | - { |
|
| 124 | - $templateName = $this->templatePath . ($this->hasBranchCoverage ? 'file_branch.html' : 'file.html'); |
|
| 125 | - $template = new Template($templateName, '{{', '}}'); |
|
| 126 | - $this->setCommonTemplateVariables($template, $node); |
|
| 127 | - |
|
| 128 | - $template->setVar( |
|
| 129 | - [ |
|
| 130 | - 'items' => $this->renderItems($node), |
|
| 131 | - 'lines' => $this->renderSourceWithLineCoverage($node), |
|
| 132 | - 'legend' => '<p><span class="success"><strong>Executed</strong></span><span class="danger"><strong>Not Executed</strong></span><span class="warning"><strong>Dead Code</strong></span></p>', |
|
| 133 | - 'structure' => '', |
|
| 134 | - ] |
|
| 135 | - ); |
|
| 136 | - |
|
| 137 | - $template->renderTo($file . '.html'); |
|
| 138 | - |
|
| 139 | - if ($this->hasBranchCoverage) { |
|
| 140 | - $template->setVar( |
|
| 141 | - [ |
|
| 142 | - 'items' => $this->renderItems($node), |
|
| 143 | - 'lines' => $this->renderSourceWithBranchCoverage($node), |
|
| 144 | - 'legend' => '<p><span class="success"><strong>Fully covered</strong></span><span class="warning"><strong>Partially covered</strong></span><span class="danger"><strong>Not covered</strong></span></p>', |
|
| 145 | - 'structure' => $this->renderBranchStructure($node), |
|
| 146 | - ] |
|
| 147 | - ); |
|
| 148 | - |
|
| 149 | - $template->renderTo($file . '_branch.html'); |
|
| 150 | - |
|
| 151 | - $template->setVar( |
|
| 152 | - [ |
|
| 153 | - 'items' => $this->renderItems($node), |
|
| 154 | - 'lines' => $this->renderSourceWithPathCoverage($node), |
|
| 155 | - 'legend' => '<p><span class="success"><strong>Fully covered</strong></span><span class="warning"><strong>Partially covered</strong></span><span class="danger"><strong>Not covered</strong></span></p>', |
|
| 156 | - 'structure' => $this->renderPathStructure($node), |
|
| 157 | - ] |
|
| 158 | - ); |
|
| 159 | - |
|
| 160 | - $template->renderTo($file . '_path.html'); |
|
| 161 | - } |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - private function renderItems(FileNode $node): string |
|
| 165 | - { |
|
| 166 | - $templateName = $this->templatePath . ($this->hasBranchCoverage ? 'file_item_branch.html' : 'file_item.html'); |
|
| 167 | - $template = new Template($templateName, '{{', '}}'); |
|
| 168 | - |
|
| 169 | - $methodTemplateName = $this->templatePath . ($this->hasBranchCoverage ? 'method_item_branch.html' : 'method_item.html'); |
|
| 170 | - $methodItemTemplate = new Template( |
|
| 171 | - $methodTemplateName, |
|
| 172 | - '{{', |
|
| 173 | - '}}' |
|
| 174 | - ); |
|
| 175 | - |
|
| 176 | - $items = $this->renderItemTemplate( |
|
| 177 | - $template, |
|
| 178 | - [ |
|
| 179 | - 'name' => 'Total', |
|
| 180 | - 'numClasses' => $node->numberOfClassesAndTraits(), |
|
| 181 | - 'numTestedClasses' => $node->numberOfTestedClassesAndTraits(), |
|
| 182 | - 'numMethods' => $node->numberOfFunctionsAndMethods(), |
|
| 183 | - 'numTestedMethods' => $node->numberOfTestedFunctionsAndMethods(), |
|
| 184 | - 'linesExecutedPercent' => $node->percentageOfExecutedLines()->asFloat(), |
|
| 185 | - 'linesExecutedPercentAsString' => $node->percentageOfExecutedLines()->asString(), |
|
| 186 | - 'numExecutedLines' => $node->numberOfExecutedLines(), |
|
| 187 | - 'numExecutableLines' => $node->numberOfExecutableLines(), |
|
| 188 | - 'branchesExecutedPercent' => $node->percentageOfExecutedBranches()->asFloat(), |
|
| 189 | - 'branchesExecutedPercentAsString' => $node->percentageOfExecutedBranches()->asString(), |
|
| 190 | - 'numExecutedBranches' => $node->numberOfExecutedBranches(), |
|
| 191 | - 'numExecutableBranches' => $node->numberOfExecutableBranches(), |
|
| 192 | - 'pathsExecutedPercent' => $node->percentageOfExecutedPaths()->asFloat(), |
|
| 193 | - 'pathsExecutedPercentAsString' => $node->percentageOfExecutedPaths()->asString(), |
|
| 194 | - 'numExecutedPaths' => $node->numberOfExecutedPaths(), |
|
| 195 | - 'numExecutablePaths' => $node->numberOfExecutablePaths(), |
|
| 196 | - 'testedMethodsPercent' => $node->percentageOfTestedFunctionsAndMethods()->asFloat(), |
|
| 197 | - 'testedMethodsPercentAsString' => $node->percentageOfTestedFunctionsAndMethods()->asString(), |
|
| 198 | - 'testedClassesPercent' => $node->percentageOfTestedClassesAndTraits()->asFloat(), |
|
| 199 | - 'testedClassesPercentAsString' => $node->percentageOfTestedClassesAndTraits()->asString(), |
|
| 200 | - 'crap' => '<abbr title="Change Risk Anti-Patterns (CRAP) Index">CRAP</abbr>', |
|
| 201 | - ] |
|
| 202 | - ); |
|
| 203 | - |
|
| 204 | - $items .= $this->renderFunctionItems( |
|
| 205 | - $node->functions(), |
|
| 206 | - $methodItemTemplate |
|
| 207 | - ); |
|
| 208 | - |
|
| 209 | - $items .= $this->renderTraitOrClassItems( |
|
| 210 | - $node->traits(), |
|
| 211 | - $template, |
|
| 212 | - $methodItemTemplate |
|
| 213 | - ); |
|
| 214 | - |
|
| 215 | - $items .= $this->renderTraitOrClassItems( |
|
| 216 | - $node->classes(), |
|
| 217 | - $template, |
|
| 218 | - $methodItemTemplate |
|
| 219 | - ); |
|
| 220 | - |
|
| 221 | - return $items; |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - private function renderTraitOrClassItems(array $items, Template $template, Template $methodItemTemplate): string |
|
| 225 | - { |
|
| 226 | - $buffer = ''; |
|
| 227 | - |
|
| 228 | - if (empty($items)) { |
|
| 229 | - return $buffer; |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - foreach ($items as $name => $item) { |
|
| 233 | - $numMethods = 0; |
|
| 234 | - $numTestedMethods = 0; |
|
| 235 | - |
|
| 236 | - foreach ($item['methods'] as $method) { |
|
| 237 | - if ($method['executableLines'] > 0) { |
|
| 238 | - $numMethods++; |
|
| 239 | - |
|
| 240 | - if ($method['executedLines'] === $method['executableLines']) { |
|
| 241 | - $numTestedMethods++; |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - |
|
| 246 | - if ($item['executableLines'] > 0) { |
|
| 247 | - $numClasses = 1; |
|
| 248 | - $numTestedClasses = $numTestedMethods === $numMethods ? 1 : 0; |
|
| 249 | - $linesExecutedPercentAsString = Percentage::fromFractionAndTotal( |
|
| 250 | - $item['executedLines'], |
|
| 251 | - $item['executableLines'] |
|
| 252 | - )->asString(); |
|
| 253 | - $branchesExecutedPercentAsString = Percentage::fromFractionAndTotal( |
|
| 254 | - $item['executedBranches'], |
|
| 255 | - $item['executableBranches'] |
|
| 256 | - )->asString(); |
|
| 257 | - $pathsExecutedPercentAsString = Percentage::fromFractionAndTotal( |
|
| 258 | - $item['executedPaths'], |
|
| 259 | - $item['executablePaths'] |
|
| 260 | - )->asString(); |
|
| 261 | - } else { |
|
| 262 | - $numClasses = 0; |
|
| 263 | - $numTestedClasses = 0; |
|
| 264 | - $linesExecutedPercentAsString = 'n/a'; |
|
| 265 | - $branchesExecutedPercentAsString = 'n/a'; |
|
| 266 | - $pathsExecutedPercentAsString = 'n/a'; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - $testedMethodsPercentage = Percentage::fromFractionAndTotal( |
|
| 270 | - $numTestedMethods, |
|
| 271 | - $numMethods |
|
| 272 | - ); |
|
| 273 | - |
|
| 274 | - $testedClassesPercentage = Percentage::fromFractionAndTotal( |
|
| 275 | - $numTestedMethods === $numMethods ? 1 : 0, |
|
| 276 | - 1 |
|
| 277 | - ); |
|
| 278 | - |
|
| 279 | - $buffer .= $this->renderItemTemplate( |
|
| 280 | - $template, |
|
| 281 | - [ |
|
| 282 | - 'name' => $this->abbreviateClassName($name), |
|
| 283 | - 'numClasses' => $numClasses, |
|
| 284 | - 'numTestedClasses' => $numTestedClasses, |
|
| 285 | - 'numMethods' => $numMethods, |
|
| 286 | - 'numTestedMethods' => $numTestedMethods, |
|
| 287 | - 'linesExecutedPercent' => Percentage::fromFractionAndTotal( |
|
| 288 | - $item['executedLines'], |
|
| 289 | - $item['executableLines'], |
|
| 290 | - )->asFloat(), |
|
| 291 | - 'linesExecutedPercentAsString' => $linesExecutedPercentAsString, |
|
| 292 | - 'numExecutedLines' => $item['executedLines'], |
|
| 293 | - 'numExecutableLines' => $item['executableLines'], |
|
| 294 | - 'branchesExecutedPercent' => Percentage::fromFractionAndTotal( |
|
| 295 | - $item['executedBranches'], |
|
| 296 | - $item['executableBranches'], |
|
| 297 | - )->asFloat(), |
|
| 298 | - 'branchesExecutedPercentAsString' => $branchesExecutedPercentAsString, |
|
| 299 | - 'numExecutedBranches' => $item['executedBranches'], |
|
| 300 | - 'numExecutableBranches' => $item['executableBranches'], |
|
| 301 | - 'pathsExecutedPercent' => Percentage::fromFractionAndTotal( |
|
| 302 | - $item['executedPaths'], |
|
| 303 | - $item['executablePaths'] |
|
| 304 | - )->asFloat(), |
|
| 305 | - 'pathsExecutedPercentAsString' => $pathsExecutedPercentAsString, |
|
| 306 | - 'numExecutedPaths' => $item['executedPaths'], |
|
| 307 | - 'numExecutablePaths' => $item['executablePaths'], |
|
| 308 | - 'testedMethodsPercent' => $testedMethodsPercentage->asFloat(), |
|
| 309 | - 'testedMethodsPercentAsString' => $testedMethodsPercentage->asString(), |
|
| 310 | - 'testedClassesPercent' => $testedClassesPercentage->asFloat(), |
|
| 311 | - 'testedClassesPercentAsString' => $testedClassesPercentage->asString(), |
|
| 312 | - 'crap' => $item['crap'], |
|
| 313 | - ] |
|
| 314 | - ); |
|
| 315 | - |
|
| 316 | - foreach ($item['methods'] as $method) { |
|
| 317 | - $buffer .= $this->renderFunctionOrMethodItem( |
|
| 318 | - $methodItemTemplate, |
|
| 319 | - $method, |
|
| 320 | - ' ' |
|
| 321 | - ); |
|
| 322 | - } |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - return $buffer; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - private function renderFunctionItems(array $functions, Template $template): string |
|
| 329 | - { |
|
| 330 | - if (empty($functions)) { |
|
| 331 | - return ''; |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - $buffer = ''; |
|
| 335 | - |
|
| 336 | - foreach ($functions as $function) { |
|
| 337 | - $buffer .= $this->renderFunctionOrMethodItem( |
|
| 338 | - $template, |
|
| 339 | - $function |
|
| 340 | - ); |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - return $buffer; |
|
| 344 | - } |
|
| 345 | - |
|
| 346 | - private function renderFunctionOrMethodItem(Template $template, array $item, string $indent = ''): string |
|
| 347 | - { |
|
| 348 | - $numMethods = 0; |
|
| 349 | - $numTestedMethods = 0; |
|
| 350 | - |
|
| 351 | - if ($item['executableLines'] > 0) { |
|
| 352 | - $numMethods = 1; |
|
| 353 | - |
|
| 354 | - if ($item['executedLines'] === $item['executableLines']) { |
|
| 355 | - $numTestedMethods = 1; |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - $executedLinesPercentage = Percentage::fromFractionAndTotal( |
|
| 360 | - $item['executedLines'], |
|
| 361 | - $item['executableLines'] |
|
| 362 | - ); |
|
| 363 | - |
|
| 364 | - $executedBranchesPercentage = Percentage::fromFractionAndTotal( |
|
| 365 | - $item['executedBranches'], |
|
| 366 | - $item['executableBranches'] |
|
| 367 | - ); |
|
| 368 | - |
|
| 369 | - $executedPathsPercentage = Percentage::fromFractionAndTotal( |
|
| 370 | - $item['executedPaths'], |
|
| 371 | - $item['executablePaths'] |
|
| 372 | - ); |
|
| 373 | - |
|
| 374 | - $testedMethodsPercentage = Percentage::fromFractionAndTotal( |
|
| 375 | - $numTestedMethods, |
|
| 376 | - 1 |
|
| 377 | - ); |
|
| 378 | - |
|
| 379 | - return $this->renderItemTemplate( |
|
| 380 | - $template, |
|
| 381 | - [ |
|
| 382 | - 'name' => sprintf( |
|
| 383 | - '%s<a href="#%d"><abbr title="%s">%s</abbr></a>', |
|
| 384 | - $indent, |
|
| 385 | - $item['startLine'], |
|
| 386 | - htmlspecialchars($item['signature'], $this->htmlSpecialCharsFlags), |
|
| 387 | - $item['functionName'] ?? $item['methodName'] |
|
| 388 | - ), |
|
| 389 | - 'numMethods' => $numMethods, |
|
| 390 | - 'numTestedMethods' => $numTestedMethods, |
|
| 391 | - 'linesExecutedPercent' => $executedLinesPercentage->asFloat(), |
|
| 392 | - 'linesExecutedPercentAsString' => $executedLinesPercentage->asString(), |
|
| 393 | - 'numExecutedLines' => $item['executedLines'], |
|
| 394 | - 'numExecutableLines' => $item['executableLines'], |
|
| 395 | - 'branchesExecutedPercent' => $executedBranchesPercentage->asFloat(), |
|
| 396 | - 'branchesExecutedPercentAsString' => $executedBranchesPercentage->asString(), |
|
| 397 | - 'numExecutedBranches' => $item['executedBranches'], |
|
| 398 | - 'numExecutableBranches' => $item['executableBranches'], |
|
| 399 | - 'pathsExecutedPercent' => $executedPathsPercentage->asFloat(), |
|
| 400 | - 'pathsExecutedPercentAsString' => $executedPathsPercentage->asString(), |
|
| 401 | - 'numExecutedPaths' => $item['executedPaths'], |
|
| 402 | - 'numExecutablePaths' => $item['executablePaths'], |
|
| 403 | - 'testedMethodsPercent' => $testedMethodsPercentage->asFloat(), |
|
| 404 | - 'testedMethodsPercentAsString' => $testedMethodsPercentage->asString(), |
|
| 405 | - 'crap' => $item['crap'], |
|
| 406 | - ] |
|
| 407 | - ); |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - private function renderSourceWithLineCoverage(FileNode $node): string |
|
| 411 | - { |
|
| 412 | - $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 413 | - $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 414 | - |
|
| 415 | - $coverageData = $node->lineCoverageData(); |
|
| 416 | - $testData = $node->testData(); |
|
| 417 | - $codeLines = $this->loadFile($node->pathAsString()); |
|
| 418 | - $lines = ''; |
|
| 419 | - $i = 1; |
|
| 420 | - |
|
| 421 | - foreach ($codeLines as $line) { |
|
| 422 | - $trClass = ''; |
|
| 423 | - $popoverContent = ''; |
|
| 424 | - $popoverTitle = ''; |
|
| 425 | - |
|
| 426 | - if (array_key_exists($i, $coverageData)) { |
|
| 427 | - $numTests = ($coverageData[$i] ? count($coverageData[$i]) : 0); |
|
| 428 | - |
|
| 429 | - if ($coverageData[$i] === null) { |
|
| 430 | - $trClass = 'warning'; |
|
| 431 | - } elseif ($numTests === 0) { |
|
| 432 | - $trClass = 'danger'; |
|
| 433 | - } else { |
|
| 434 | - if ($numTests > 1) { |
|
| 435 | - $popoverTitle = $numTests . ' tests cover line ' . $i; |
|
| 436 | - } else { |
|
| 437 | - $popoverTitle = '1 test covers line ' . $i; |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - $lineCss = 'covered-by-large-tests'; |
|
| 441 | - $popoverContent = '<ul>'; |
|
| 442 | - |
|
| 443 | - foreach ($coverageData[$i] as $test) { |
|
| 444 | - if ($lineCss === 'covered-by-large-tests' && $testData[$test]['size'] === 'medium') { |
|
| 445 | - $lineCss = 'covered-by-medium-tests'; |
|
| 446 | - } elseif ($testData[$test]['size'] === 'small') { |
|
| 447 | - $lineCss = 'covered-by-small-tests'; |
|
| 448 | - } |
|
| 449 | - |
|
| 450 | - $popoverContent .= $this->createPopoverContentForTest($test, $testData[$test]); |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - $popoverContent .= '</ul>'; |
|
| 454 | - $trClass = $lineCss . ' popin'; |
|
| 455 | - } |
|
| 456 | - } |
|
| 457 | - |
|
| 458 | - $popover = ''; |
|
| 459 | - |
|
| 460 | - if (!empty($popoverTitle)) { |
|
| 461 | - $popover = sprintf( |
|
| 462 | - ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
|
| 463 | - $popoverTitle, |
|
| 464 | - htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags) |
|
| 465 | - ); |
|
| 466 | - } |
|
| 467 | - |
|
| 468 | - $lines .= $this->renderLine($singleLineTemplate, $i, $line, $trClass, $popover); |
|
| 469 | - |
|
| 470 | - $i++; |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - $linesTemplate->setVar(['lines' => $lines]); |
|
| 474 | - |
|
| 475 | - return $linesTemplate->render(); |
|
| 476 | - } |
|
| 477 | - |
|
| 478 | - private function renderSourceWithBranchCoverage(FileNode $node): string |
|
| 479 | - { |
|
| 480 | - $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 481 | - $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 482 | - |
|
| 483 | - $functionCoverageData = $node->functionCoverageData(); |
|
| 484 | - $testData = $node->testData(); |
|
| 485 | - $codeLines = $this->loadFile($node->pathAsString()); |
|
| 486 | - |
|
| 487 | - $lineData = []; |
|
| 488 | - |
|
| 489 | - /** @var int $line */ |
|
| 490 | - foreach (array_keys($codeLines) as $line) { |
|
| 491 | - $lineData[$line + 1] = [ |
|
| 492 | - 'includedInBranches' => 0, |
|
| 493 | - 'includedInHitBranches' => 0, |
|
| 494 | - 'tests' => [], |
|
| 495 | - ]; |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - foreach ($functionCoverageData as $method) { |
|
| 499 | - foreach ($method['branches'] as $branch) { |
|
| 500 | - foreach (range($branch['line_start'], $branch['line_end']) as $line) { |
|
| 501 | - if (!isset($lineData[$line])) { // blank line at end of file is sometimes included here |
|
| 502 | - continue; |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - $lineData[$line]['includedInBranches']++; |
|
| 506 | - |
|
| 507 | - if ($branch['hit']) { |
|
| 508 | - $lineData[$line]['includedInHitBranches']++; |
|
| 509 | - $lineData[$line]['tests'] = array_unique(array_merge($lineData[$line]['tests'], $branch['hit'])); |
|
| 510 | - } |
|
| 511 | - } |
|
| 512 | - } |
|
| 513 | - } |
|
| 514 | - |
|
| 515 | - $lines = ''; |
|
| 516 | - $i = 1; |
|
| 517 | - |
|
| 518 | - /** @var string $line */ |
|
| 519 | - foreach ($codeLines as $line) { |
|
| 520 | - $trClass = ''; |
|
| 521 | - $popover = ''; |
|
| 522 | - |
|
| 523 | - if ($lineData[$i]['includedInBranches'] > 0) { |
|
| 524 | - $lineCss = 'success'; |
|
| 525 | - |
|
| 526 | - if ($lineData[$i]['includedInHitBranches'] === 0) { |
|
| 527 | - $lineCss = 'danger'; |
|
| 528 | - } elseif ($lineData[$i]['includedInHitBranches'] !== $lineData[$i]['includedInBranches']) { |
|
| 529 | - $lineCss = 'warning'; |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - $popoverContent = '<ul>'; |
|
| 533 | - |
|
| 534 | - if (count($lineData[$i]['tests']) === 1) { |
|
| 535 | - $popoverTitle = '1 test covers line ' . $i; |
|
| 536 | - } else { |
|
| 537 | - $popoverTitle = count($lineData[$i]['tests']) . ' tests cover line ' . $i; |
|
| 538 | - } |
|
| 539 | - $popoverTitle .= '. These are covering ' . $lineData[$i]['includedInHitBranches'] . ' out of the ' . $lineData[$i]['includedInBranches'] . ' code branches.'; |
|
| 540 | - |
|
| 541 | - foreach ($lineData[$i]['tests'] as $test) { |
|
| 542 | - $popoverContent .= $this->createPopoverContentForTest($test, $testData[$test]); |
|
| 543 | - } |
|
| 544 | - |
|
| 545 | - $popoverContent .= '</ul>'; |
|
| 546 | - $trClass = $lineCss . ' popin'; |
|
| 547 | - |
|
| 548 | - $popover = sprintf( |
|
| 549 | - ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
|
| 550 | - $popoverTitle, |
|
| 551 | - htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags) |
|
| 552 | - ); |
|
| 553 | - } |
|
| 554 | - |
|
| 555 | - $lines .= $this->renderLine($singleLineTemplate, $i, $line, $trClass, $popover); |
|
| 556 | - |
|
| 557 | - $i++; |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - $linesTemplate->setVar(['lines' => $lines]); |
|
| 561 | - |
|
| 562 | - return $linesTemplate->render(); |
|
| 563 | - } |
|
| 564 | - |
|
| 565 | - private function renderSourceWithPathCoverage(FileNode $node): string |
|
| 566 | - { |
|
| 567 | - $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 568 | - $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 569 | - |
|
| 570 | - $functionCoverageData = $node->functionCoverageData(); |
|
| 571 | - $testData = $node->testData(); |
|
| 572 | - $codeLines = $this->loadFile($node->pathAsString()); |
|
| 573 | - |
|
| 574 | - $lineData = []; |
|
| 575 | - |
|
| 576 | - /** @var int $line */ |
|
| 577 | - foreach (array_keys($codeLines) as $line) { |
|
| 578 | - $lineData[$line + 1] = [ |
|
| 579 | - 'includedInPaths' => [], |
|
| 580 | - 'includedInHitPaths' => [], |
|
| 581 | - 'tests' => [], |
|
| 582 | - ]; |
|
| 583 | - } |
|
| 584 | - |
|
| 585 | - foreach ($functionCoverageData as $method) { |
|
| 586 | - foreach ($method['paths'] as $pathId => $path) { |
|
| 587 | - foreach ($path['path'] as $branchTaken) { |
|
| 588 | - foreach (range($method['branches'][$branchTaken]['line_start'], $method['branches'][$branchTaken]['line_end']) as $line) { |
|
| 589 | - if (!isset($lineData[$line])) { |
|
| 590 | - continue; |
|
| 591 | - } |
|
| 592 | - $lineData[$line]['includedInPaths'][] = $pathId; |
|
| 593 | - |
|
| 594 | - if ($path['hit']) { |
|
| 595 | - $lineData[$line]['includedInHitPaths'][] = $pathId; |
|
| 596 | - $lineData[$line]['tests'] = array_unique(array_merge($lineData[$line]['tests'], $path['hit'])); |
|
| 597 | - } |
|
| 598 | - } |
|
| 599 | - } |
|
| 600 | - } |
|
| 601 | - } |
|
| 602 | - |
|
| 603 | - $lines = ''; |
|
| 604 | - $i = 1; |
|
| 605 | - |
|
| 606 | - /** @var string $line */ |
|
| 607 | - foreach ($codeLines as $line) { |
|
| 608 | - $trClass = ''; |
|
| 609 | - $popover = ''; |
|
| 610 | - $includedInPathsCount = count(array_unique($lineData[$i]['includedInPaths'])); |
|
| 611 | - $includedInHitPathsCount = count(array_unique($lineData[$i]['includedInHitPaths'])); |
|
| 612 | - |
|
| 613 | - if ($includedInPathsCount > 0) { |
|
| 614 | - $lineCss = 'success'; |
|
| 615 | - |
|
| 616 | - if ($includedInHitPathsCount === 0) { |
|
| 617 | - $lineCss = 'danger'; |
|
| 618 | - } elseif ($includedInHitPathsCount !== $includedInPathsCount) { |
|
| 619 | - $lineCss = 'warning'; |
|
| 620 | - } |
|
| 621 | - |
|
| 622 | - $popoverContent = '<ul>'; |
|
| 623 | - |
|
| 624 | - if (count($lineData[$i]['tests']) === 1) { |
|
| 625 | - $popoverTitle = '1 test covers line ' . $i; |
|
| 626 | - } else { |
|
| 627 | - $popoverTitle = count($lineData[$i]['tests']) . ' tests cover line ' . $i; |
|
| 628 | - } |
|
| 629 | - $popoverTitle .= '. These are covering ' . $includedInHitPathsCount . ' out of the ' . $includedInPathsCount . ' code paths.'; |
|
| 630 | - |
|
| 631 | - foreach ($lineData[$i]['tests'] as $test) { |
|
| 632 | - $popoverContent .= $this->createPopoverContentForTest($test, $testData[$test]); |
|
| 633 | - } |
|
| 634 | - |
|
| 635 | - $popoverContent .= '</ul>'; |
|
| 636 | - $trClass = $lineCss . ' popin'; |
|
| 637 | - |
|
| 638 | - $popover = sprintf( |
|
| 639 | - ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
|
| 640 | - $popoverTitle, |
|
| 641 | - htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags) |
|
| 642 | - ); |
|
| 643 | - } |
|
| 644 | - |
|
| 645 | - $lines .= $this->renderLine($singleLineTemplate, $i, $line, $trClass, $popover); |
|
| 646 | - |
|
| 647 | - $i++; |
|
| 648 | - } |
|
| 649 | - |
|
| 650 | - $linesTemplate->setVar(['lines' => $lines]); |
|
| 651 | - |
|
| 652 | - return $linesTemplate->render(); |
|
| 653 | - } |
|
| 654 | - |
|
| 655 | - private function renderBranchStructure(FileNode $node): string |
|
| 656 | - { |
|
| 657 | - $branchesTemplate = new Template($this->templatePath . 'branches.html.dist', '{{', '}}'); |
|
| 658 | - |
|
| 659 | - $coverageData = $node->functionCoverageData(); |
|
| 660 | - $testData = $node->testData(); |
|
| 661 | - $codeLines = $this->loadFile($node->pathAsString()); |
|
| 662 | - $branches = ''; |
|
| 663 | - |
|
| 664 | - ksort($coverageData); |
|
| 665 | - |
|
| 666 | - foreach ($coverageData as $methodName => $methodData) { |
|
| 667 | - if (!$methodData['branches']) { |
|
| 668 | - continue; |
|
| 669 | - } |
|
| 670 | - |
|
| 671 | - $branchStructure = ''; |
|
| 672 | - |
|
| 673 | - foreach ($methodData['branches'] as $branch) { |
|
| 674 | - $branchStructure .= $this->renderBranchLines($branch, $codeLines, $testData); |
|
| 675 | - } |
|
| 676 | - |
|
| 677 | - if ($branchStructure !== '') { // don't show empty branches |
|
| 678 | - $branches .= '<h5 class="structure-heading"><a name="' . htmlspecialchars($methodName, $this->htmlSpecialCharsFlags) . '">' . $this->abbreviateMethodName($methodName) . '</a></h5>' . "\n"; |
|
| 679 | - $branches .= $branchStructure; |
|
| 680 | - } |
|
| 681 | - } |
|
| 682 | - |
|
| 683 | - $branchesTemplate->setVar(['branches' => $branches]); |
|
| 684 | - |
|
| 685 | - return $branchesTemplate->render(); |
|
| 686 | - } |
|
| 687 | - |
|
| 688 | - private function renderBranchLines(array $branch, array $codeLines, array $testData): string |
|
| 689 | - { |
|
| 690 | - $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 691 | - $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 107 | + /** |
|
| 108 | + * @psalm-var array<int,true> |
|
| 109 | + */ |
|
| 110 | + private static $keywordTokens = []; |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @var array |
|
| 114 | + */ |
|
| 115 | + private static $formattedSourceCache = []; |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @var int |
|
| 119 | + */ |
|
| 120 | + private $htmlSpecialCharsFlags = ENT_COMPAT | ENT_HTML401 | ENT_SUBSTITUTE; |
|
| 121 | + |
|
| 122 | + public function render(FileNode $node, string $file): void |
|
| 123 | + { |
|
| 124 | + $templateName = $this->templatePath . ($this->hasBranchCoverage ? 'file_branch.html' : 'file.html'); |
|
| 125 | + $template = new Template($templateName, '{{', '}}'); |
|
| 126 | + $this->setCommonTemplateVariables($template, $node); |
|
| 127 | + |
|
| 128 | + $template->setVar( |
|
| 129 | + [ |
|
| 130 | + 'items' => $this->renderItems($node), |
|
| 131 | + 'lines' => $this->renderSourceWithLineCoverage($node), |
|
| 132 | + 'legend' => '<p><span class="success"><strong>Executed</strong></span><span class="danger"><strong>Not Executed</strong></span><span class="warning"><strong>Dead Code</strong></span></p>', |
|
| 133 | + 'structure' => '', |
|
| 134 | + ] |
|
| 135 | + ); |
|
| 136 | + |
|
| 137 | + $template->renderTo($file . '.html'); |
|
| 138 | + |
|
| 139 | + if ($this->hasBranchCoverage) { |
|
| 140 | + $template->setVar( |
|
| 141 | + [ |
|
| 142 | + 'items' => $this->renderItems($node), |
|
| 143 | + 'lines' => $this->renderSourceWithBranchCoverage($node), |
|
| 144 | + 'legend' => '<p><span class="success"><strong>Fully covered</strong></span><span class="warning"><strong>Partially covered</strong></span><span class="danger"><strong>Not covered</strong></span></p>', |
|
| 145 | + 'structure' => $this->renderBranchStructure($node), |
|
| 146 | + ] |
|
| 147 | + ); |
|
| 148 | + |
|
| 149 | + $template->renderTo($file . '_branch.html'); |
|
| 150 | + |
|
| 151 | + $template->setVar( |
|
| 152 | + [ |
|
| 153 | + 'items' => $this->renderItems($node), |
|
| 154 | + 'lines' => $this->renderSourceWithPathCoverage($node), |
|
| 155 | + 'legend' => '<p><span class="success"><strong>Fully covered</strong></span><span class="warning"><strong>Partially covered</strong></span><span class="danger"><strong>Not covered</strong></span></p>', |
|
| 156 | + 'structure' => $this->renderPathStructure($node), |
|
| 157 | + ] |
|
| 158 | + ); |
|
| 159 | + |
|
| 160 | + $template->renderTo($file . '_path.html'); |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + private function renderItems(FileNode $node): string |
|
| 165 | + { |
|
| 166 | + $templateName = $this->templatePath . ($this->hasBranchCoverage ? 'file_item_branch.html' : 'file_item.html'); |
|
| 167 | + $template = new Template($templateName, '{{', '}}'); |
|
| 168 | + |
|
| 169 | + $methodTemplateName = $this->templatePath . ($this->hasBranchCoverage ? 'method_item_branch.html' : 'method_item.html'); |
|
| 170 | + $methodItemTemplate = new Template( |
|
| 171 | + $methodTemplateName, |
|
| 172 | + '{{', |
|
| 173 | + '}}' |
|
| 174 | + ); |
|
| 175 | + |
|
| 176 | + $items = $this->renderItemTemplate( |
|
| 177 | + $template, |
|
| 178 | + [ |
|
| 179 | + 'name' => 'Total', |
|
| 180 | + 'numClasses' => $node->numberOfClassesAndTraits(), |
|
| 181 | + 'numTestedClasses' => $node->numberOfTestedClassesAndTraits(), |
|
| 182 | + 'numMethods' => $node->numberOfFunctionsAndMethods(), |
|
| 183 | + 'numTestedMethods' => $node->numberOfTestedFunctionsAndMethods(), |
|
| 184 | + 'linesExecutedPercent' => $node->percentageOfExecutedLines()->asFloat(), |
|
| 185 | + 'linesExecutedPercentAsString' => $node->percentageOfExecutedLines()->asString(), |
|
| 186 | + 'numExecutedLines' => $node->numberOfExecutedLines(), |
|
| 187 | + 'numExecutableLines' => $node->numberOfExecutableLines(), |
|
| 188 | + 'branchesExecutedPercent' => $node->percentageOfExecutedBranches()->asFloat(), |
|
| 189 | + 'branchesExecutedPercentAsString' => $node->percentageOfExecutedBranches()->asString(), |
|
| 190 | + 'numExecutedBranches' => $node->numberOfExecutedBranches(), |
|
| 191 | + 'numExecutableBranches' => $node->numberOfExecutableBranches(), |
|
| 192 | + 'pathsExecutedPercent' => $node->percentageOfExecutedPaths()->asFloat(), |
|
| 193 | + 'pathsExecutedPercentAsString' => $node->percentageOfExecutedPaths()->asString(), |
|
| 194 | + 'numExecutedPaths' => $node->numberOfExecutedPaths(), |
|
| 195 | + 'numExecutablePaths' => $node->numberOfExecutablePaths(), |
|
| 196 | + 'testedMethodsPercent' => $node->percentageOfTestedFunctionsAndMethods()->asFloat(), |
|
| 197 | + 'testedMethodsPercentAsString' => $node->percentageOfTestedFunctionsAndMethods()->asString(), |
|
| 198 | + 'testedClassesPercent' => $node->percentageOfTestedClassesAndTraits()->asFloat(), |
|
| 199 | + 'testedClassesPercentAsString' => $node->percentageOfTestedClassesAndTraits()->asString(), |
|
| 200 | + 'crap' => '<abbr title="Change Risk Anti-Patterns (CRAP) Index">CRAP</abbr>', |
|
| 201 | + ] |
|
| 202 | + ); |
|
| 203 | + |
|
| 204 | + $items .= $this->renderFunctionItems( |
|
| 205 | + $node->functions(), |
|
| 206 | + $methodItemTemplate |
|
| 207 | + ); |
|
| 208 | + |
|
| 209 | + $items .= $this->renderTraitOrClassItems( |
|
| 210 | + $node->traits(), |
|
| 211 | + $template, |
|
| 212 | + $methodItemTemplate |
|
| 213 | + ); |
|
| 214 | + |
|
| 215 | + $items .= $this->renderTraitOrClassItems( |
|
| 216 | + $node->classes(), |
|
| 217 | + $template, |
|
| 218 | + $methodItemTemplate |
|
| 219 | + ); |
|
| 220 | + |
|
| 221 | + return $items; |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + private function renderTraitOrClassItems(array $items, Template $template, Template $methodItemTemplate): string |
|
| 225 | + { |
|
| 226 | + $buffer = ''; |
|
| 227 | + |
|
| 228 | + if (empty($items)) { |
|
| 229 | + return $buffer; |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + foreach ($items as $name => $item) { |
|
| 233 | + $numMethods = 0; |
|
| 234 | + $numTestedMethods = 0; |
|
| 235 | + |
|
| 236 | + foreach ($item['methods'] as $method) { |
|
| 237 | + if ($method['executableLines'] > 0) { |
|
| 238 | + $numMethods++; |
|
| 239 | + |
|
| 240 | + if ($method['executedLines'] === $method['executableLines']) { |
|
| 241 | + $numTestedMethods++; |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + |
|
| 246 | + if ($item['executableLines'] > 0) { |
|
| 247 | + $numClasses = 1; |
|
| 248 | + $numTestedClasses = $numTestedMethods === $numMethods ? 1 : 0; |
|
| 249 | + $linesExecutedPercentAsString = Percentage::fromFractionAndTotal( |
|
| 250 | + $item['executedLines'], |
|
| 251 | + $item['executableLines'] |
|
| 252 | + )->asString(); |
|
| 253 | + $branchesExecutedPercentAsString = Percentage::fromFractionAndTotal( |
|
| 254 | + $item['executedBranches'], |
|
| 255 | + $item['executableBranches'] |
|
| 256 | + )->asString(); |
|
| 257 | + $pathsExecutedPercentAsString = Percentage::fromFractionAndTotal( |
|
| 258 | + $item['executedPaths'], |
|
| 259 | + $item['executablePaths'] |
|
| 260 | + )->asString(); |
|
| 261 | + } else { |
|
| 262 | + $numClasses = 0; |
|
| 263 | + $numTestedClasses = 0; |
|
| 264 | + $linesExecutedPercentAsString = 'n/a'; |
|
| 265 | + $branchesExecutedPercentAsString = 'n/a'; |
|
| 266 | + $pathsExecutedPercentAsString = 'n/a'; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + $testedMethodsPercentage = Percentage::fromFractionAndTotal( |
|
| 270 | + $numTestedMethods, |
|
| 271 | + $numMethods |
|
| 272 | + ); |
|
| 273 | + |
|
| 274 | + $testedClassesPercentage = Percentage::fromFractionAndTotal( |
|
| 275 | + $numTestedMethods === $numMethods ? 1 : 0, |
|
| 276 | + 1 |
|
| 277 | + ); |
|
| 278 | + |
|
| 279 | + $buffer .= $this->renderItemTemplate( |
|
| 280 | + $template, |
|
| 281 | + [ |
|
| 282 | + 'name' => $this->abbreviateClassName($name), |
|
| 283 | + 'numClasses' => $numClasses, |
|
| 284 | + 'numTestedClasses' => $numTestedClasses, |
|
| 285 | + 'numMethods' => $numMethods, |
|
| 286 | + 'numTestedMethods' => $numTestedMethods, |
|
| 287 | + 'linesExecutedPercent' => Percentage::fromFractionAndTotal( |
|
| 288 | + $item['executedLines'], |
|
| 289 | + $item['executableLines'], |
|
| 290 | + )->asFloat(), |
|
| 291 | + 'linesExecutedPercentAsString' => $linesExecutedPercentAsString, |
|
| 292 | + 'numExecutedLines' => $item['executedLines'], |
|
| 293 | + 'numExecutableLines' => $item['executableLines'], |
|
| 294 | + 'branchesExecutedPercent' => Percentage::fromFractionAndTotal( |
|
| 295 | + $item['executedBranches'], |
|
| 296 | + $item['executableBranches'], |
|
| 297 | + )->asFloat(), |
|
| 298 | + 'branchesExecutedPercentAsString' => $branchesExecutedPercentAsString, |
|
| 299 | + 'numExecutedBranches' => $item['executedBranches'], |
|
| 300 | + 'numExecutableBranches' => $item['executableBranches'], |
|
| 301 | + 'pathsExecutedPercent' => Percentage::fromFractionAndTotal( |
|
| 302 | + $item['executedPaths'], |
|
| 303 | + $item['executablePaths'] |
|
| 304 | + )->asFloat(), |
|
| 305 | + 'pathsExecutedPercentAsString' => $pathsExecutedPercentAsString, |
|
| 306 | + 'numExecutedPaths' => $item['executedPaths'], |
|
| 307 | + 'numExecutablePaths' => $item['executablePaths'], |
|
| 308 | + 'testedMethodsPercent' => $testedMethodsPercentage->asFloat(), |
|
| 309 | + 'testedMethodsPercentAsString' => $testedMethodsPercentage->asString(), |
|
| 310 | + 'testedClassesPercent' => $testedClassesPercentage->asFloat(), |
|
| 311 | + 'testedClassesPercentAsString' => $testedClassesPercentage->asString(), |
|
| 312 | + 'crap' => $item['crap'], |
|
| 313 | + ] |
|
| 314 | + ); |
|
| 315 | + |
|
| 316 | + foreach ($item['methods'] as $method) { |
|
| 317 | + $buffer .= $this->renderFunctionOrMethodItem( |
|
| 318 | + $methodItemTemplate, |
|
| 319 | + $method, |
|
| 320 | + ' ' |
|
| 321 | + ); |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + return $buffer; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + private function renderFunctionItems(array $functions, Template $template): string |
|
| 329 | + { |
|
| 330 | + if (empty($functions)) { |
|
| 331 | + return ''; |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + $buffer = ''; |
|
| 335 | + |
|
| 336 | + foreach ($functions as $function) { |
|
| 337 | + $buffer .= $this->renderFunctionOrMethodItem( |
|
| 338 | + $template, |
|
| 339 | + $function |
|
| 340 | + ); |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + return $buffer; |
|
| 344 | + } |
|
| 345 | + |
|
| 346 | + private function renderFunctionOrMethodItem(Template $template, array $item, string $indent = ''): string |
|
| 347 | + { |
|
| 348 | + $numMethods = 0; |
|
| 349 | + $numTestedMethods = 0; |
|
| 350 | + |
|
| 351 | + if ($item['executableLines'] > 0) { |
|
| 352 | + $numMethods = 1; |
|
| 353 | + |
|
| 354 | + if ($item['executedLines'] === $item['executableLines']) { |
|
| 355 | + $numTestedMethods = 1; |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + $executedLinesPercentage = Percentage::fromFractionAndTotal( |
|
| 360 | + $item['executedLines'], |
|
| 361 | + $item['executableLines'] |
|
| 362 | + ); |
|
| 363 | + |
|
| 364 | + $executedBranchesPercentage = Percentage::fromFractionAndTotal( |
|
| 365 | + $item['executedBranches'], |
|
| 366 | + $item['executableBranches'] |
|
| 367 | + ); |
|
| 368 | + |
|
| 369 | + $executedPathsPercentage = Percentage::fromFractionAndTotal( |
|
| 370 | + $item['executedPaths'], |
|
| 371 | + $item['executablePaths'] |
|
| 372 | + ); |
|
| 373 | + |
|
| 374 | + $testedMethodsPercentage = Percentage::fromFractionAndTotal( |
|
| 375 | + $numTestedMethods, |
|
| 376 | + 1 |
|
| 377 | + ); |
|
| 378 | + |
|
| 379 | + return $this->renderItemTemplate( |
|
| 380 | + $template, |
|
| 381 | + [ |
|
| 382 | + 'name' => sprintf( |
|
| 383 | + '%s<a href="#%d"><abbr title="%s">%s</abbr></a>', |
|
| 384 | + $indent, |
|
| 385 | + $item['startLine'], |
|
| 386 | + htmlspecialchars($item['signature'], $this->htmlSpecialCharsFlags), |
|
| 387 | + $item['functionName'] ?? $item['methodName'] |
|
| 388 | + ), |
|
| 389 | + 'numMethods' => $numMethods, |
|
| 390 | + 'numTestedMethods' => $numTestedMethods, |
|
| 391 | + 'linesExecutedPercent' => $executedLinesPercentage->asFloat(), |
|
| 392 | + 'linesExecutedPercentAsString' => $executedLinesPercentage->asString(), |
|
| 393 | + 'numExecutedLines' => $item['executedLines'], |
|
| 394 | + 'numExecutableLines' => $item['executableLines'], |
|
| 395 | + 'branchesExecutedPercent' => $executedBranchesPercentage->asFloat(), |
|
| 396 | + 'branchesExecutedPercentAsString' => $executedBranchesPercentage->asString(), |
|
| 397 | + 'numExecutedBranches' => $item['executedBranches'], |
|
| 398 | + 'numExecutableBranches' => $item['executableBranches'], |
|
| 399 | + 'pathsExecutedPercent' => $executedPathsPercentage->asFloat(), |
|
| 400 | + 'pathsExecutedPercentAsString' => $executedPathsPercentage->asString(), |
|
| 401 | + 'numExecutedPaths' => $item['executedPaths'], |
|
| 402 | + 'numExecutablePaths' => $item['executablePaths'], |
|
| 403 | + 'testedMethodsPercent' => $testedMethodsPercentage->asFloat(), |
|
| 404 | + 'testedMethodsPercentAsString' => $testedMethodsPercentage->asString(), |
|
| 405 | + 'crap' => $item['crap'], |
|
| 406 | + ] |
|
| 407 | + ); |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + private function renderSourceWithLineCoverage(FileNode $node): string |
|
| 411 | + { |
|
| 412 | + $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 413 | + $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 414 | + |
|
| 415 | + $coverageData = $node->lineCoverageData(); |
|
| 416 | + $testData = $node->testData(); |
|
| 417 | + $codeLines = $this->loadFile($node->pathAsString()); |
|
| 418 | + $lines = ''; |
|
| 419 | + $i = 1; |
|
| 420 | + |
|
| 421 | + foreach ($codeLines as $line) { |
|
| 422 | + $trClass = ''; |
|
| 423 | + $popoverContent = ''; |
|
| 424 | + $popoverTitle = ''; |
|
| 425 | + |
|
| 426 | + if (array_key_exists($i, $coverageData)) { |
|
| 427 | + $numTests = ($coverageData[$i] ? count($coverageData[$i]) : 0); |
|
| 428 | + |
|
| 429 | + if ($coverageData[$i] === null) { |
|
| 430 | + $trClass = 'warning'; |
|
| 431 | + } elseif ($numTests === 0) { |
|
| 432 | + $trClass = 'danger'; |
|
| 433 | + } else { |
|
| 434 | + if ($numTests > 1) { |
|
| 435 | + $popoverTitle = $numTests . ' tests cover line ' . $i; |
|
| 436 | + } else { |
|
| 437 | + $popoverTitle = '1 test covers line ' . $i; |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + $lineCss = 'covered-by-large-tests'; |
|
| 441 | + $popoverContent = '<ul>'; |
|
| 442 | + |
|
| 443 | + foreach ($coverageData[$i] as $test) { |
|
| 444 | + if ($lineCss === 'covered-by-large-tests' && $testData[$test]['size'] === 'medium') { |
|
| 445 | + $lineCss = 'covered-by-medium-tests'; |
|
| 446 | + } elseif ($testData[$test]['size'] === 'small') { |
|
| 447 | + $lineCss = 'covered-by-small-tests'; |
|
| 448 | + } |
|
| 449 | + |
|
| 450 | + $popoverContent .= $this->createPopoverContentForTest($test, $testData[$test]); |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + $popoverContent .= '</ul>'; |
|
| 454 | + $trClass = $lineCss . ' popin'; |
|
| 455 | + } |
|
| 456 | + } |
|
| 457 | + |
|
| 458 | + $popover = ''; |
|
| 459 | + |
|
| 460 | + if (!empty($popoverTitle)) { |
|
| 461 | + $popover = sprintf( |
|
| 462 | + ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
|
| 463 | + $popoverTitle, |
|
| 464 | + htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags) |
|
| 465 | + ); |
|
| 466 | + } |
|
| 467 | + |
|
| 468 | + $lines .= $this->renderLine($singleLineTemplate, $i, $line, $trClass, $popover); |
|
| 469 | + |
|
| 470 | + $i++; |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + $linesTemplate->setVar(['lines' => $lines]); |
|
| 474 | + |
|
| 475 | + return $linesTemplate->render(); |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + private function renderSourceWithBranchCoverage(FileNode $node): string |
|
| 479 | + { |
|
| 480 | + $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 481 | + $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 482 | + |
|
| 483 | + $functionCoverageData = $node->functionCoverageData(); |
|
| 484 | + $testData = $node->testData(); |
|
| 485 | + $codeLines = $this->loadFile($node->pathAsString()); |
|
| 486 | + |
|
| 487 | + $lineData = []; |
|
| 488 | + |
|
| 489 | + /** @var int $line */ |
|
| 490 | + foreach (array_keys($codeLines) as $line) { |
|
| 491 | + $lineData[$line + 1] = [ |
|
| 492 | + 'includedInBranches' => 0, |
|
| 493 | + 'includedInHitBranches' => 0, |
|
| 494 | + 'tests' => [], |
|
| 495 | + ]; |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + foreach ($functionCoverageData as $method) { |
|
| 499 | + foreach ($method['branches'] as $branch) { |
|
| 500 | + foreach (range($branch['line_start'], $branch['line_end']) as $line) { |
|
| 501 | + if (!isset($lineData[$line])) { // blank line at end of file is sometimes included here |
|
| 502 | + continue; |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + $lineData[$line]['includedInBranches']++; |
|
| 506 | + |
|
| 507 | + if ($branch['hit']) { |
|
| 508 | + $lineData[$line]['includedInHitBranches']++; |
|
| 509 | + $lineData[$line]['tests'] = array_unique(array_merge($lineData[$line]['tests'], $branch['hit'])); |
|
| 510 | + } |
|
| 511 | + } |
|
| 512 | + } |
|
| 513 | + } |
|
| 514 | + |
|
| 515 | + $lines = ''; |
|
| 516 | + $i = 1; |
|
| 517 | + |
|
| 518 | + /** @var string $line */ |
|
| 519 | + foreach ($codeLines as $line) { |
|
| 520 | + $trClass = ''; |
|
| 521 | + $popover = ''; |
|
| 522 | + |
|
| 523 | + if ($lineData[$i]['includedInBranches'] > 0) { |
|
| 524 | + $lineCss = 'success'; |
|
| 525 | + |
|
| 526 | + if ($lineData[$i]['includedInHitBranches'] === 0) { |
|
| 527 | + $lineCss = 'danger'; |
|
| 528 | + } elseif ($lineData[$i]['includedInHitBranches'] !== $lineData[$i]['includedInBranches']) { |
|
| 529 | + $lineCss = 'warning'; |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + $popoverContent = '<ul>'; |
|
| 533 | + |
|
| 534 | + if (count($lineData[$i]['tests']) === 1) { |
|
| 535 | + $popoverTitle = '1 test covers line ' . $i; |
|
| 536 | + } else { |
|
| 537 | + $popoverTitle = count($lineData[$i]['tests']) . ' tests cover line ' . $i; |
|
| 538 | + } |
|
| 539 | + $popoverTitle .= '. These are covering ' . $lineData[$i]['includedInHitBranches'] . ' out of the ' . $lineData[$i]['includedInBranches'] . ' code branches.'; |
|
| 540 | + |
|
| 541 | + foreach ($lineData[$i]['tests'] as $test) { |
|
| 542 | + $popoverContent .= $this->createPopoverContentForTest($test, $testData[$test]); |
|
| 543 | + } |
|
| 544 | + |
|
| 545 | + $popoverContent .= '</ul>'; |
|
| 546 | + $trClass = $lineCss . ' popin'; |
|
| 547 | + |
|
| 548 | + $popover = sprintf( |
|
| 549 | + ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
|
| 550 | + $popoverTitle, |
|
| 551 | + htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags) |
|
| 552 | + ); |
|
| 553 | + } |
|
| 554 | + |
|
| 555 | + $lines .= $this->renderLine($singleLineTemplate, $i, $line, $trClass, $popover); |
|
| 556 | + |
|
| 557 | + $i++; |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + $linesTemplate->setVar(['lines' => $lines]); |
|
| 561 | + |
|
| 562 | + return $linesTemplate->render(); |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + private function renderSourceWithPathCoverage(FileNode $node): string |
|
| 566 | + { |
|
| 567 | + $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 568 | + $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 569 | + |
|
| 570 | + $functionCoverageData = $node->functionCoverageData(); |
|
| 571 | + $testData = $node->testData(); |
|
| 572 | + $codeLines = $this->loadFile($node->pathAsString()); |
|
| 573 | + |
|
| 574 | + $lineData = []; |
|
| 575 | + |
|
| 576 | + /** @var int $line */ |
|
| 577 | + foreach (array_keys($codeLines) as $line) { |
|
| 578 | + $lineData[$line + 1] = [ |
|
| 579 | + 'includedInPaths' => [], |
|
| 580 | + 'includedInHitPaths' => [], |
|
| 581 | + 'tests' => [], |
|
| 582 | + ]; |
|
| 583 | + } |
|
| 584 | + |
|
| 585 | + foreach ($functionCoverageData as $method) { |
|
| 586 | + foreach ($method['paths'] as $pathId => $path) { |
|
| 587 | + foreach ($path['path'] as $branchTaken) { |
|
| 588 | + foreach (range($method['branches'][$branchTaken]['line_start'], $method['branches'][$branchTaken]['line_end']) as $line) { |
|
| 589 | + if (!isset($lineData[$line])) { |
|
| 590 | + continue; |
|
| 591 | + } |
|
| 592 | + $lineData[$line]['includedInPaths'][] = $pathId; |
|
| 593 | + |
|
| 594 | + if ($path['hit']) { |
|
| 595 | + $lineData[$line]['includedInHitPaths'][] = $pathId; |
|
| 596 | + $lineData[$line]['tests'] = array_unique(array_merge($lineData[$line]['tests'], $path['hit'])); |
|
| 597 | + } |
|
| 598 | + } |
|
| 599 | + } |
|
| 600 | + } |
|
| 601 | + } |
|
| 602 | + |
|
| 603 | + $lines = ''; |
|
| 604 | + $i = 1; |
|
| 605 | + |
|
| 606 | + /** @var string $line */ |
|
| 607 | + foreach ($codeLines as $line) { |
|
| 608 | + $trClass = ''; |
|
| 609 | + $popover = ''; |
|
| 610 | + $includedInPathsCount = count(array_unique($lineData[$i]['includedInPaths'])); |
|
| 611 | + $includedInHitPathsCount = count(array_unique($lineData[$i]['includedInHitPaths'])); |
|
| 612 | + |
|
| 613 | + if ($includedInPathsCount > 0) { |
|
| 614 | + $lineCss = 'success'; |
|
| 615 | + |
|
| 616 | + if ($includedInHitPathsCount === 0) { |
|
| 617 | + $lineCss = 'danger'; |
|
| 618 | + } elseif ($includedInHitPathsCount !== $includedInPathsCount) { |
|
| 619 | + $lineCss = 'warning'; |
|
| 620 | + } |
|
| 621 | + |
|
| 622 | + $popoverContent = '<ul>'; |
|
| 623 | + |
|
| 624 | + if (count($lineData[$i]['tests']) === 1) { |
|
| 625 | + $popoverTitle = '1 test covers line ' . $i; |
|
| 626 | + } else { |
|
| 627 | + $popoverTitle = count($lineData[$i]['tests']) . ' tests cover line ' . $i; |
|
| 628 | + } |
|
| 629 | + $popoverTitle .= '. These are covering ' . $includedInHitPathsCount . ' out of the ' . $includedInPathsCount . ' code paths.'; |
|
| 630 | + |
|
| 631 | + foreach ($lineData[$i]['tests'] as $test) { |
|
| 632 | + $popoverContent .= $this->createPopoverContentForTest($test, $testData[$test]); |
|
| 633 | + } |
|
| 634 | + |
|
| 635 | + $popoverContent .= '</ul>'; |
|
| 636 | + $trClass = $lineCss . ' popin'; |
|
| 637 | + |
|
| 638 | + $popover = sprintf( |
|
| 639 | + ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
|
| 640 | + $popoverTitle, |
|
| 641 | + htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags) |
|
| 642 | + ); |
|
| 643 | + } |
|
| 644 | + |
|
| 645 | + $lines .= $this->renderLine($singleLineTemplate, $i, $line, $trClass, $popover); |
|
| 646 | + |
|
| 647 | + $i++; |
|
| 648 | + } |
|
| 649 | + |
|
| 650 | + $linesTemplate->setVar(['lines' => $lines]); |
|
| 651 | + |
|
| 652 | + return $linesTemplate->render(); |
|
| 653 | + } |
|
| 654 | + |
|
| 655 | + private function renderBranchStructure(FileNode $node): string |
|
| 656 | + { |
|
| 657 | + $branchesTemplate = new Template($this->templatePath . 'branches.html.dist', '{{', '}}'); |
|
| 658 | + |
|
| 659 | + $coverageData = $node->functionCoverageData(); |
|
| 660 | + $testData = $node->testData(); |
|
| 661 | + $codeLines = $this->loadFile($node->pathAsString()); |
|
| 662 | + $branches = ''; |
|
| 663 | + |
|
| 664 | + ksort($coverageData); |
|
| 665 | + |
|
| 666 | + foreach ($coverageData as $methodName => $methodData) { |
|
| 667 | + if (!$methodData['branches']) { |
|
| 668 | + continue; |
|
| 669 | + } |
|
| 670 | + |
|
| 671 | + $branchStructure = ''; |
|
| 672 | + |
|
| 673 | + foreach ($methodData['branches'] as $branch) { |
|
| 674 | + $branchStructure .= $this->renderBranchLines($branch, $codeLines, $testData); |
|
| 675 | + } |
|
| 676 | + |
|
| 677 | + if ($branchStructure !== '') { // don't show empty branches |
|
| 678 | + $branches .= '<h5 class="structure-heading"><a name="' . htmlspecialchars($methodName, $this->htmlSpecialCharsFlags) . '">' . $this->abbreviateMethodName($methodName) . '</a></h5>' . "\n"; |
|
| 679 | + $branches .= $branchStructure; |
|
| 680 | + } |
|
| 681 | + } |
|
| 682 | + |
|
| 683 | + $branchesTemplate->setVar(['branches' => $branches]); |
|
| 684 | + |
|
| 685 | + return $branchesTemplate->render(); |
|
| 686 | + } |
|
| 687 | + |
|
| 688 | + private function renderBranchLines(array $branch, array $codeLines, array $testData): string |
|
| 689 | + { |
|
| 690 | + $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 691 | + $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 692 | 692 | |
| 693 | - $lines = ''; |
|
| 693 | + $lines = ''; |
|
| 694 | 694 | |
| 695 | - $branchLines = range($branch['line_start'], $branch['line_end']); |
|
| 696 | - sort($branchLines); // sometimes end_line < start_line |
|
| 695 | + $branchLines = range($branch['line_start'], $branch['line_end']); |
|
| 696 | + sort($branchLines); // sometimes end_line < start_line |
|
| 697 | 697 | |
| 698 | - /** @var int $line */ |
|
| 699 | - foreach ($branchLines as $line) { |
|
| 700 | - if (!isset($codeLines[$line])) { // blank line at end of file is sometimes included here |
|
| 701 | - continue; |
|
| 702 | - } |
|
| 698 | + /** @var int $line */ |
|
| 699 | + foreach ($branchLines as $line) { |
|
| 700 | + if (!isset($codeLines[$line])) { // blank line at end of file is sometimes included here |
|
| 701 | + continue; |
|
| 702 | + } |
|
| 703 | 703 | |
| 704 | - $popoverContent = ''; |
|
| 705 | - $popoverTitle = ''; |
|
| 704 | + $popoverContent = ''; |
|
| 705 | + $popoverTitle = ''; |
|
| 706 | 706 | |
| 707 | - $numTests = count($branch['hit']); |
|
| 707 | + $numTests = count($branch['hit']); |
|
| 708 | 708 | |
| 709 | - if ($numTests === 0) { |
|
| 710 | - $trClass = 'danger'; |
|
| 711 | - } else { |
|
| 712 | - $lineCss = 'covered-by-large-tests'; |
|
| 713 | - $popoverContent = '<ul>'; |
|
| 709 | + if ($numTests === 0) { |
|
| 710 | + $trClass = 'danger'; |
|
| 711 | + } else { |
|
| 712 | + $lineCss = 'covered-by-large-tests'; |
|
| 713 | + $popoverContent = '<ul>'; |
|
| 714 | 714 | |
| 715 | - if ($numTests > 1) { |
|
| 716 | - $popoverTitle = $numTests . ' tests cover this branch'; |
|
| 717 | - } else { |
|
| 718 | - $popoverTitle = '1 test covers this branch'; |
|
| 719 | - } |
|
| 715 | + if ($numTests > 1) { |
|
| 716 | + $popoverTitle = $numTests . ' tests cover this branch'; |
|
| 717 | + } else { |
|
| 718 | + $popoverTitle = '1 test covers this branch'; |
|
| 719 | + } |
|
| 720 | 720 | |
| 721 | - foreach ($branch['hit'] as $test) { |
|
| 722 | - if ($lineCss === 'covered-by-large-tests' && $testData[$test]['size'] === 'medium') { |
|
| 723 | - $lineCss = 'covered-by-medium-tests'; |
|
| 724 | - } elseif ($testData[$test]['size'] === 'small') { |
|
| 725 | - $lineCss = 'covered-by-small-tests'; |
|
| 726 | - } |
|
| 721 | + foreach ($branch['hit'] as $test) { |
|
| 722 | + if ($lineCss === 'covered-by-large-tests' && $testData[$test]['size'] === 'medium') { |
|
| 723 | + $lineCss = 'covered-by-medium-tests'; |
|
| 724 | + } elseif ($testData[$test]['size'] === 'small') { |
|
| 725 | + $lineCss = 'covered-by-small-tests'; |
|
| 726 | + } |
|
| 727 | 727 | |
| 728 | - $popoverContent .= $this->createPopoverContentForTest($test, $testData[$test]); |
|
| 729 | - } |
|
| 730 | - $trClass = $lineCss . ' popin'; |
|
| 731 | - } |
|
| 728 | + $popoverContent .= $this->createPopoverContentForTest($test, $testData[$test]); |
|
| 729 | + } |
|
| 730 | + $trClass = $lineCss . ' popin'; |
|
| 731 | + } |
|
| 732 | 732 | |
| 733 | - $popover = ''; |
|
| 733 | + $popover = ''; |
|
| 734 | 734 | |
| 735 | - if (!empty($popoverTitle)) { |
|
| 736 | - $popover = sprintf( |
|
| 737 | - ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
|
| 738 | - $popoverTitle, |
|
| 739 | - htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags) |
|
| 740 | - ); |
|
| 741 | - } |
|
| 735 | + if (!empty($popoverTitle)) { |
|
| 736 | + $popover = sprintf( |
|
| 737 | + ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
|
| 738 | + $popoverTitle, |
|
| 739 | + htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags) |
|
| 740 | + ); |
|
| 741 | + } |
|
| 742 | 742 | |
| 743 | - $lines .= $this->renderLine($singleLineTemplate, $line, $codeLines[$line - 1], $trClass, $popover); |
|
| 744 | - } |
|
| 743 | + $lines .= $this->renderLine($singleLineTemplate, $line, $codeLines[$line - 1], $trClass, $popover); |
|
| 744 | + } |
|
| 745 | 745 | |
| 746 | - if ($lines === '') { |
|
| 747 | - return ''; |
|
| 748 | - } |
|
| 746 | + if ($lines === '') { |
|
| 747 | + return ''; |
|
| 748 | + } |
|
| 749 | 749 | |
| 750 | - $linesTemplate->setVar(['lines' => $lines]); |
|
| 750 | + $linesTemplate->setVar(['lines' => $lines]); |
|
| 751 | 751 | |
| 752 | - return $linesTemplate->render(); |
|
| 753 | - } |
|
| 752 | + return $linesTemplate->render(); |
|
| 753 | + } |
|
| 754 | 754 | |
| 755 | - private function renderPathStructure(FileNode $node): string |
|
| 756 | - { |
|
| 757 | - $pathsTemplate = new Template($this->templatePath . 'paths.html.dist', '{{', '}}'); |
|
| 755 | + private function renderPathStructure(FileNode $node): string |
|
| 756 | + { |
|
| 757 | + $pathsTemplate = new Template($this->templatePath . 'paths.html.dist', '{{', '}}'); |
|
| 758 | 758 | |
| 759 | - $coverageData = $node->functionCoverageData(); |
|
| 760 | - $testData = $node->testData(); |
|
| 761 | - $codeLines = $this->loadFile($node->pathAsString()); |
|
| 762 | - $paths = ''; |
|
| 759 | + $coverageData = $node->functionCoverageData(); |
|
| 760 | + $testData = $node->testData(); |
|
| 761 | + $codeLines = $this->loadFile($node->pathAsString()); |
|
| 762 | + $paths = ''; |
|
| 763 | 763 | |
| 764 | - ksort($coverageData); |
|
| 764 | + ksort($coverageData); |
|
| 765 | 765 | |
| 766 | - foreach ($coverageData as $methodName => $methodData) { |
|
| 767 | - if (!$methodData['paths']) { |
|
| 768 | - continue; |
|
| 769 | - } |
|
| 766 | + foreach ($coverageData as $methodName => $methodData) { |
|
| 767 | + if (!$methodData['paths']) { |
|
| 768 | + continue; |
|
| 769 | + } |
|
| 770 | 770 | |
| 771 | - $pathStructure = ''; |
|
| 771 | + $pathStructure = ''; |
|
| 772 | 772 | |
| 773 | - if (count($methodData['paths']) > 100) { |
|
| 774 | - $pathStructure .= '<p>' . count($methodData['paths']) . ' is too many paths to sensibly render, consider refactoring your code to bring this number down.</p>'; |
|
| 775 | - |
|
| 776 | - continue; |
|
| 777 | - } |
|
| 778 | - |
|
| 779 | - foreach ($methodData['paths'] as $path) { |
|
| 780 | - $pathStructure .= $this->renderPathLines($path, $methodData['branches'], $codeLines, $testData); |
|
| 781 | - } |
|
| 782 | - |
|
| 783 | - if ($pathStructure !== '') { |
|
| 784 | - $paths .= '<h5 class="structure-heading"><a name="' . htmlspecialchars($methodName, $this->htmlSpecialCharsFlags) . '">' . $this->abbreviateMethodName($methodName) . '</a></h5>' . "\n"; |
|
| 785 | - $paths .= $pathStructure; |
|
| 786 | - } |
|
| 787 | - } |
|
| 788 | - |
|
| 789 | - $pathsTemplate->setVar(['paths' => $paths]); |
|
| 790 | - |
|
| 791 | - return $pathsTemplate->render(); |
|
| 792 | - } |
|
| 793 | - |
|
| 794 | - private function renderPathLines(array $path, array $branches, array $codeLines, array $testData): string |
|
| 795 | - { |
|
| 796 | - $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 797 | - $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 798 | - |
|
| 799 | - $lines = ''; |
|
| 800 | - $first = true; |
|
| 801 | - |
|
| 802 | - foreach ($path['path'] as $branchId) { |
|
| 803 | - if ($first) { |
|
| 804 | - $first = false; |
|
| 805 | - } else { |
|
| 806 | - $lines .= ' <tr><td colspan="2"> </td></tr>' . "\n"; |
|
| 807 | - } |
|
| 808 | - |
|
| 809 | - $branchLines = range($branches[$branchId]['line_start'], $branches[$branchId]['line_end']); |
|
| 810 | - sort($branchLines); // sometimes end_line < start_line |
|
| 811 | - |
|
| 812 | - /** @var int $line */ |
|
| 813 | - foreach ($branchLines as $line) { |
|
| 814 | - if (!isset($codeLines[$line])) { // blank line at end of file is sometimes included here |
|
| 815 | - continue; |
|
| 816 | - } |
|
| 817 | - |
|
| 818 | - $popoverContent = ''; |
|
| 819 | - $popoverTitle = ''; |
|
| 820 | - |
|
| 821 | - $numTests = count($path['hit']); |
|
| 822 | - |
|
| 823 | - if ($numTests === 0) { |
|
| 824 | - $trClass = 'danger'; |
|
| 825 | - } else { |
|
| 826 | - $lineCss = 'covered-by-large-tests'; |
|
| 827 | - $popoverContent = '<ul>'; |
|
| 828 | - |
|
| 829 | - if ($numTests > 1) { |
|
| 830 | - $popoverTitle = $numTests . ' tests cover this path'; |
|
| 831 | - } else { |
|
| 832 | - $popoverTitle = '1 test covers this path'; |
|
| 833 | - } |
|
| 834 | - |
|
| 835 | - foreach ($path['hit'] as $test) { |
|
| 836 | - if ($lineCss === 'covered-by-large-tests' && $testData[$test]['size'] === 'medium') { |
|
| 837 | - $lineCss = 'covered-by-medium-tests'; |
|
| 838 | - } elseif ($testData[$test]['size'] === 'small') { |
|
| 839 | - $lineCss = 'covered-by-small-tests'; |
|
| 840 | - } |
|
| 841 | - |
|
| 842 | - $popoverContent .= $this->createPopoverContentForTest($test, $testData[$test]); |
|
| 843 | - } |
|
| 844 | - |
|
| 845 | - $trClass = $lineCss . ' popin'; |
|
| 846 | - } |
|
| 847 | - |
|
| 848 | - $popover = ''; |
|
| 849 | - |
|
| 850 | - if (!empty($popoverTitle)) { |
|
| 851 | - $popover = sprintf( |
|
| 852 | - ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
|
| 853 | - $popoverTitle, |
|
| 854 | - htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags) |
|
| 855 | - ); |
|
| 856 | - } |
|
| 857 | - |
|
| 858 | - $lines .= $this->renderLine($singleLineTemplate, $line, $codeLines[$line - 1], $trClass, $popover); |
|
| 859 | - } |
|
| 860 | - } |
|
| 861 | - |
|
| 862 | - if ($lines === '') { |
|
| 863 | - return ''; |
|
| 864 | - } |
|
| 865 | - |
|
| 866 | - $linesTemplate->setVar(['lines' => $lines]); |
|
| 867 | - |
|
| 868 | - return $linesTemplate->render(); |
|
| 869 | - } |
|
| 870 | - |
|
| 871 | - private function renderLine(Template $template, int $lineNumber, string $lineContent, string $class, string $popover): string |
|
| 872 | - { |
|
| 873 | - $template->setVar( |
|
| 874 | - [ |
|
| 875 | - 'lineNumber' => $lineNumber, |
|
| 876 | - 'lineContent' => $lineContent, |
|
| 877 | - 'class' => $class, |
|
| 878 | - 'popover' => $popover, |
|
| 879 | - ] |
|
| 880 | - ); |
|
| 881 | - |
|
| 882 | - return $template->render(); |
|
| 883 | - } |
|
| 884 | - |
|
| 885 | - private function loadFile(string $file): array |
|
| 886 | - { |
|
| 887 | - if (isset(self::$formattedSourceCache[$file])) { |
|
| 888 | - return self::$formattedSourceCache[$file]; |
|
| 889 | - } |
|
| 890 | - |
|
| 891 | - $buffer = file_get_contents($file); |
|
| 892 | - $tokens = token_get_all($buffer); |
|
| 893 | - $result = ['']; |
|
| 894 | - $i = 0; |
|
| 895 | - $stringFlag = false; |
|
| 896 | - $fileEndsWithNewLine = substr($buffer, -1) === "\n"; |
|
| 897 | - |
|
| 898 | - unset($buffer); |
|
| 899 | - |
|
| 900 | - foreach ($tokens as $j => $token) { |
|
| 901 | - if (is_string($token)) { |
|
| 902 | - if ($token === '"' && $tokens[$j - 1] !== '\\') { |
|
| 903 | - $result[$i] .= sprintf( |
|
| 904 | - '<span class="string">%s</span>', |
|
| 905 | - htmlspecialchars($token, $this->htmlSpecialCharsFlags) |
|
| 906 | - ); |
|
| 907 | - |
|
| 908 | - $stringFlag = !$stringFlag; |
|
| 909 | - } else { |
|
| 910 | - $result[$i] .= sprintf( |
|
| 911 | - '<span class="keyword">%s</span>', |
|
| 912 | - htmlspecialchars($token, $this->htmlSpecialCharsFlags) |
|
| 913 | - ); |
|
| 914 | - } |
|
| 915 | - |
|
| 916 | - continue; |
|
| 917 | - } |
|
| 918 | - |
|
| 919 | - [$token, $value] = $token; |
|
| 920 | - |
|
| 921 | - $value = str_replace( |
|
| 922 | - ["\t", ' '], |
|
| 923 | - [' ', ' '], |
|
| 924 | - htmlspecialchars($value, $this->htmlSpecialCharsFlags) |
|
| 925 | - ); |
|
| 926 | - |
|
| 927 | - if ($value === "\n") { |
|
| 928 | - $result[++$i] = ''; |
|
| 929 | - } else { |
|
| 930 | - $lines = explode("\n", $value); |
|
| 931 | - |
|
| 932 | - foreach ($lines as $jj => $line) { |
|
| 933 | - $line = trim($line); |
|
| 934 | - |
|
| 935 | - if ($line !== '') { |
|
| 936 | - if ($stringFlag) { |
|
| 937 | - $colour = 'string'; |
|
| 938 | - } else { |
|
| 939 | - $colour = 'default'; |
|
| 940 | - |
|
| 941 | - if ($this->isInlineHtml($token)) { |
|
| 942 | - $colour = 'html'; |
|
| 943 | - } elseif ($this->isComment($token)) { |
|
| 944 | - $colour = 'comment'; |
|
| 945 | - } elseif ($this->isKeyword($token)) { |
|
| 946 | - $colour = 'keyword'; |
|
| 947 | - } |
|
| 948 | - } |
|
| 949 | - |
|
| 950 | - $result[$i] .= sprintf( |
|
| 951 | - '<span class="%s">%s</span>', |
|
| 952 | - $colour, |
|
| 953 | - $line |
|
| 954 | - ); |
|
| 955 | - } |
|
| 956 | - |
|
| 957 | - if (isset($lines[$jj + 1])) { |
|
| 958 | - $result[++$i] = ''; |
|
| 959 | - } |
|
| 960 | - } |
|
| 961 | - } |
|
| 962 | - } |
|
| 963 | - |
|
| 964 | - if ($fileEndsWithNewLine) { |
|
| 965 | - unset($result[count($result) - 1]); |
|
| 966 | - } |
|
| 967 | - |
|
| 968 | - self::$formattedSourceCache[$file] = $result; |
|
| 969 | - |
|
| 970 | - return $result; |
|
| 971 | - } |
|
| 972 | - |
|
| 973 | - private function abbreviateClassName(string $className): string |
|
| 974 | - { |
|
| 975 | - $tmp = explode('\\', $className); |
|
| 976 | - |
|
| 977 | - if (count($tmp) > 1) { |
|
| 978 | - $className = sprintf( |
|
| 979 | - '<abbr title="%s">%s</abbr>', |
|
| 980 | - $className, |
|
| 981 | - array_pop($tmp) |
|
| 982 | - ); |
|
| 983 | - } |
|
| 984 | - |
|
| 985 | - return $className; |
|
| 986 | - } |
|
| 987 | - |
|
| 988 | - private function abbreviateMethodName(string $methodName): string |
|
| 989 | - { |
|
| 990 | - $parts = explode('->', $methodName); |
|
| 991 | - |
|
| 992 | - if (count($parts) === 2) { |
|
| 993 | - return $this->abbreviateClassName($parts[0]) . '->' . $parts[1]; |
|
| 994 | - } |
|
| 995 | - |
|
| 996 | - return $methodName; |
|
| 997 | - } |
|
| 998 | - |
|
| 999 | - private function createPopoverContentForTest(string $test, array $testData): string |
|
| 1000 | - { |
|
| 1001 | - $testCSS = ''; |
|
| 1002 | - |
|
| 1003 | - if ($testData['fromTestcase']) { |
|
| 1004 | - switch ($testData['status']) { |
|
| 1005 | - case BaseTestRunner::STATUS_PASSED: |
|
| 1006 | - switch ($testData['size']) { |
|
| 1007 | - case 'small': |
|
| 1008 | - $testCSS = ' class="covered-by-small-tests"'; |
|
| 1009 | - |
|
| 1010 | - break; |
|
| 1011 | - |
|
| 1012 | - case 'medium': |
|
| 1013 | - $testCSS = ' class="covered-by-medium-tests"'; |
|
| 1014 | - |
|
| 1015 | - break; |
|
| 1016 | - |
|
| 1017 | - default: |
|
| 1018 | - $testCSS = ' class="covered-by-large-tests"'; |
|
| 1019 | - |
|
| 1020 | - break; |
|
| 1021 | - } |
|
| 1022 | - |
|
| 1023 | - break; |
|
| 1024 | - |
|
| 1025 | - case BaseTestRunner::STATUS_SKIPPED: |
|
| 1026 | - case BaseTestRunner::STATUS_INCOMPLETE: |
|
| 1027 | - case BaseTestRunner::STATUS_RISKY: |
|
| 1028 | - case BaseTestRunner::STATUS_WARNING: |
|
| 1029 | - $testCSS = ' class="warning"'; |
|
| 1030 | - |
|
| 1031 | - break; |
|
| 1032 | - |
|
| 1033 | - case BaseTestRunner::STATUS_FAILURE: |
|
| 1034 | - case BaseTestRunner::STATUS_ERROR: |
|
| 1035 | - $testCSS = ' class="danger"'; |
|
| 1036 | - |
|
| 1037 | - break; |
|
| 1038 | - } |
|
| 1039 | - } |
|
| 1040 | - |
|
| 1041 | - return sprintf( |
|
| 1042 | - '<li%s>%s</li>', |
|
| 1043 | - $testCSS, |
|
| 1044 | - htmlspecialchars($test, $this->htmlSpecialCharsFlags) |
|
| 1045 | - ); |
|
| 1046 | - } |
|
| 1047 | - |
|
| 1048 | - private function isComment(int $token): bool |
|
| 1049 | - { |
|
| 1050 | - return $token === T_COMMENT || $token === T_DOC_COMMENT; |
|
| 1051 | - } |
|
| 1052 | - |
|
| 1053 | - private function isInlineHtml(int $token): bool |
|
| 1054 | - { |
|
| 1055 | - return $token === T_INLINE_HTML; |
|
| 1056 | - } |
|
| 1057 | - |
|
| 1058 | - private function isKeyword(int $token): bool |
|
| 1059 | - { |
|
| 1060 | - return isset(self::keywordTokens()[$token]); |
|
| 1061 | - } |
|
| 1062 | - |
|
| 1063 | - /** |
|
| 1064 | - * @psalm-return array<int,true> |
|
| 1065 | - */ |
|
| 1066 | - private static function keywordTokens(): array |
|
| 1067 | - { |
|
| 1068 | - if (self::$keywordTokens !== []) { |
|
| 1069 | - return self::$keywordTokens; |
|
| 1070 | - } |
|
| 1071 | - |
|
| 1072 | - self::$keywordTokens = [ |
|
| 1073 | - T_ABSTRACT => true, |
|
| 1074 | - T_ARRAY => true, |
|
| 1075 | - T_AS => true, |
|
| 1076 | - T_BREAK => true, |
|
| 1077 | - T_CALLABLE => true, |
|
| 1078 | - T_CASE => true, |
|
| 1079 | - T_CATCH => true, |
|
| 1080 | - T_CLASS => true, |
|
| 1081 | - T_CLONE => true, |
|
| 1082 | - T_CONST => true, |
|
| 1083 | - T_CONTINUE => true, |
|
| 1084 | - T_DECLARE => true, |
|
| 1085 | - T_DEFAULT => true, |
|
| 1086 | - T_DO => true, |
|
| 1087 | - T_ECHO => true, |
|
| 1088 | - T_ELSE => true, |
|
| 1089 | - T_ELSEIF => true, |
|
| 1090 | - T_EMPTY => true, |
|
| 1091 | - T_ENDDECLARE => true, |
|
| 1092 | - T_ENDFOR => true, |
|
| 1093 | - T_ENDFOREACH => true, |
|
| 1094 | - T_ENDIF => true, |
|
| 1095 | - T_ENDSWITCH => true, |
|
| 1096 | - T_ENDWHILE => true, |
|
| 1097 | - T_EVAL => true, |
|
| 1098 | - T_EXIT => true, |
|
| 1099 | - T_EXTENDS => true, |
|
| 1100 | - T_FINAL => true, |
|
| 1101 | - T_FINALLY => true, |
|
| 1102 | - T_FOR => true, |
|
| 1103 | - T_FOREACH => true, |
|
| 1104 | - T_FUNCTION => true, |
|
| 1105 | - T_GLOBAL => true, |
|
| 1106 | - T_GOTO => true, |
|
| 1107 | - T_HALT_COMPILER => true, |
|
| 1108 | - T_IF => true, |
|
| 1109 | - T_IMPLEMENTS => true, |
|
| 1110 | - T_INCLUDE => true, |
|
| 1111 | - T_INCLUDE_ONCE => true, |
|
| 1112 | - T_INSTANCEOF => true, |
|
| 1113 | - T_INSTEADOF => true, |
|
| 1114 | - T_INTERFACE => true, |
|
| 1115 | - T_ISSET => true, |
|
| 1116 | - T_LIST => true, |
|
| 1117 | - T_NAMESPACE => true, |
|
| 1118 | - T_NEW => true, |
|
| 1119 | - T_PRINT => true, |
|
| 1120 | - T_PRIVATE => true, |
|
| 1121 | - T_PROTECTED => true, |
|
| 1122 | - T_PUBLIC => true, |
|
| 1123 | - T_REQUIRE => true, |
|
| 1124 | - T_REQUIRE_ONCE => true, |
|
| 1125 | - T_RETURN => true, |
|
| 1126 | - T_STATIC => true, |
|
| 1127 | - T_SWITCH => true, |
|
| 1128 | - T_THROW => true, |
|
| 1129 | - T_TRAIT => true, |
|
| 1130 | - T_TRY => true, |
|
| 1131 | - T_UNSET => true, |
|
| 1132 | - T_USE => true, |
|
| 1133 | - T_VAR => true, |
|
| 1134 | - T_WHILE => true, |
|
| 1135 | - T_YIELD => true, |
|
| 1136 | - T_YIELD_FROM => true, |
|
| 1137 | - ]; |
|
| 1138 | - |
|
| 1139 | - if (defined('T_FN')) { |
|
| 1140 | - self::$keywordTokens[constant('T_FN')] = true; |
|
| 1141 | - } |
|
| 1142 | - |
|
| 1143 | - if (defined('T_MATCH')) { |
|
| 1144 | - self::$keywordTokens[constant('T_MATCH')] = true; |
|
| 1145 | - } |
|
| 1146 | - |
|
| 1147 | - if (defined('T_ENUM')) { |
|
| 1148 | - self::$keywordTokens[constant('T_ENUM')] = true; |
|
| 1149 | - } |
|
| 1150 | - |
|
| 1151 | - if (defined('T_READONLY')) { |
|
| 1152 | - self::$keywordTokens[constant('T_READONLY')] = true; |
|
| 1153 | - } |
|
| 1154 | - |
|
| 1155 | - return self::$keywordTokens; |
|
| 1156 | - } |
|
| 773 | + if (count($methodData['paths']) > 100) { |
|
| 774 | + $pathStructure .= '<p>' . count($methodData['paths']) . ' is too many paths to sensibly render, consider refactoring your code to bring this number down.</p>'; |
|
| 775 | + |
|
| 776 | + continue; |
|
| 777 | + } |
|
| 778 | + |
|
| 779 | + foreach ($methodData['paths'] as $path) { |
|
| 780 | + $pathStructure .= $this->renderPathLines($path, $methodData['branches'], $codeLines, $testData); |
|
| 781 | + } |
|
| 782 | + |
|
| 783 | + if ($pathStructure !== '') { |
|
| 784 | + $paths .= '<h5 class="structure-heading"><a name="' . htmlspecialchars($methodName, $this->htmlSpecialCharsFlags) . '">' . $this->abbreviateMethodName($methodName) . '</a></h5>' . "\n"; |
|
| 785 | + $paths .= $pathStructure; |
|
| 786 | + } |
|
| 787 | + } |
|
| 788 | + |
|
| 789 | + $pathsTemplate->setVar(['paths' => $paths]); |
|
| 790 | + |
|
| 791 | + return $pathsTemplate->render(); |
|
| 792 | + } |
|
| 793 | + |
|
| 794 | + private function renderPathLines(array $path, array $branches, array $codeLines, array $testData): string |
|
| 795 | + { |
|
| 796 | + $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 797 | + $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 798 | + |
|
| 799 | + $lines = ''; |
|
| 800 | + $first = true; |
|
| 801 | + |
|
| 802 | + foreach ($path['path'] as $branchId) { |
|
| 803 | + if ($first) { |
|
| 804 | + $first = false; |
|
| 805 | + } else { |
|
| 806 | + $lines .= ' <tr><td colspan="2"> </td></tr>' . "\n"; |
|
| 807 | + } |
|
| 808 | + |
|
| 809 | + $branchLines = range($branches[$branchId]['line_start'], $branches[$branchId]['line_end']); |
|
| 810 | + sort($branchLines); // sometimes end_line < start_line |
|
| 811 | + |
|
| 812 | + /** @var int $line */ |
|
| 813 | + foreach ($branchLines as $line) { |
|
| 814 | + if (!isset($codeLines[$line])) { // blank line at end of file is sometimes included here |
|
| 815 | + continue; |
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + $popoverContent = ''; |
|
| 819 | + $popoverTitle = ''; |
|
| 820 | + |
|
| 821 | + $numTests = count($path['hit']); |
|
| 822 | + |
|
| 823 | + if ($numTests === 0) { |
|
| 824 | + $trClass = 'danger'; |
|
| 825 | + } else { |
|
| 826 | + $lineCss = 'covered-by-large-tests'; |
|
| 827 | + $popoverContent = '<ul>'; |
|
| 828 | + |
|
| 829 | + if ($numTests > 1) { |
|
| 830 | + $popoverTitle = $numTests . ' tests cover this path'; |
|
| 831 | + } else { |
|
| 832 | + $popoverTitle = '1 test covers this path'; |
|
| 833 | + } |
|
| 834 | + |
|
| 835 | + foreach ($path['hit'] as $test) { |
|
| 836 | + if ($lineCss === 'covered-by-large-tests' && $testData[$test]['size'] === 'medium') { |
|
| 837 | + $lineCss = 'covered-by-medium-tests'; |
|
| 838 | + } elseif ($testData[$test]['size'] === 'small') { |
|
| 839 | + $lineCss = 'covered-by-small-tests'; |
|
| 840 | + } |
|
| 841 | + |
|
| 842 | + $popoverContent .= $this->createPopoverContentForTest($test, $testData[$test]); |
|
| 843 | + } |
|
| 844 | + |
|
| 845 | + $trClass = $lineCss . ' popin'; |
|
| 846 | + } |
|
| 847 | + |
|
| 848 | + $popover = ''; |
|
| 849 | + |
|
| 850 | + if (!empty($popoverTitle)) { |
|
| 851 | + $popover = sprintf( |
|
| 852 | + ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
|
| 853 | + $popoverTitle, |
|
| 854 | + htmlspecialchars($popoverContent, $this->htmlSpecialCharsFlags) |
|
| 855 | + ); |
|
| 856 | + } |
|
| 857 | + |
|
| 858 | + $lines .= $this->renderLine($singleLineTemplate, $line, $codeLines[$line - 1], $trClass, $popover); |
|
| 859 | + } |
|
| 860 | + } |
|
| 861 | + |
|
| 862 | + if ($lines === '') { |
|
| 863 | + return ''; |
|
| 864 | + } |
|
| 865 | + |
|
| 866 | + $linesTemplate->setVar(['lines' => $lines]); |
|
| 867 | + |
|
| 868 | + return $linesTemplate->render(); |
|
| 869 | + } |
|
| 870 | + |
|
| 871 | + private function renderLine(Template $template, int $lineNumber, string $lineContent, string $class, string $popover): string |
|
| 872 | + { |
|
| 873 | + $template->setVar( |
|
| 874 | + [ |
|
| 875 | + 'lineNumber' => $lineNumber, |
|
| 876 | + 'lineContent' => $lineContent, |
|
| 877 | + 'class' => $class, |
|
| 878 | + 'popover' => $popover, |
|
| 879 | + ] |
|
| 880 | + ); |
|
| 881 | + |
|
| 882 | + return $template->render(); |
|
| 883 | + } |
|
| 884 | + |
|
| 885 | + private function loadFile(string $file): array |
|
| 886 | + { |
|
| 887 | + if (isset(self::$formattedSourceCache[$file])) { |
|
| 888 | + return self::$formattedSourceCache[$file]; |
|
| 889 | + } |
|
| 890 | + |
|
| 891 | + $buffer = file_get_contents($file); |
|
| 892 | + $tokens = token_get_all($buffer); |
|
| 893 | + $result = ['']; |
|
| 894 | + $i = 0; |
|
| 895 | + $stringFlag = false; |
|
| 896 | + $fileEndsWithNewLine = substr($buffer, -1) === "\n"; |
|
| 897 | + |
|
| 898 | + unset($buffer); |
|
| 899 | + |
|
| 900 | + foreach ($tokens as $j => $token) { |
|
| 901 | + if (is_string($token)) { |
|
| 902 | + if ($token === '"' && $tokens[$j - 1] !== '\\') { |
|
| 903 | + $result[$i] .= sprintf( |
|
| 904 | + '<span class="string">%s</span>', |
|
| 905 | + htmlspecialchars($token, $this->htmlSpecialCharsFlags) |
|
| 906 | + ); |
|
| 907 | + |
|
| 908 | + $stringFlag = !$stringFlag; |
|
| 909 | + } else { |
|
| 910 | + $result[$i] .= sprintf( |
|
| 911 | + '<span class="keyword">%s</span>', |
|
| 912 | + htmlspecialchars($token, $this->htmlSpecialCharsFlags) |
|
| 913 | + ); |
|
| 914 | + } |
|
| 915 | + |
|
| 916 | + continue; |
|
| 917 | + } |
|
| 918 | + |
|
| 919 | + [$token, $value] = $token; |
|
| 920 | + |
|
| 921 | + $value = str_replace( |
|
| 922 | + ["\t", ' '], |
|
| 923 | + [' ', ' '], |
|
| 924 | + htmlspecialchars($value, $this->htmlSpecialCharsFlags) |
|
| 925 | + ); |
|
| 926 | + |
|
| 927 | + if ($value === "\n") { |
|
| 928 | + $result[++$i] = ''; |
|
| 929 | + } else { |
|
| 930 | + $lines = explode("\n", $value); |
|
| 931 | + |
|
| 932 | + foreach ($lines as $jj => $line) { |
|
| 933 | + $line = trim($line); |
|
| 934 | + |
|
| 935 | + if ($line !== '') { |
|
| 936 | + if ($stringFlag) { |
|
| 937 | + $colour = 'string'; |
|
| 938 | + } else { |
|
| 939 | + $colour = 'default'; |
|
| 940 | + |
|
| 941 | + if ($this->isInlineHtml($token)) { |
|
| 942 | + $colour = 'html'; |
|
| 943 | + } elseif ($this->isComment($token)) { |
|
| 944 | + $colour = 'comment'; |
|
| 945 | + } elseif ($this->isKeyword($token)) { |
|
| 946 | + $colour = 'keyword'; |
|
| 947 | + } |
|
| 948 | + } |
|
| 949 | + |
|
| 950 | + $result[$i] .= sprintf( |
|
| 951 | + '<span class="%s">%s</span>', |
|
| 952 | + $colour, |
|
| 953 | + $line |
|
| 954 | + ); |
|
| 955 | + } |
|
| 956 | + |
|
| 957 | + if (isset($lines[$jj + 1])) { |
|
| 958 | + $result[++$i] = ''; |
|
| 959 | + } |
|
| 960 | + } |
|
| 961 | + } |
|
| 962 | + } |
|
| 963 | + |
|
| 964 | + if ($fileEndsWithNewLine) { |
|
| 965 | + unset($result[count($result) - 1]); |
|
| 966 | + } |
|
| 967 | + |
|
| 968 | + self::$formattedSourceCache[$file] = $result; |
|
| 969 | + |
|
| 970 | + return $result; |
|
| 971 | + } |
|
| 972 | + |
|
| 973 | + private function abbreviateClassName(string $className): string |
|
| 974 | + { |
|
| 975 | + $tmp = explode('\\', $className); |
|
| 976 | + |
|
| 977 | + if (count($tmp) > 1) { |
|
| 978 | + $className = sprintf( |
|
| 979 | + '<abbr title="%s">%s</abbr>', |
|
| 980 | + $className, |
|
| 981 | + array_pop($tmp) |
|
| 982 | + ); |
|
| 983 | + } |
|
| 984 | + |
|
| 985 | + return $className; |
|
| 986 | + } |
|
| 987 | + |
|
| 988 | + private function abbreviateMethodName(string $methodName): string |
|
| 989 | + { |
|
| 990 | + $parts = explode('->', $methodName); |
|
| 991 | + |
|
| 992 | + if (count($parts) === 2) { |
|
| 993 | + return $this->abbreviateClassName($parts[0]) . '->' . $parts[1]; |
|
| 994 | + } |
|
| 995 | + |
|
| 996 | + return $methodName; |
|
| 997 | + } |
|
| 998 | + |
|
| 999 | + private function createPopoverContentForTest(string $test, array $testData): string |
|
| 1000 | + { |
|
| 1001 | + $testCSS = ''; |
|
| 1002 | + |
|
| 1003 | + if ($testData['fromTestcase']) { |
|
| 1004 | + switch ($testData['status']) { |
|
| 1005 | + case BaseTestRunner::STATUS_PASSED: |
|
| 1006 | + switch ($testData['size']) { |
|
| 1007 | + case 'small': |
|
| 1008 | + $testCSS = ' class="covered-by-small-tests"'; |
|
| 1009 | + |
|
| 1010 | + break; |
|
| 1011 | + |
|
| 1012 | + case 'medium': |
|
| 1013 | + $testCSS = ' class="covered-by-medium-tests"'; |
|
| 1014 | + |
|
| 1015 | + break; |
|
| 1016 | + |
|
| 1017 | + default: |
|
| 1018 | + $testCSS = ' class="covered-by-large-tests"'; |
|
| 1019 | + |
|
| 1020 | + break; |
|
| 1021 | + } |
|
| 1022 | + |
|
| 1023 | + break; |
|
| 1024 | + |
|
| 1025 | + case BaseTestRunner::STATUS_SKIPPED: |
|
| 1026 | + case BaseTestRunner::STATUS_INCOMPLETE: |
|
| 1027 | + case BaseTestRunner::STATUS_RISKY: |
|
| 1028 | + case BaseTestRunner::STATUS_WARNING: |
|
| 1029 | + $testCSS = ' class="warning"'; |
|
| 1030 | + |
|
| 1031 | + break; |
|
| 1032 | + |
|
| 1033 | + case BaseTestRunner::STATUS_FAILURE: |
|
| 1034 | + case BaseTestRunner::STATUS_ERROR: |
|
| 1035 | + $testCSS = ' class="danger"'; |
|
| 1036 | + |
|
| 1037 | + break; |
|
| 1038 | + } |
|
| 1039 | + } |
|
| 1040 | + |
|
| 1041 | + return sprintf( |
|
| 1042 | + '<li%s>%s</li>', |
|
| 1043 | + $testCSS, |
|
| 1044 | + htmlspecialchars($test, $this->htmlSpecialCharsFlags) |
|
| 1045 | + ); |
|
| 1046 | + } |
|
| 1047 | + |
|
| 1048 | + private function isComment(int $token): bool |
|
| 1049 | + { |
|
| 1050 | + return $token === T_COMMENT || $token === T_DOC_COMMENT; |
|
| 1051 | + } |
|
| 1052 | + |
|
| 1053 | + private function isInlineHtml(int $token): bool |
|
| 1054 | + { |
|
| 1055 | + return $token === T_INLINE_HTML; |
|
| 1056 | + } |
|
| 1057 | + |
|
| 1058 | + private function isKeyword(int $token): bool |
|
| 1059 | + { |
|
| 1060 | + return isset(self::keywordTokens()[$token]); |
|
| 1061 | + } |
|
| 1062 | + |
|
| 1063 | + /** |
|
| 1064 | + * @psalm-return array<int,true> |
|
| 1065 | + */ |
|
| 1066 | + private static function keywordTokens(): array |
|
| 1067 | + { |
|
| 1068 | + if (self::$keywordTokens !== []) { |
|
| 1069 | + return self::$keywordTokens; |
|
| 1070 | + } |
|
| 1071 | + |
|
| 1072 | + self::$keywordTokens = [ |
|
| 1073 | + T_ABSTRACT => true, |
|
| 1074 | + T_ARRAY => true, |
|
| 1075 | + T_AS => true, |
|
| 1076 | + T_BREAK => true, |
|
| 1077 | + T_CALLABLE => true, |
|
| 1078 | + T_CASE => true, |
|
| 1079 | + T_CATCH => true, |
|
| 1080 | + T_CLASS => true, |
|
| 1081 | + T_CLONE => true, |
|
| 1082 | + T_CONST => true, |
|
| 1083 | + T_CONTINUE => true, |
|
| 1084 | + T_DECLARE => true, |
|
| 1085 | + T_DEFAULT => true, |
|
| 1086 | + T_DO => true, |
|
| 1087 | + T_ECHO => true, |
|
| 1088 | + T_ELSE => true, |
|
| 1089 | + T_ELSEIF => true, |
|
| 1090 | + T_EMPTY => true, |
|
| 1091 | + T_ENDDECLARE => true, |
|
| 1092 | + T_ENDFOR => true, |
|
| 1093 | + T_ENDFOREACH => true, |
|
| 1094 | + T_ENDIF => true, |
|
| 1095 | + T_ENDSWITCH => true, |
|
| 1096 | + T_ENDWHILE => true, |
|
| 1097 | + T_EVAL => true, |
|
| 1098 | + T_EXIT => true, |
|
| 1099 | + T_EXTENDS => true, |
|
| 1100 | + T_FINAL => true, |
|
| 1101 | + T_FINALLY => true, |
|
| 1102 | + T_FOR => true, |
|
| 1103 | + T_FOREACH => true, |
|
| 1104 | + T_FUNCTION => true, |
|
| 1105 | + T_GLOBAL => true, |
|
| 1106 | + T_GOTO => true, |
|
| 1107 | + T_HALT_COMPILER => true, |
|
| 1108 | + T_IF => true, |
|
| 1109 | + T_IMPLEMENTS => true, |
|
| 1110 | + T_INCLUDE => true, |
|
| 1111 | + T_INCLUDE_ONCE => true, |
|
| 1112 | + T_INSTANCEOF => true, |
|
| 1113 | + T_INSTEADOF => true, |
|
| 1114 | + T_INTERFACE => true, |
|
| 1115 | + T_ISSET => true, |
|
| 1116 | + T_LIST => true, |
|
| 1117 | + T_NAMESPACE => true, |
|
| 1118 | + T_NEW => true, |
|
| 1119 | + T_PRINT => true, |
|
| 1120 | + T_PRIVATE => true, |
|
| 1121 | + T_PROTECTED => true, |
|
| 1122 | + T_PUBLIC => true, |
|
| 1123 | + T_REQUIRE => true, |
|
| 1124 | + T_REQUIRE_ONCE => true, |
|
| 1125 | + T_RETURN => true, |
|
| 1126 | + T_STATIC => true, |
|
| 1127 | + T_SWITCH => true, |
|
| 1128 | + T_THROW => true, |
|
| 1129 | + T_TRAIT => true, |
|
| 1130 | + T_TRY => true, |
|
| 1131 | + T_UNSET => true, |
|
| 1132 | + T_USE => true, |
|
| 1133 | + T_VAR => true, |
|
| 1134 | + T_WHILE => true, |
|
| 1135 | + T_YIELD => true, |
|
| 1136 | + T_YIELD_FROM => true, |
|
| 1137 | + ]; |
|
| 1138 | + |
|
| 1139 | + if (defined('T_FN')) { |
|
| 1140 | + self::$keywordTokens[constant('T_FN')] = true; |
|
| 1141 | + } |
|
| 1142 | + |
|
| 1143 | + if (defined('T_MATCH')) { |
|
| 1144 | + self::$keywordTokens[constant('T_MATCH')] = true; |
|
| 1145 | + } |
|
| 1146 | + |
|
| 1147 | + if (defined('T_ENUM')) { |
|
| 1148 | + self::$keywordTokens[constant('T_ENUM')] = true; |
|
| 1149 | + } |
|
| 1150 | + |
|
| 1151 | + if (defined('T_READONLY')) { |
|
| 1152 | + self::$keywordTokens[constant('T_READONLY')] = true; |
|
| 1153 | + } |
|
| 1154 | + |
|
| 1155 | + return self::$keywordTokens; |
|
| 1156 | + } |
|
| 1157 | 1157 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | public function render(FileNode $node, string $file): void |
| 123 | 123 | { |
| 124 | - $templateName = $this->templatePath . ($this->hasBranchCoverage ? 'file_branch.html' : 'file.html'); |
|
| 124 | + $templateName = $this->templatePath.($this->hasBranchCoverage ? 'file_branch.html' : 'file.html'); |
|
| 125 | 125 | $template = new Template($templateName, '{{', '}}'); |
| 126 | 126 | $this->setCommonTemplateVariables($template, $node); |
| 127 | 127 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | ] |
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | - $template->renderTo($file . '.html'); |
|
| 137 | + $template->renderTo($file.'.html'); |
|
| 138 | 138 | |
| 139 | 139 | if ($this->hasBranchCoverage) { |
| 140 | 140 | $template->setVar( |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | ] |
| 147 | 147 | ); |
| 148 | 148 | |
| 149 | - $template->renderTo($file . '_branch.html'); |
|
| 149 | + $template->renderTo($file.'_branch.html'); |
|
| 150 | 150 | |
| 151 | 151 | $template->setVar( |
| 152 | 152 | [ |
@@ -157,16 +157,16 @@ discard block |
||
| 157 | 157 | ] |
| 158 | 158 | ); |
| 159 | 159 | |
| 160 | - $template->renderTo($file . '_path.html'); |
|
| 160 | + $template->renderTo($file.'_path.html'); |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | private function renderItems(FileNode $node): string |
| 165 | 165 | { |
| 166 | - $templateName = $this->templatePath . ($this->hasBranchCoverage ? 'file_item_branch.html' : 'file_item.html'); |
|
| 166 | + $templateName = $this->templatePath.($this->hasBranchCoverage ? 'file_item_branch.html' : 'file_item.html'); |
|
| 167 | 167 | $template = new Template($templateName, '{{', '}}'); |
| 168 | 168 | |
| 169 | - $methodTemplateName = $this->templatePath . ($this->hasBranchCoverage ? 'method_item_branch.html' : 'method_item.html'); |
|
| 169 | + $methodTemplateName = $this->templatePath.($this->hasBranchCoverage ? 'method_item_branch.html' : 'method_item.html'); |
|
| 170 | 170 | $methodItemTemplate = new Template( |
| 171 | 171 | $methodTemplateName, |
| 172 | 172 | '{{', |
@@ -409,8 +409,8 @@ discard block |
||
| 409 | 409 | |
| 410 | 410 | private function renderSourceWithLineCoverage(FileNode $node): string |
| 411 | 411 | { |
| 412 | - $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 413 | - $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 412 | + $linesTemplate = new Template($this->templatePath.'lines.html.dist', '{{', '}}'); |
|
| 413 | + $singleLineTemplate = new Template($this->templatePath.'line.html.dist', '{{', '}}'); |
|
| 414 | 414 | |
| 415 | 415 | $coverageData = $node->lineCoverageData(); |
| 416 | 416 | $testData = $node->testData(); |
@@ -432,9 +432,9 @@ discard block |
||
| 432 | 432 | $trClass = 'danger'; |
| 433 | 433 | } else { |
| 434 | 434 | if ($numTests > 1) { |
| 435 | - $popoverTitle = $numTests . ' tests cover line ' . $i; |
|
| 435 | + $popoverTitle = $numTests.' tests cover line '.$i; |
|
| 436 | 436 | } else { |
| 437 | - $popoverTitle = '1 test covers line ' . $i; |
|
| 437 | + $popoverTitle = '1 test covers line '.$i; |
|
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | $lineCss = 'covered-by-large-tests'; |
@@ -451,13 +451,13 @@ discard block |
||
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | $popoverContent .= '</ul>'; |
| 454 | - $trClass = $lineCss . ' popin'; |
|
| 454 | + $trClass = $lineCss.' popin'; |
|
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | $popover = ''; |
| 459 | 459 | |
| 460 | - if (!empty($popoverTitle)) { |
|
| 460 | + if ( ! empty($popoverTitle)) { |
|
| 461 | 461 | $popover = sprintf( |
| 462 | 462 | ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
| 463 | 463 | $popoverTitle, |
@@ -477,8 +477,8 @@ discard block |
||
| 477 | 477 | |
| 478 | 478 | private function renderSourceWithBranchCoverage(FileNode $node): string |
| 479 | 479 | { |
| 480 | - $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 481 | - $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 480 | + $linesTemplate = new Template($this->templatePath.'lines.html.dist', '{{', '}}'); |
|
| 481 | + $singleLineTemplate = new Template($this->templatePath.'line.html.dist', '{{', '}}'); |
|
| 482 | 482 | |
| 483 | 483 | $functionCoverageData = $node->functionCoverageData(); |
| 484 | 484 | $testData = $node->testData(); |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | foreach ($functionCoverageData as $method) { |
| 499 | 499 | foreach ($method['branches'] as $branch) { |
| 500 | 500 | foreach (range($branch['line_start'], $branch['line_end']) as $line) { |
| 501 | - if (!isset($lineData[$line])) { // blank line at end of file is sometimes included here |
|
| 501 | + if ( ! isset($lineData[$line])) { // blank line at end of file is sometimes included here |
|
| 502 | 502 | continue; |
| 503 | 503 | } |
| 504 | 504 | |
@@ -532,18 +532,18 @@ discard block |
||
| 532 | 532 | $popoverContent = '<ul>'; |
| 533 | 533 | |
| 534 | 534 | if (count($lineData[$i]['tests']) === 1) { |
| 535 | - $popoverTitle = '1 test covers line ' . $i; |
|
| 535 | + $popoverTitle = '1 test covers line '.$i; |
|
| 536 | 536 | } else { |
| 537 | - $popoverTitle = count($lineData[$i]['tests']) . ' tests cover line ' . $i; |
|
| 537 | + $popoverTitle = count($lineData[$i]['tests']).' tests cover line '.$i; |
|
| 538 | 538 | } |
| 539 | - $popoverTitle .= '. These are covering ' . $lineData[$i]['includedInHitBranches'] . ' out of the ' . $lineData[$i]['includedInBranches'] . ' code branches.'; |
|
| 539 | + $popoverTitle .= '. These are covering '.$lineData[$i]['includedInHitBranches'].' out of the '.$lineData[$i]['includedInBranches'].' code branches.'; |
|
| 540 | 540 | |
| 541 | 541 | foreach ($lineData[$i]['tests'] as $test) { |
| 542 | 542 | $popoverContent .= $this->createPopoverContentForTest($test, $testData[$test]); |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | $popoverContent .= '</ul>'; |
| 546 | - $trClass = $lineCss . ' popin'; |
|
| 546 | + $trClass = $lineCss.' popin'; |
|
| 547 | 547 | |
| 548 | 548 | $popover = sprintf( |
| 549 | 549 | ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
@@ -564,8 +564,8 @@ discard block |
||
| 564 | 564 | |
| 565 | 565 | private function renderSourceWithPathCoverage(FileNode $node): string |
| 566 | 566 | { |
| 567 | - $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 568 | - $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 567 | + $linesTemplate = new Template($this->templatePath.'lines.html.dist', '{{', '}}'); |
|
| 568 | + $singleLineTemplate = new Template($this->templatePath.'line.html.dist', '{{', '}}'); |
|
| 569 | 569 | |
| 570 | 570 | $functionCoverageData = $node->functionCoverageData(); |
| 571 | 571 | $testData = $node->testData(); |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | foreach ($method['paths'] as $pathId => $path) { |
| 587 | 587 | foreach ($path['path'] as $branchTaken) { |
| 588 | 588 | foreach (range($method['branches'][$branchTaken]['line_start'], $method['branches'][$branchTaken]['line_end']) as $line) { |
| 589 | - if (!isset($lineData[$line])) { |
|
| 589 | + if ( ! isset($lineData[$line])) { |
|
| 590 | 590 | continue; |
| 591 | 591 | } |
| 592 | 592 | $lineData[$line]['includedInPaths'][] = $pathId; |
@@ -622,18 +622,18 @@ discard block |
||
| 622 | 622 | $popoverContent = '<ul>'; |
| 623 | 623 | |
| 624 | 624 | if (count($lineData[$i]['tests']) === 1) { |
| 625 | - $popoverTitle = '1 test covers line ' . $i; |
|
| 625 | + $popoverTitle = '1 test covers line '.$i; |
|
| 626 | 626 | } else { |
| 627 | - $popoverTitle = count($lineData[$i]['tests']) . ' tests cover line ' . $i; |
|
| 627 | + $popoverTitle = count($lineData[$i]['tests']).' tests cover line '.$i; |
|
| 628 | 628 | } |
| 629 | - $popoverTitle .= '. These are covering ' . $includedInHitPathsCount . ' out of the ' . $includedInPathsCount . ' code paths.'; |
|
| 629 | + $popoverTitle .= '. These are covering '.$includedInHitPathsCount.' out of the '.$includedInPathsCount.' code paths.'; |
|
| 630 | 630 | |
| 631 | 631 | foreach ($lineData[$i]['tests'] as $test) { |
| 632 | 632 | $popoverContent .= $this->createPopoverContentForTest($test, $testData[$test]); |
| 633 | 633 | } |
| 634 | 634 | |
| 635 | 635 | $popoverContent .= '</ul>'; |
| 636 | - $trClass = $lineCss . ' popin'; |
|
| 636 | + $trClass = $lineCss.' popin'; |
|
| 637 | 637 | |
| 638 | 638 | $popover = sprintf( |
| 639 | 639 | ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | |
| 655 | 655 | private function renderBranchStructure(FileNode $node): string |
| 656 | 656 | { |
| 657 | - $branchesTemplate = new Template($this->templatePath . 'branches.html.dist', '{{', '}}'); |
|
| 657 | + $branchesTemplate = new Template($this->templatePath.'branches.html.dist', '{{', '}}'); |
|
| 658 | 658 | |
| 659 | 659 | $coverageData = $node->functionCoverageData(); |
| 660 | 660 | $testData = $node->testData(); |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | ksort($coverageData); |
| 665 | 665 | |
| 666 | 666 | foreach ($coverageData as $methodName => $methodData) { |
| 667 | - if (!$methodData['branches']) { |
|
| 667 | + if ( ! $methodData['branches']) { |
|
| 668 | 668 | continue; |
| 669 | 669 | } |
| 670 | 670 | |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | if ($branchStructure !== '') { // don't show empty branches |
| 678 | - $branches .= '<h5 class="structure-heading"><a name="' . htmlspecialchars($methodName, $this->htmlSpecialCharsFlags) . '">' . $this->abbreviateMethodName($methodName) . '</a></h5>' . "\n"; |
|
| 678 | + $branches .= '<h5 class="structure-heading"><a name="'.htmlspecialchars($methodName, $this->htmlSpecialCharsFlags).'">'.$this->abbreviateMethodName($methodName).'</a></h5>'."\n"; |
|
| 679 | 679 | $branches .= $branchStructure; |
| 680 | 680 | } |
| 681 | 681 | } |
@@ -687,8 +687,8 @@ discard block |
||
| 687 | 687 | |
| 688 | 688 | private function renderBranchLines(array $branch, array $codeLines, array $testData): string |
| 689 | 689 | { |
| 690 | - $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 691 | - $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 690 | + $linesTemplate = new Template($this->templatePath.'lines.html.dist', '{{', '}}'); |
|
| 691 | + $singleLineTemplate = new Template($this->templatePath.'line.html.dist', '{{', '}}'); |
|
| 692 | 692 | |
| 693 | 693 | $lines = ''; |
| 694 | 694 | |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | |
| 698 | 698 | /** @var int $line */ |
| 699 | 699 | foreach ($branchLines as $line) { |
| 700 | - if (!isset($codeLines[$line])) { // blank line at end of file is sometimes included here |
|
| 700 | + if ( ! isset($codeLines[$line])) { // blank line at end of file is sometimes included here |
|
| 701 | 701 | continue; |
| 702 | 702 | } |
| 703 | 703 | |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | $popoverContent = '<ul>'; |
| 714 | 714 | |
| 715 | 715 | if ($numTests > 1) { |
| 716 | - $popoverTitle = $numTests . ' tests cover this branch'; |
|
| 716 | + $popoverTitle = $numTests.' tests cover this branch'; |
|
| 717 | 717 | } else { |
| 718 | 718 | $popoverTitle = '1 test covers this branch'; |
| 719 | 719 | } |
@@ -727,12 +727,12 @@ discard block |
||
| 727 | 727 | |
| 728 | 728 | $popoverContent .= $this->createPopoverContentForTest($test, $testData[$test]); |
| 729 | 729 | } |
| 730 | - $trClass = $lineCss . ' popin'; |
|
| 730 | + $trClass = $lineCss.' popin'; |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | $popover = ''; |
| 734 | 734 | |
| 735 | - if (!empty($popoverTitle)) { |
|
| 735 | + if ( ! empty($popoverTitle)) { |
|
| 736 | 736 | $popover = sprintf( |
| 737 | 737 | ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
| 738 | 738 | $popoverTitle, |
@@ -754,7 +754,7 @@ discard block |
||
| 754 | 754 | |
| 755 | 755 | private function renderPathStructure(FileNode $node): string |
| 756 | 756 | { |
| 757 | - $pathsTemplate = new Template($this->templatePath . 'paths.html.dist', '{{', '}}'); |
|
| 757 | + $pathsTemplate = new Template($this->templatePath.'paths.html.dist', '{{', '}}'); |
|
| 758 | 758 | |
| 759 | 759 | $coverageData = $node->functionCoverageData(); |
| 760 | 760 | $testData = $node->testData(); |
@@ -764,14 +764,14 @@ discard block |
||
| 764 | 764 | ksort($coverageData); |
| 765 | 765 | |
| 766 | 766 | foreach ($coverageData as $methodName => $methodData) { |
| 767 | - if (!$methodData['paths']) { |
|
| 767 | + if ( ! $methodData['paths']) { |
|
| 768 | 768 | continue; |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | $pathStructure = ''; |
| 772 | 772 | |
| 773 | 773 | if (count($methodData['paths']) > 100) { |
| 774 | - $pathStructure .= '<p>' . count($methodData['paths']) . ' is too many paths to sensibly render, consider refactoring your code to bring this number down.</p>'; |
|
| 774 | + $pathStructure .= '<p>'.count($methodData['paths']).' is too many paths to sensibly render, consider refactoring your code to bring this number down.</p>'; |
|
| 775 | 775 | |
| 776 | 776 | continue; |
| 777 | 777 | } |
@@ -781,7 +781,7 @@ discard block |
||
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | if ($pathStructure !== '') { |
| 784 | - $paths .= '<h5 class="structure-heading"><a name="' . htmlspecialchars($methodName, $this->htmlSpecialCharsFlags) . '">' . $this->abbreviateMethodName($methodName) . '</a></h5>' . "\n"; |
|
| 784 | + $paths .= '<h5 class="structure-heading"><a name="'.htmlspecialchars($methodName, $this->htmlSpecialCharsFlags).'">'.$this->abbreviateMethodName($methodName).'</a></h5>'."\n"; |
|
| 785 | 785 | $paths .= $pathStructure; |
| 786 | 786 | } |
| 787 | 787 | } |
@@ -793,8 +793,8 @@ discard block |
||
| 793 | 793 | |
| 794 | 794 | private function renderPathLines(array $path, array $branches, array $codeLines, array $testData): string |
| 795 | 795 | { |
| 796 | - $linesTemplate = new Template($this->templatePath . 'lines.html.dist', '{{', '}}'); |
|
| 797 | - $singleLineTemplate = new Template($this->templatePath . 'line.html.dist', '{{', '}}'); |
|
| 796 | + $linesTemplate = new Template($this->templatePath.'lines.html.dist', '{{', '}}'); |
|
| 797 | + $singleLineTemplate = new Template($this->templatePath.'line.html.dist', '{{', '}}'); |
|
| 798 | 798 | |
| 799 | 799 | $lines = ''; |
| 800 | 800 | $first = true; |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | if ($first) { |
| 804 | 804 | $first = false; |
| 805 | 805 | } else { |
| 806 | - $lines .= ' <tr><td colspan="2"> </td></tr>' . "\n"; |
|
| 806 | + $lines .= ' <tr><td colspan="2"> </td></tr>'."\n"; |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | $branchLines = range($branches[$branchId]['line_start'], $branches[$branchId]['line_end']); |
@@ -811,7 +811,7 @@ discard block |
||
| 811 | 811 | |
| 812 | 812 | /** @var int $line */ |
| 813 | 813 | foreach ($branchLines as $line) { |
| 814 | - if (!isset($codeLines[$line])) { // blank line at end of file is sometimes included here |
|
| 814 | + if ( ! isset($codeLines[$line])) { // blank line at end of file is sometimes included here |
|
| 815 | 815 | continue; |
| 816 | 816 | } |
| 817 | 817 | |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | $popoverContent = '<ul>'; |
| 828 | 828 | |
| 829 | 829 | if ($numTests > 1) { |
| 830 | - $popoverTitle = $numTests . ' tests cover this path'; |
|
| 830 | + $popoverTitle = $numTests.' tests cover this path'; |
|
| 831 | 831 | } else { |
| 832 | 832 | $popoverTitle = '1 test covers this path'; |
| 833 | 833 | } |
@@ -842,12 +842,12 @@ discard block |
||
| 842 | 842 | $popoverContent .= $this->createPopoverContentForTest($test, $testData[$test]); |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - $trClass = $lineCss . ' popin'; |
|
| 845 | + $trClass = $lineCss.' popin'; |
|
| 846 | 846 | } |
| 847 | 847 | |
| 848 | 848 | $popover = ''; |
| 849 | 849 | |
| 850 | - if (!empty($popoverTitle)) { |
|
| 850 | + if ( ! empty($popoverTitle)) { |
|
| 851 | 851 | $popover = sprintf( |
| 852 | 852 | ' data-title="%s" data-content="%s" data-placement="top" data-html="true"', |
| 853 | 853 | $popoverTitle, |
@@ -905,7 +905,7 @@ discard block |
||
| 905 | 905 | htmlspecialchars($token, $this->htmlSpecialCharsFlags) |
| 906 | 906 | ); |
| 907 | 907 | |
| 908 | - $stringFlag = !$stringFlag; |
|
| 908 | + $stringFlag = ! $stringFlag; |
|
| 909 | 909 | } else { |
| 910 | 910 | $result[$i] .= sprintf( |
| 911 | 911 | '<span class="keyword">%s</span>', |
@@ -990,7 +990,7 @@ discard block |
||
| 990 | 990 | $parts = explode('->', $methodName); |
| 991 | 991 | |
| 992 | 992 | if (count($parts) === 2) { |
| 993 | - return $this->abbreviateClassName($parts[0]) . '->' . $parts[1]; |
|
| 993 | + return $this->abbreviateClassName($parts[0]).'->'.$parts[1]; |
|
| 994 | 994 | } |
| 995 | 995 | |
| 996 | 996 | return $methodName; |
@@ -56,229 +56,229 @@ |
||
| 56 | 56 | */ |
| 57 | 57 | final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract |
| 58 | 58 | { |
| 59 | - /** |
|
| 60 | - * @psalm-var array<int, int> |
|
| 61 | - */ |
|
| 62 | - private $executableLines = []; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @psalm-var array<int, int> |
|
| 66 | - */ |
|
| 67 | - private $propertyLines = []; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @psalm-var array<int, Return_> |
|
| 71 | - */ |
|
| 72 | - private $returns = []; |
|
| 73 | - |
|
| 74 | - public function enterNode(Node $node): void |
|
| 75 | - { |
|
| 76 | - $this->savePropertyLines($node); |
|
| 77 | - |
|
| 78 | - if (!$this->isExecutable($node)) { |
|
| 79 | - return; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - foreach ($this->getLines($node) as $line) { |
|
| 83 | - if (isset($this->propertyLines[$line])) { |
|
| 84 | - return; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $this->executableLines[$line] = $line; |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @psalm-return array<int, int> |
|
| 93 | - */ |
|
| 94 | - public function executableLines(): array |
|
| 95 | - { |
|
| 96 | - $this->computeReturns(); |
|
| 97 | - |
|
| 98 | - sort($this->executableLines); |
|
| 99 | - |
|
| 100 | - return $this->executableLines; |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - private function savePropertyLines(Node $node): void |
|
| 104 | - { |
|
| 105 | - if (!$node instanceof Property && !$node instanceof Node\Stmt\ClassConst) { |
|
| 106 | - return; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - foreach (range($node->getStartLine(), $node->getEndLine()) as $index) { |
|
| 110 | - $this->propertyLines[$index] = $index; |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - private function computeReturns(): void |
|
| 115 | - { |
|
| 116 | - foreach ($this->returns as $return) { |
|
| 117 | - foreach (range($return->getStartLine(), $return->getEndLine()) as $loc) { |
|
| 118 | - if (isset($this->executableLines[$loc])) { |
|
| 119 | - continue 2; |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - $line = $return->getEndLine(); |
|
| 124 | - |
|
| 125 | - if ($return->expr !== null) { |
|
| 126 | - $line = $return->expr->getStartLine(); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - $this->executableLines[$line] = $line; |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * @return int[] |
|
| 135 | - */ |
|
| 136 | - private function getLines(Node $node): array |
|
| 137 | - { |
|
| 138 | - if ($node instanceof BinaryOp) { |
|
| 139 | - if (($node->left instanceof Node\Scalar || |
|
| 140 | - $node->left instanceof Node\Expr\ConstFetch) && |
|
| 141 | - ($node->right instanceof Node\Scalar || |
|
| 142 | - $node->right instanceof Node\Expr\ConstFetch)) { |
|
| 143 | - return [$node->right->getStartLine()]; |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - return []; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - if ($node instanceof Cast || |
|
| 150 | - $node instanceof PropertyFetch || |
|
| 151 | - $node instanceof NullsafePropertyFetch || |
|
| 152 | - $node instanceof StaticPropertyFetch) { |
|
| 153 | - return [$node->getEndLine()]; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - if ($node instanceof ArrayDimFetch) { |
|
| 157 | - if (null === $node->dim) { |
|
| 158 | - return []; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - return [$node->dim->getStartLine()]; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - if ($node instanceof Array_) { |
|
| 165 | - $startLine = $node->getStartLine(); |
|
| 166 | - |
|
| 167 | - if (isset($this->executableLines[$startLine])) { |
|
| 168 | - return []; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - if ([] === $node->items) { |
|
| 172 | - return [$node->getEndLine()]; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - if ($node->items[0] instanceof ArrayItem) { |
|
| 176 | - return [$node->items[0]->getStartLine()]; |
|
| 177 | - } |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - if ($node instanceof ClassMethod) { |
|
| 181 | - if ($node->name->name !== '__construct') { |
|
| 182 | - return []; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - $existsAPromotedProperty = false; |
|
| 186 | - |
|
| 187 | - foreach ($node->getParams() as $param) { |
|
| 188 | - if (0 !== ($param->flags & Class_::VISIBILITY_MODIFIER_MASK)) { |
|
| 189 | - $existsAPromotedProperty = true; |
|
| 190 | - |
|
| 191 | - break; |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - if ($existsAPromotedProperty) { |
|
| 196 | - // Only the line with `function` keyword should be listed here |
|
| 197 | - // but `nikic/php-parser` doesn't provide a way to fetch it |
|
| 198 | - return range($node->getStartLine(), $node->name->getEndLine()); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - return []; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - if ($node instanceof MethodCall) { |
|
| 205 | - return [$node->name->getStartLine()]; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - if ($node instanceof Ternary) { |
|
| 209 | - $lines = [$node->cond->getStartLine()]; |
|
| 210 | - |
|
| 211 | - if (null !== $node->if) { |
|
| 212 | - $lines[] = $node->if->getStartLine(); |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - $lines[] = $node->else->getStartLine(); |
|
| 216 | - |
|
| 217 | - return $lines; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - if ($node instanceof Match_) { |
|
| 221 | - return [$node->cond->getStartLine()]; |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - if ($node instanceof MatchArm) { |
|
| 225 | - return [$node->body->getStartLine()]; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - if ($node instanceof Expression && ( |
|
| 229 | - $node->expr instanceof Cast || |
|
| 230 | - $node->expr instanceof Match_ || |
|
| 231 | - $node->expr instanceof MethodCall |
|
| 232 | - )) { |
|
| 233 | - return []; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - if ($node instanceof Return_) { |
|
| 237 | - $this->returns[] = $node; |
|
| 238 | - |
|
| 239 | - return []; |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - return [$node->getStartLine()]; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - private function isExecutable(Node $node): bool |
|
| 246 | - { |
|
| 247 | - return $node instanceof Assign || |
|
| 248 | - $node instanceof ArrayDimFetch || |
|
| 249 | - $node instanceof Array_ || |
|
| 250 | - $node instanceof BinaryOp || |
|
| 251 | - $node instanceof Break_ || |
|
| 252 | - $node instanceof CallLike || |
|
| 253 | - $node instanceof Case_ || |
|
| 254 | - $node instanceof Cast || |
|
| 255 | - $node instanceof Catch_ || |
|
| 256 | - $node instanceof ClassMethod || |
|
| 257 | - $node instanceof Closure || |
|
| 258 | - $node instanceof Continue_ || |
|
| 259 | - $node instanceof Do_ || |
|
| 260 | - $node instanceof Echo_ || |
|
| 261 | - $node instanceof ElseIf_ || |
|
| 262 | - $node instanceof Else_ || |
|
| 263 | - $node instanceof Encapsed || |
|
| 264 | - $node instanceof Expression || |
|
| 265 | - $node instanceof Finally_ || |
|
| 266 | - $node instanceof For_ || |
|
| 267 | - $node instanceof Foreach_ || |
|
| 268 | - $node instanceof Goto_ || |
|
| 269 | - $node instanceof If_ || |
|
| 270 | - $node instanceof Match_ || |
|
| 271 | - $node instanceof MatchArm || |
|
| 272 | - $node instanceof MethodCall || |
|
| 273 | - $node instanceof NullsafePropertyFetch || |
|
| 274 | - $node instanceof PropertyFetch || |
|
| 275 | - $node instanceof Return_ || |
|
| 276 | - $node instanceof StaticPropertyFetch || |
|
| 277 | - $node instanceof Switch_ || |
|
| 278 | - $node instanceof Ternary || |
|
| 279 | - $node instanceof Throw_ || |
|
| 280 | - $node instanceof TryCatch || |
|
| 281 | - $node instanceof Unset_ || |
|
| 282 | - $node instanceof While_; |
|
| 283 | - } |
|
| 59 | + /** |
|
| 60 | + * @psalm-var array<int, int> |
|
| 61 | + */ |
|
| 62 | + private $executableLines = []; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @psalm-var array<int, int> |
|
| 66 | + */ |
|
| 67 | + private $propertyLines = []; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @psalm-var array<int, Return_> |
|
| 71 | + */ |
|
| 72 | + private $returns = []; |
|
| 73 | + |
|
| 74 | + public function enterNode(Node $node): void |
|
| 75 | + { |
|
| 76 | + $this->savePropertyLines($node); |
|
| 77 | + |
|
| 78 | + if (!$this->isExecutable($node)) { |
|
| 79 | + return; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + foreach ($this->getLines($node) as $line) { |
|
| 83 | + if (isset($this->propertyLines[$line])) { |
|
| 84 | + return; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $this->executableLines[$line] = $line; |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @psalm-return array<int, int> |
|
| 93 | + */ |
|
| 94 | + public function executableLines(): array |
|
| 95 | + { |
|
| 96 | + $this->computeReturns(); |
|
| 97 | + |
|
| 98 | + sort($this->executableLines); |
|
| 99 | + |
|
| 100 | + return $this->executableLines; |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + private function savePropertyLines(Node $node): void |
|
| 104 | + { |
|
| 105 | + if (!$node instanceof Property && !$node instanceof Node\Stmt\ClassConst) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + foreach (range($node->getStartLine(), $node->getEndLine()) as $index) { |
|
| 110 | + $this->propertyLines[$index] = $index; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + private function computeReturns(): void |
|
| 115 | + { |
|
| 116 | + foreach ($this->returns as $return) { |
|
| 117 | + foreach (range($return->getStartLine(), $return->getEndLine()) as $loc) { |
|
| 118 | + if (isset($this->executableLines[$loc])) { |
|
| 119 | + continue 2; |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + $line = $return->getEndLine(); |
|
| 124 | + |
|
| 125 | + if ($return->expr !== null) { |
|
| 126 | + $line = $return->expr->getStartLine(); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + $this->executableLines[$line] = $line; |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * @return int[] |
|
| 135 | + */ |
|
| 136 | + private function getLines(Node $node): array |
|
| 137 | + { |
|
| 138 | + if ($node instanceof BinaryOp) { |
|
| 139 | + if (($node->left instanceof Node\Scalar || |
|
| 140 | + $node->left instanceof Node\Expr\ConstFetch) && |
|
| 141 | + ($node->right instanceof Node\Scalar || |
|
| 142 | + $node->right instanceof Node\Expr\ConstFetch)) { |
|
| 143 | + return [$node->right->getStartLine()]; |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + return []; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + if ($node instanceof Cast || |
|
| 150 | + $node instanceof PropertyFetch || |
|
| 151 | + $node instanceof NullsafePropertyFetch || |
|
| 152 | + $node instanceof StaticPropertyFetch) { |
|
| 153 | + return [$node->getEndLine()]; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + if ($node instanceof ArrayDimFetch) { |
|
| 157 | + if (null === $node->dim) { |
|
| 158 | + return []; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + return [$node->dim->getStartLine()]; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + if ($node instanceof Array_) { |
|
| 165 | + $startLine = $node->getStartLine(); |
|
| 166 | + |
|
| 167 | + if (isset($this->executableLines[$startLine])) { |
|
| 168 | + return []; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + if ([] === $node->items) { |
|
| 172 | + return [$node->getEndLine()]; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + if ($node->items[0] instanceof ArrayItem) { |
|
| 176 | + return [$node->items[0]->getStartLine()]; |
|
| 177 | + } |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + if ($node instanceof ClassMethod) { |
|
| 181 | + if ($node->name->name !== '__construct') { |
|
| 182 | + return []; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + $existsAPromotedProperty = false; |
|
| 186 | + |
|
| 187 | + foreach ($node->getParams() as $param) { |
|
| 188 | + if (0 !== ($param->flags & Class_::VISIBILITY_MODIFIER_MASK)) { |
|
| 189 | + $existsAPromotedProperty = true; |
|
| 190 | + |
|
| 191 | + break; |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + if ($existsAPromotedProperty) { |
|
| 196 | + // Only the line with `function` keyword should be listed here |
|
| 197 | + // but `nikic/php-parser` doesn't provide a way to fetch it |
|
| 198 | + return range($node->getStartLine(), $node->name->getEndLine()); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + return []; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + if ($node instanceof MethodCall) { |
|
| 205 | + return [$node->name->getStartLine()]; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + if ($node instanceof Ternary) { |
|
| 209 | + $lines = [$node->cond->getStartLine()]; |
|
| 210 | + |
|
| 211 | + if (null !== $node->if) { |
|
| 212 | + $lines[] = $node->if->getStartLine(); |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + $lines[] = $node->else->getStartLine(); |
|
| 216 | + |
|
| 217 | + return $lines; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + if ($node instanceof Match_) { |
|
| 221 | + return [$node->cond->getStartLine()]; |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + if ($node instanceof MatchArm) { |
|
| 225 | + return [$node->body->getStartLine()]; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + if ($node instanceof Expression && ( |
|
| 229 | + $node->expr instanceof Cast || |
|
| 230 | + $node->expr instanceof Match_ || |
|
| 231 | + $node->expr instanceof MethodCall |
|
| 232 | + )) { |
|
| 233 | + return []; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + if ($node instanceof Return_) { |
|
| 237 | + $this->returns[] = $node; |
|
| 238 | + |
|
| 239 | + return []; |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + return [$node->getStartLine()]; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + private function isExecutable(Node $node): bool |
|
| 246 | + { |
|
| 247 | + return $node instanceof Assign || |
|
| 248 | + $node instanceof ArrayDimFetch || |
|
| 249 | + $node instanceof Array_ || |
|
| 250 | + $node instanceof BinaryOp || |
|
| 251 | + $node instanceof Break_ || |
|
| 252 | + $node instanceof CallLike || |
|
| 253 | + $node instanceof Case_ || |
|
| 254 | + $node instanceof Cast || |
|
| 255 | + $node instanceof Catch_ || |
|
| 256 | + $node instanceof ClassMethod || |
|
| 257 | + $node instanceof Closure || |
|
| 258 | + $node instanceof Continue_ || |
|
| 259 | + $node instanceof Do_ || |
|
| 260 | + $node instanceof Echo_ || |
|
| 261 | + $node instanceof ElseIf_ || |
|
| 262 | + $node instanceof Else_ || |
|
| 263 | + $node instanceof Encapsed || |
|
| 264 | + $node instanceof Expression || |
|
| 265 | + $node instanceof Finally_ || |
|
| 266 | + $node instanceof For_ || |
|
| 267 | + $node instanceof Foreach_ || |
|
| 268 | + $node instanceof Goto_ || |
|
| 269 | + $node instanceof If_ || |
|
| 270 | + $node instanceof Match_ || |
|
| 271 | + $node instanceof MatchArm || |
|
| 272 | + $node instanceof MethodCall || |
|
| 273 | + $node instanceof NullsafePropertyFetch || |
|
| 274 | + $node instanceof PropertyFetch || |
|
| 275 | + $node instanceof Return_ || |
|
| 276 | + $node instanceof StaticPropertyFetch || |
|
| 277 | + $node instanceof Switch_ || |
|
| 278 | + $node instanceof Ternary || |
|
| 279 | + $node instanceof Throw_ || |
|
| 280 | + $node instanceof TryCatch || |
|
| 281 | + $node instanceof Unset_ || |
|
| 282 | + $node instanceof While_; |
|
| 283 | + } |
|
| 284 | 284 | } |
@@ -27,93 +27,93 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | final class IgnoredLinesFindingVisitor extends NodeVisitorAbstract |
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * @psalm-var list<int> |
|
| 32 | - */ |
|
| 33 | - private $ignoredLines = []; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @var bool |
|
| 37 | - */ |
|
| 38 | - private $useAnnotationsForIgnoringCode; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @var bool |
|
| 42 | - */ |
|
| 43 | - private $ignoreDeprecated; |
|
| 44 | - |
|
| 45 | - public function __construct(bool $useAnnotationsForIgnoringCode, bool $ignoreDeprecated) |
|
| 46 | - { |
|
| 47 | - $this->useAnnotationsForIgnoringCode = $useAnnotationsForIgnoringCode; |
|
| 48 | - $this->ignoreDeprecated = $ignoreDeprecated; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public function enterNode(Node $node): void |
|
| 52 | - { |
|
| 53 | - if (!$node instanceof Class_ && |
|
| 54 | - !$node instanceof Trait_ && |
|
| 55 | - !$node instanceof Interface_ && |
|
| 56 | - !$node instanceof ClassMethod && |
|
| 57 | - !$node instanceof Function_ && |
|
| 58 | - !$node instanceof Attribute) { |
|
| 59 | - return; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - if ($node instanceof Class_ && $node->isAnonymous()) { |
|
| 63 | - return; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - if ($node instanceof Class_ || |
|
| 67 | - $node instanceof Trait_ || |
|
| 68 | - $node instanceof Interface_ || |
|
| 69 | - $node instanceof Attribute) { |
|
| 70 | - $this->ignoredLines[] = $node->getStartLine(); |
|
| 71 | - |
|
| 72 | - assert($node->name !== null); |
|
| 73 | - |
|
| 74 | - // Workaround for https://github.com/nikic/PHP-Parser/issues/886 |
|
| 75 | - $this->ignoredLines[] = $node->name->getStartLine(); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - if (!$this->useAnnotationsForIgnoringCode) { |
|
| 79 | - return; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - if ($node instanceof Interface_) { |
|
| 83 | - return; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - $this->processDocComment($node); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @psalm-return list<int> |
|
| 91 | - */ |
|
| 92 | - public function ignoredLines(): array |
|
| 93 | - { |
|
| 94 | - return $this->ignoredLines; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - private function processDocComment(Node $node): void |
|
| 98 | - { |
|
| 99 | - $docComment = $node->getDocComment(); |
|
| 100 | - |
|
| 101 | - if ($docComment === null) { |
|
| 102 | - return; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - if (strpos($docComment->getText(), '@codeCoverageIgnore') !== false) { |
|
| 106 | - $this->ignoredLines = array_merge( |
|
| 107 | - $this->ignoredLines, |
|
| 108 | - range($node->getStartLine(), $node->getEndLine()) |
|
| 109 | - ); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - if ($this->ignoreDeprecated && strpos($docComment->getText(), '@deprecated') !== false) { |
|
| 113 | - $this->ignoredLines = array_merge( |
|
| 114 | - $this->ignoredLines, |
|
| 115 | - range($node->getStartLine(), $node->getEndLine()) |
|
| 116 | - ); |
|
| 117 | - } |
|
| 118 | - } |
|
| 30 | + /** |
|
| 31 | + * @psalm-var list<int> |
|
| 32 | + */ |
|
| 33 | + private $ignoredLines = []; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @var bool |
|
| 37 | + */ |
|
| 38 | + private $useAnnotationsForIgnoringCode; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @var bool |
|
| 42 | + */ |
|
| 43 | + private $ignoreDeprecated; |
|
| 44 | + |
|
| 45 | + public function __construct(bool $useAnnotationsForIgnoringCode, bool $ignoreDeprecated) |
|
| 46 | + { |
|
| 47 | + $this->useAnnotationsForIgnoringCode = $useAnnotationsForIgnoringCode; |
|
| 48 | + $this->ignoreDeprecated = $ignoreDeprecated; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public function enterNode(Node $node): void |
|
| 52 | + { |
|
| 53 | + if (!$node instanceof Class_ && |
|
| 54 | + !$node instanceof Trait_ && |
|
| 55 | + !$node instanceof Interface_ && |
|
| 56 | + !$node instanceof ClassMethod && |
|
| 57 | + !$node instanceof Function_ && |
|
| 58 | + !$node instanceof Attribute) { |
|
| 59 | + return; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + if ($node instanceof Class_ && $node->isAnonymous()) { |
|
| 63 | + return; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + if ($node instanceof Class_ || |
|
| 67 | + $node instanceof Trait_ || |
|
| 68 | + $node instanceof Interface_ || |
|
| 69 | + $node instanceof Attribute) { |
|
| 70 | + $this->ignoredLines[] = $node->getStartLine(); |
|
| 71 | + |
|
| 72 | + assert($node->name !== null); |
|
| 73 | + |
|
| 74 | + // Workaround for https://github.com/nikic/PHP-Parser/issues/886 |
|
| 75 | + $this->ignoredLines[] = $node->name->getStartLine(); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + if (!$this->useAnnotationsForIgnoringCode) { |
|
| 79 | + return; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + if ($node instanceof Interface_) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + $this->processDocComment($node); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @psalm-return list<int> |
|
| 91 | + */ |
|
| 92 | + public function ignoredLines(): array |
|
| 93 | + { |
|
| 94 | + return $this->ignoredLines; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + private function processDocComment(Node $node): void |
|
| 98 | + { |
|
| 99 | + $docComment = $node->getDocComment(); |
|
| 100 | + |
|
| 101 | + if ($docComment === null) { |
|
| 102 | + return; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + if (strpos($docComment->getText(), '@codeCoverageIgnore') !== false) { |
|
| 106 | + $this->ignoredLines = array_merge( |
|
| 107 | + $this->ignoredLines, |
|
| 108 | + range($node->getStartLine(), $node->getEndLine()) |
|
| 109 | + ); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + if ($this->ignoreDeprecated && strpos($docComment->getText(), '@deprecated') !== false) { |
|
| 113 | + $this->ignoredLines = array_merge( |
|
| 114 | + $this->ignoredLines, |
|
| 115 | + range($node->getStartLine(), $node->getEndLine()) |
|
| 116 | + ); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | } |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | public function enterNode(Node $node): void |
| 52 | 52 | { |
| 53 | - if (!$node instanceof Class_ && |
|
| 54 | - !$node instanceof Trait_ && |
|
| 55 | - !$node instanceof Interface_ && |
|
| 56 | - !$node instanceof ClassMethod && |
|
| 57 | - !$node instanceof Function_ && |
|
| 58 | - !$node instanceof Attribute) { |
|
| 53 | + if ( ! $node instanceof Class_ && |
|
| 54 | + ! $node instanceof Trait_ && |
|
| 55 | + ! $node instanceof Interface_ && |
|
| 56 | + ! $node instanceof ClassMethod && |
|
| 57 | + ! $node instanceof Function_ && |
|
| 58 | + ! $node instanceof Attribute) { |
|
| 59 | 59 | return; |
| 60 | 60 | } |
| 61 | 61 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $this->ignoredLines[] = $node->name->getStartLine(); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if (!$this->useAnnotationsForIgnoringCode) { |
|
| 78 | + if ( ! $this->useAnnotationsForIgnoringCode) { |
|
| 79 | 79 | return; |
| 80 | 80 | } |
| 81 | 81 | |
@@ -1,421 +1,421 @@ |
||
| 1 | 1 | <?php return array( |
| 2 | - 'root' => array( |
|
| 3 | - 'name' => 'eventespresso/event-espresso-core', |
|
| 4 | - 'pretty_version' => 'dev-master', |
|
| 5 | - 'version' => 'dev-master', |
|
| 6 | - 'reference' => '1b6228484125d76d73410e4081202e4e4ab8cdd2', |
|
| 7 | - 'type' => 'wordpress-plugin', |
|
| 8 | - 'install_path' => __DIR__ . '/../../', |
|
| 9 | - 'aliases' => array(), |
|
| 10 | - 'dev' => true, |
|
| 11 | - ), |
|
| 12 | - 'versions' => array( |
|
| 13 | - 'doctrine/instantiator' => array( |
|
| 14 | - 'pretty_version' => '1.4.1', |
|
| 15 | - 'version' => '1.4.1.0', |
|
| 16 | - 'reference' => '10dcfce151b967d20fde1b34ae6640712c3891bc', |
|
| 17 | - 'type' => 'library', |
|
| 18 | - 'install_path' => __DIR__ . '/../doctrine/instantiator', |
|
| 19 | - 'aliases' => array(), |
|
| 20 | - 'dev_requirement' => true, |
|
| 21 | - ), |
|
| 22 | - 'dompdf/dompdf' => array( |
|
| 23 | - 'pretty_version' => 'v2.0.1', |
|
| 24 | - 'version' => '2.0.1.0', |
|
| 25 | - 'reference' => 'c5310df0e22c758c85ea5288175fc6cd777bc085', |
|
| 26 | - 'type' => 'library', |
|
| 27 | - 'install_path' => __DIR__ . '/../dompdf/dompdf', |
|
| 28 | - 'aliases' => array(), |
|
| 29 | - 'dev_requirement' => false, |
|
| 30 | - ), |
|
| 31 | - 'eventespresso/ee-coding-standards' => array( |
|
| 32 | - 'pretty_version' => 'dev-master', |
|
| 33 | - 'version' => 'dev-master', |
|
| 34 | - 'reference' => 'f7bd4b8a0566f00342cd952c66b28077fcd3d260', |
|
| 35 | - 'type' => 'phpcodesniffer-standard', |
|
| 36 | - 'install_path' => __DIR__ . '/../eventespresso/ee-coding-standards', |
|
| 37 | - 'aliases' => array( |
|
| 38 | - 0 => '9999999-dev', |
|
| 39 | - ), |
|
| 40 | - 'dev_requirement' => true, |
|
| 41 | - ), |
|
| 42 | - 'eventespresso/event-espresso-core' => array( |
|
| 43 | - 'pretty_version' => 'dev-master', |
|
| 44 | - 'version' => 'dev-master', |
|
| 45 | - 'reference' => '1b6228484125d76d73410e4081202e4e4ab8cdd2', |
|
| 46 | - 'type' => 'wordpress-plugin', |
|
| 47 | - 'install_path' => __DIR__ . '/../../', |
|
| 48 | - 'aliases' => array(), |
|
| 49 | - 'dev_requirement' => false, |
|
| 50 | - ), |
|
| 51 | - 'masterminds/html5' => array( |
|
| 52 | - 'pretty_version' => '2.7.6', |
|
| 53 | - 'version' => '2.7.6.0', |
|
| 54 | - 'reference' => '897eb517a343a2281f11bc5556d6548db7d93947', |
|
| 55 | - 'type' => 'library', |
|
| 56 | - 'install_path' => __DIR__ . '/../masterminds/html5', |
|
| 57 | - 'aliases' => array(), |
|
| 58 | - 'dev_requirement' => false, |
|
| 59 | - ), |
|
| 60 | - 'myclabs/deep-copy' => array( |
|
| 61 | - 'pretty_version' => '1.11.0', |
|
| 62 | - 'version' => '1.11.0.0', |
|
| 63 | - 'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614', |
|
| 64 | - 'type' => 'library', |
|
| 65 | - 'install_path' => __DIR__ . '/../myclabs/deep-copy', |
|
| 66 | - 'aliases' => array(), |
|
| 67 | - 'dev_requirement' => true, |
|
| 68 | - ), |
|
| 69 | - 'nikic/php-parser' => array( |
|
| 70 | - 'pretty_version' => 'v4.15.1', |
|
| 71 | - 'version' => '4.15.1.0', |
|
| 72 | - 'reference' => '0ef6c55a3f47f89d7a374e6f835197a0b5fcf900', |
|
| 73 | - 'type' => 'library', |
|
| 74 | - 'install_path' => __DIR__ . '/../nikic/php-parser', |
|
| 75 | - 'aliases' => array(), |
|
| 76 | - 'dev_requirement' => true, |
|
| 77 | - ), |
|
| 78 | - 'phar-io/manifest' => array( |
|
| 79 | - 'pretty_version' => '2.0.3', |
|
| 80 | - 'version' => '2.0.3.0', |
|
| 81 | - 'reference' => '97803eca37d319dfa7826cc2437fc020857acb53', |
|
| 82 | - 'type' => 'library', |
|
| 83 | - 'install_path' => __DIR__ . '/../phar-io/manifest', |
|
| 84 | - 'aliases' => array(), |
|
| 85 | - 'dev_requirement' => true, |
|
| 86 | - ), |
|
| 87 | - 'phar-io/version' => array( |
|
| 88 | - 'pretty_version' => '3.2.1', |
|
| 89 | - 'version' => '3.2.1.0', |
|
| 90 | - 'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74', |
|
| 91 | - 'type' => 'library', |
|
| 92 | - 'install_path' => __DIR__ . '/../phar-io/version', |
|
| 93 | - 'aliases' => array(), |
|
| 94 | - 'dev_requirement' => true, |
|
| 95 | - ), |
|
| 96 | - 'phenx/php-font-lib' => array( |
|
| 97 | - 'pretty_version' => '0.5.4', |
|
| 98 | - 'version' => '0.5.4.0', |
|
| 99 | - 'reference' => 'dd448ad1ce34c63d09baccd05415e361300c35b4', |
|
| 100 | - 'type' => 'library', |
|
| 101 | - 'install_path' => __DIR__ . '/../phenx/php-font-lib', |
|
| 102 | - 'aliases' => array(), |
|
| 103 | - 'dev_requirement' => false, |
|
| 104 | - ), |
|
| 105 | - 'phenx/php-svg-lib' => array( |
|
| 106 | - 'pretty_version' => '0.5.0', |
|
| 107 | - 'version' => '0.5.0.0', |
|
| 108 | - 'reference' => '76876c6cf3080bcb6f249d7d59705108166a6685', |
|
| 109 | - 'type' => 'library', |
|
| 110 | - 'install_path' => __DIR__ . '/../phenx/php-svg-lib', |
|
| 111 | - 'aliases' => array(), |
|
| 112 | - 'dev_requirement' => false, |
|
| 113 | - ), |
|
| 114 | - 'phpcompatibility/php-compatibility' => array( |
|
| 115 | - 'pretty_version' => '9.3.5', |
|
| 116 | - 'version' => '9.3.5.0', |
|
| 117 | - 'reference' => '9fb324479acf6f39452e0655d2429cc0d3914243', |
|
| 118 | - 'type' => 'phpcodesniffer-standard', |
|
| 119 | - 'install_path' => __DIR__ . '/../phpcompatibility/php-compatibility', |
|
| 120 | - 'aliases' => array(), |
|
| 121 | - 'dev_requirement' => true, |
|
| 122 | - ), |
|
| 123 | - 'phpcompatibility/phpcompatibility-paragonie' => array( |
|
| 124 | - 'pretty_version' => '1.3.2', |
|
| 125 | - 'version' => '1.3.2.0', |
|
| 126 | - 'reference' => 'bba5a9dfec7fcfbd679cfaf611d86b4d3759da26', |
|
| 127 | - 'type' => 'phpcodesniffer-standard', |
|
| 128 | - 'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-paragonie', |
|
| 129 | - 'aliases' => array(), |
|
| 130 | - 'dev_requirement' => true, |
|
| 131 | - ), |
|
| 132 | - 'phpcompatibility/phpcompatibility-wp' => array( |
|
| 133 | - 'pretty_version' => '2.1.4', |
|
| 134 | - 'version' => '2.1.4.0', |
|
| 135 | - 'reference' => 'b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5', |
|
| 136 | - 'type' => 'phpcodesniffer-standard', |
|
| 137 | - 'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-wp', |
|
| 138 | - 'aliases' => array(), |
|
| 139 | - 'dev_requirement' => true, |
|
| 140 | - ), |
|
| 141 | - 'phpunit/php-code-coverage' => array( |
|
| 142 | - 'pretty_version' => '9.2.18', |
|
| 143 | - 'version' => '9.2.18.0', |
|
| 144 | - 'reference' => '12fddc491826940cf9b7e88ad9664cf51f0f6d0a', |
|
| 145 | - 'type' => 'library', |
|
| 146 | - 'install_path' => __DIR__ . '/../phpunit/php-code-coverage', |
|
| 147 | - 'aliases' => array(), |
|
| 148 | - 'dev_requirement' => true, |
|
| 149 | - ), |
|
| 150 | - 'phpunit/php-file-iterator' => array( |
|
| 151 | - 'pretty_version' => '3.0.6', |
|
| 152 | - 'version' => '3.0.6.0', |
|
| 153 | - 'reference' => 'cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf', |
|
| 154 | - 'type' => 'library', |
|
| 155 | - 'install_path' => __DIR__ . '/../phpunit/php-file-iterator', |
|
| 156 | - 'aliases' => array(), |
|
| 157 | - 'dev_requirement' => true, |
|
| 158 | - ), |
|
| 159 | - 'phpunit/php-invoker' => array( |
|
| 160 | - 'pretty_version' => '3.1.1', |
|
| 161 | - 'version' => '3.1.1.0', |
|
| 162 | - 'reference' => '5a10147d0aaf65b58940a0b72f71c9ac0423cc67', |
|
| 163 | - 'type' => 'library', |
|
| 164 | - 'install_path' => __DIR__ . '/../phpunit/php-invoker', |
|
| 165 | - 'aliases' => array(), |
|
| 166 | - 'dev_requirement' => true, |
|
| 167 | - ), |
|
| 168 | - 'phpunit/php-text-template' => array( |
|
| 169 | - 'pretty_version' => '2.0.4', |
|
| 170 | - 'version' => '2.0.4.0', |
|
| 171 | - 'reference' => '5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28', |
|
| 172 | - 'type' => 'library', |
|
| 173 | - 'install_path' => __DIR__ . '/../phpunit/php-text-template', |
|
| 174 | - 'aliases' => array(), |
|
| 175 | - 'dev_requirement' => true, |
|
| 176 | - ), |
|
| 177 | - 'phpunit/php-timer' => array( |
|
| 178 | - 'pretty_version' => '5.0.3', |
|
| 179 | - 'version' => '5.0.3.0', |
|
| 180 | - 'reference' => '5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2', |
|
| 181 | - 'type' => 'library', |
|
| 182 | - 'install_path' => __DIR__ . '/../phpunit/php-timer', |
|
| 183 | - 'aliases' => array(), |
|
| 184 | - 'dev_requirement' => true, |
|
| 185 | - ), |
|
| 186 | - 'phpunit/phpunit' => array( |
|
| 187 | - 'pretty_version' => '9.5.25', |
|
| 188 | - 'version' => '9.5.25.0', |
|
| 189 | - 'reference' => '3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d', |
|
| 190 | - 'type' => 'library', |
|
| 191 | - 'install_path' => __DIR__ . '/../phpunit/phpunit', |
|
| 192 | - 'aliases' => array(), |
|
| 193 | - 'dev_requirement' => true, |
|
| 194 | - ), |
|
| 195 | - 'roave/security-advisories' => array( |
|
| 196 | - 'pretty_version' => 'dev-master', |
|
| 197 | - 'version' => 'dev-master', |
|
| 198 | - 'reference' => 'd55c618dc2c5141caa00a416ca21bb6f06cf00e0', |
|
| 199 | - 'type' => 'metapackage', |
|
| 200 | - 'install_path' => NULL, |
|
| 201 | - 'aliases' => array(), |
|
| 202 | - 'dev_requirement' => true, |
|
| 203 | - ), |
|
| 204 | - 'sabberworm/php-css-parser' => array( |
|
| 205 | - 'pretty_version' => '8.4.0', |
|
| 206 | - 'version' => '8.4.0.0', |
|
| 207 | - 'reference' => 'e41d2140031d533348b2192a83f02d8dd8a71d30', |
|
| 208 | - 'type' => 'library', |
|
| 209 | - 'install_path' => __DIR__ . '/../sabberworm/php-css-parser', |
|
| 210 | - 'aliases' => array(), |
|
| 211 | - 'dev_requirement' => false, |
|
| 212 | - ), |
|
| 213 | - 'sebastian/cli-parser' => array( |
|
| 214 | - 'pretty_version' => '1.0.1', |
|
| 215 | - 'version' => '1.0.1.0', |
|
| 216 | - 'reference' => '442e7c7e687e42adc03470c7b668bc4b2402c0b2', |
|
| 217 | - 'type' => 'library', |
|
| 218 | - 'install_path' => __DIR__ . '/../sebastian/cli-parser', |
|
| 219 | - 'aliases' => array(), |
|
| 220 | - 'dev_requirement' => true, |
|
| 221 | - ), |
|
| 222 | - 'sebastian/code-unit' => array( |
|
| 223 | - 'pretty_version' => '1.0.8', |
|
| 224 | - 'version' => '1.0.8.0', |
|
| 225 | - 'reference' => '1fc9f64c0927627ef78ba436c9b17d967e68e120', |
|
| 226 | - 'type' => 'library', |
|
| 227 | - 'install_path' => __DIR__ . '/../sebastian/code-unit', |
|
| 228 | - 'aliases' => array(), |
|
| 229 | - 'dev_requirement' => true, |
|
| 230 | - ), |
|
| 231 | - 'sebastian/code-unit-reverse-lookup' => array( |
|
| 232 | - 'pretty_version' => '2.0.3', |
|
| 233 | - 'version' => '2.0.3.0', |
|
| 234 | - 'reference' => 'ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5', |
|
| 235 | - 'type' => 'library', |
|
| 236 | - 'install_path' => __DIR__ . '/../sebastian/code-unit-reverse-lookup', |
|
| 237 | - 'aliases' => array(), |
|
| 238 | - 'dev_requirement' => true, |
|
| 239 | - ), |
|
| 240 | - 'sebastian/comparator' => array( |
|
| 241 | - 'pretty_version' => '4.0.8', |
|
| 242 | - 'version' => '4.0.8.0', |
|
| 243 | - 'reference' => 'fa0f136dd2334583309d32b62544682ee972b51a', |
|
| 244 | - 'type' => 'library', |
|
| 245 | - 'install_path' => __DIR__ . '/../sebastian/comparator', |
|
| 246 | - 'aliases' => array(), |
|
| 247 | - 'dev_requirement' => true, |
|
| 248 | - ), |
|
| 249 | - 'sebastian/complexity' => array( |
|
| 250 | - 'pretty_version' => '2.0.2', |
|
| 251 | - 'version' => '2.0.2.0', |
|
| 252 | - 'reference' => '739b35e53379900cc9ac327b2147867b8b6efd88', |
|
| 253 | - 'type' => 'library', |
|
| 254 | - 'install_path' => __DIR__ . '/../sebastian/complexity', |
|
| 255 | - 'aliases' => array(), |
|
| 256 | - 'dev_requirement' => true, |
|
| 257 | - ), |
|
| 258 | - 'sebastian/diff' => array( |
|
| 259 | - 'pretty_version' => '4.0.4', |
|
| 260 | - 'version' => '4.0.4.0', |
|
| 261 | - 'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d', |
|
| 262 | - 'type' => 'library', |
|
| 263 | - 'install_path' => __DIR__ . '/../sebastian/diff', |
|
| 264 | - 'aliases' => array(), |
|
| 265 | - 'dev_requirement' => true, |
|
| 266 | - ), |
|
| 267 | - 'sebastian/environment' => array( |
|
| 268 | - 'pretty_version' => '5.1.4', |
|
| 269 | - 'version' => '5.1.4.0', |
|
| 270 | - 'reference' => '1b5dff7bb151a4db11d49d90e5408e4e938270f7', |
|
| 271 | - 'type' => 'library', |
|
| 272 | - 'install_path' => __DIR__ . '/../sebastian/environment', |
|
| 273 | - 'aliases' => array(), |
|
| 274 | - 'dev_requirement' => true, |
|
| 275 | - ), |
|
| 276 | - 'sebastian/exporter' => array( |
|
| 277 | - 'pretty_version' => '4.0.5', |
|
| 278 | - 'version' => '4.0.5.0', |
|
| 279 | - 'reference' => 'ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d', |
|
| 280 | - 'type' => 'library', |
|
| 281 | - 'install_path' => __DIR__ . '/../sebastian/exporter', |
|
| 282 | - 'aliases' => array(), |
|
| 283 | - 'dev_requirement' => true, |
|
| 284 | - ), |
|
| 285 | - 'sebastian/global-state' => array( |
|
| 286 | - 'pretty_version' => '5.0.5', |
|
| 287 | - 'version' => '5.0.5.0', |
|
| 288 | - 'reference' => '0ca8db5a5fc9c8646244e629625ac486fa286bf2', |
|
| 289 | - 'type' => 'library', |
|
| 290 | - 'install_path' => __DIR__ . '/../sebastian/global-state', |
|
| 291 | - 'aliases' => array(), |
|
| 292 | - 'dev_requirement' => true, |
|
| 293 | - ), |
|
| 294 | - 'sebastian/lines-of-code' => array( |
|
| 295 | - 'pretty_version' => '1.0.3', |
|
| 296 | - 'version' => '1.0.3.0', |
|
| 297 | - 'reference' => 'c1c2e997aa3146983ed888ad08b15470a2e22ecc', |
|
| 298 | - 'type' => 'library', |
|
| 299 | - 'install_path' => __DIR__ . '/../sebastian/lines-of-code', |
|
| 300 | - 'aliases' => array(), |
|
| 301 | - 'dev_requirement' => true, |
|
| 302 | - ), |
|
| 303 | - 'sebastian/object-enumerator' => array( |
|
| 304 | - 'pretty_version' => '4.0.4', |
|
| 305 | - 'version' => '4.0.4.0', |
|
| 306 | - 'reference' => '5c9eeac41b290a3712d88851518825ad78f45c71', |
|
| 307 | - 'type' => 'library', |
|
| 308 | - 'install_path' => __DIR__ . '/../sebastian/object-enumerator', |
|
| 309 | - 'aliases' => array(), |
|
| 310 | - 'dev_requirement' => true, |
|
| 311 | - ), |
|
| 312 | - 'sebastian/object-reflector' => array( |
|
| 313 | - 'pretty_version' => '2.0.4', |
|
| 314 | - 'version' => '2.0.4.0', |
|
| 315 | - 'reference' => 'b4f479ebdbf63ac605d183ece17d8d7fe49c15c7', |
|
| 316 | - 'type' => 'library', |
|
| 317 | - 'install_path' => __DIR__ . '/../sebastian/object-reflector', |
|
| 318 | - 'aliases' => array(), |
|
| 319 | - 'dev_requirement' => true, |
|
| 320 | - ), |
|
| 321 | - 'sebastian/recursion-context' => array( |
|
| 322 | - 'pretty_version' => '4.0.4', |
|
| 323 | - 'version' => '4.0.4.0', |
|
| 324 | - 'reference' => 'cd9d8cf3c5804de4341c283ed787f099f5506172', |
|
| 325 | - 'type' => 'library', |
|
| 326 | - 'install_path' => __DIR__ . '/../sebastian/recursion-context', |
|
| 327 | - 'aliases' => array(), |
|
| 328 | - 'dev_requirement' => true, |
|
| 329 | - ), |
|
| 330 | - 'sebastian/resource-operations' => array( |
|
| 331 | - 'pretty_version' => '3.0.3', |
|
| 332 | - 'version' => '3.0.3.0', |
|
| 333 | - 'reference' => '0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8', |
|
| 334 | - 'type' => 'library', |
|
| 335 | - 'install_path' => __DIR__ . '/../sebastian/resource-operations', |
|
| 336 | - 'aliases' => array(), |
|
| 337 | - 'dev_requirement' => true, |
|
| 338 | - ), |
|
| 339 | - 'sebastian/type' => array( |
|
| 340 | - 'pretty_version' => '3.2.0', |
|
| 341 | - 'version' => '3.2.0.0', |
|
| 342 | - 'reference' => 'fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e', |
|
| 343 | - 'type' => 'library', |
|
| 344 | - 'install_path' => __DIR__ . '/../sebastian/type', |
|
| 345 | - 'aliases' => array(), |
|
| 346 | - 'dev_requirement' => true, |
|
| 347 | - ), |
|
| 348 | - 'sebastian/version' => array( |
|
| 349 | - 'pretty_version' => '3.0.2', |
|
| 350 | - 'version' => '3.0.2.0', |
|
| 351 | - 'reference' => 'c6c1022351a901512170118436c764e473f6de8c', |
|
| 352 | - 'type' => 'library', |
|
| 353 | - 'install_path' => __DIR__ . '/../sebastian/version', |
|
| 354 | - 'aliases' => array(), |
|
| 355 | - 'dev_requirement' => true, |
|
| 356 | - ), |
|
| 357 | - 'squizlabs/php_codesniffer' => array( |
|
| 358 | - 'pretty_version' => '3.7.1', |
|
| 359 | - 'version' => '3.7.1.0', |
|
| 360 | - 'reference' => '1359e176e9307e906dc3d890bcc9603ff6d90619', |
|
| 361 | - 'type' => 'library', |
|
| 362 | - 'install_path' => __DIR__ . '/../squizlabs/php_codesniffer', |
|
| 363 | - 'aliases' => array(), |
|
| 364 | - 'dev_requirement' => true, |
|
| 365 | - ), |
|
| 366 | - 'symfony/css-selector' => array( |
|
| 367 | - 'pretty_version' => 'v5.4.11', |
|
| 368 | - 'version' => '5.4.11.0', |
|
| 369 | - 'reference' => 'c1681789f059ab756001052164726ae88512ae3d', |
|
| 370 | - 'type' => 'library', |
|
| 371 | - 'install_path' => __DIR__ . '/../symfony/css-selector', |
|
| 372 | - 'aliases' => array(), |
|
| 373 | - 'dev_requirement' => false, |
|
| 374 | - ), |
|
| 375 | - 'symfony/polyfill-php80' => array( |
|
| 376 | - 'pretty_version' => 'v1.26.0', |
|
| 377 | - 'version' => '1.26.0.0', |
|
| 378 | - 'reference' => 'cfa0ae98841b9e461207c13ab093d76b0fa7bace', |
|
| 379 | - 'type' => 'library', |
|
| 380 | - 'install_path' => __DIR__ . '/../symfony/polyfill-php80', |
|
| 381 | - 'aliases' => array(), |
|
| 382 | - 'dev_requirement' => false, |
|
| 383 | - ), |
|
| 384 | - 'theseer/tokenizer' => array( |
|
| 385 | - 'pretty_version' => '1.2.1', |
|
| 386 | - 'version' => '1.2.1.0', |
|
| 387 | - 'reference' => '34a41e998c2183e22995f158c581e7b5e755ab9e', |
|
| 388 | - 'type' => 'library', |
|
| 389 | - 'install_path' => __DIR__ . '/../theseer/tokenizer', |
|
| 390 | - 'aliases' => array(), |
|
| 391 | - 'dev_requirement' => true, |
|
| 392 | - ), |
|
| 393 | - 'tijsverkoyen/css-to-inline-styles' => array( |
|
| 394 | - 'pretty_version' => '2.2.3', |
|
| 395 | - 'version' => '2.2.3.0', |
|
| 396 | - 'reference' => 'b43b05cf43c1b6d849478965062b6ef73e223bb5', |
|
| 397 | - 'type' => 'library', |
|
| 398 | - 'install_path' => __DIR__ . '/../tijsverkoyen/css-to-inline-styles', |
|
| 399 | - 'aliases' => array(), |
|
| 400 | - 'dev_requirement' => false, |
|
| 401 | - ), |
|
| 402 | - 'wp-coding-standards/wpcs' => array( |
|
| 403 | - 'pretty_version' => '2.3.0', |
|
| 404 | - 'version' => '2.3.0.0', |
|
| 405 | - 'reference' => '7da1894633f168fe244afc6de00d141f27517b62', |
|
| 406 | - 'type' => 'phpcodesniffer-standard', |
|
| 407 | - 'install_path' => __DIR__ . '/../wp-coding-standards/wpcs', |
|
| 408 | - 'aliases' => array(), |
|
| 409 | - 'dev_requirement' => true, |
|
| 410 | - ), |
|
| 411 | - 'yoast/phpunit-polyfills' => array( |
|
| 412 | - 'pretty_version' => '1.0.3', |
|
| 413 | - 'version' => '1.0.3.0', |
|
| 414 | - 'reference' => '5ea3536428944955f969bc764bbe09738e151ada', |
|
| 415 | - 'type' => 'library', |
|
| 416 | - 'install_path' => __DIR__ . '/../yoast/phpunit-polyfills', |
|
| 417 | - 'aliases' => array(), |
|
| 418 | - 'dev_requirement' => true, |
|
| 419 | - ), |
|
| 420 | - ), |
|
| 2 | + 'root' => array( |
|
| 3 | + 'name' => 'eventespresso/event-espresso-core', |
|
| 4 | + 'pretty_version' => 'dev-master', |
|
| 5 | + 'version' => 'dev-master', |
|
| 6 | + 'reference' => '1b6228484125d76d73410e4081202e4e4ab8cdd2', |
|
| 7 | + 'type' => 'wordpress-plugin', |
|
| 8 | + 'install_path' => __DIR__ . '/../../', |
|
| 9 | + 'aliases' => array(), |
|
| 10 | + 'dev' => true, |
|
| 11 | + ), |
|
| 12 | + 'versions' => array( |
|
| 13 | + 'doctrine/instantiator' => array( |
|
| 14 | + 'pretty_version' => '1.4.1', |
|
| 15 | + 'version' => '1.4.1.0', |
|
| 16 | + 'reference' => '10dcfce151b967d20fde1b34ae6640712c3891bc', |
|
| 17 | + 'type' => 'library', |
|
| 18 | + 'install_path' => __DIR__ . '/../doctrine/instantiator', |
|
| 19 | + 'aliases' => array(), |
|
| 20 | + 'dev_requirement' => true, |
|
| 21 | + ), |
|
| 22 | + 'dompdf/dompdf' => array( |
|
| 23 | + 'pretty_version' => 'v2.0.1', |
|
| 24 | + 'version' => '2.0.1.0', |
|
| 25 | + 'reference' => 'c5310df0e22c758c85ea5288175fc6cd777bc085', |
|
| 26 | + 'type' => 'library', |
|
| 27 | + 'install_path' => __DIR__ . '/../dompdf/dompdf', |
|
| 28 | + 'aliases' => array(), |
|
| 29 | + 'dev_requirement' => false, |
|
| 30 | + ), |
|
| 31 | + 'eventespresso/ee-coding-standards' => array( |
|
| 32 | + 'pretty_version' => 'dev-master', |
|
| 33 | + 'version' => 'dev-master', |
|
| 34 | + 'reference' => 'f7bd4b8a0566f00342cd952c66b28077fcd3d260', |
|
| 35 | + 'type' => 'phpcodesniffer-standard', |
|
| 36 | + 'install_path' => __DIR__ . '/../eventespresso/ee-coding-standards', |
|
| 37 | + 'aliases' => array( |
|
| 38 | + 0 => '9999999-dev', |
|
| 39 | + ), |
|
| 40 | + 'dev_requirement' => true, |
|
| 41 | + ), |
|
| 42 | + 'eventespresso/event-espresso-core' => array( |
|
| 43 | + 'pretty_version' => 'dev-master', |
|
| 44 | + 'version' => 'dev-master', |
|
| 45 | + 'reference' => '1b6228484125d76d73410e4081202e4e4ab8cdd2', |
|
| 46 | + 'type' => 'wordpress-plugin', |
|
| 47 | + 'install_path' => __DIR__ . '/../../', |
|
| 48 | + 'aliases' => array(), |
|
| 49 | + 'dev_requirement' => false, |
|
| 50 | + ), |
|
| 51 | + 'masterminds/html5' => array( |
|
| 52 | + 'pretty_version' => '2.7.6', |
|
| 53 | + 'version' => '2.7.6.0', |
|
| 54 | + 'reference' => '897eb517a343a2281f11bc5556d6548db7d93947', |
|
| 55 | + 'type' => 'library', |
|
| 56 | + 'install_path' => __DIR__ . '/../masterminds/html5', |
|
| 57 | + 'aliases' => array(), |
|
| 58 | + 'dev_requirement' => false, |
|
| 59 | + ), |
|
| 60 | + 'myclabs/deep-copy' => array( |
|
| 61 | + 'pretty_version' => '1.11.0', |
|
| 62 | + 'version' => '1.11.0.0', |
|
| 63 | + 'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614', |
|
| 64 | + 'type' => 'library', |
|
| 65 | + 'install_path' => __DIR__ . '/../myclabs/deep-copy', |
|
| 66 | + 'aliases' => array(), |
|
| 67 | + 'dev_requirement' => true, |
|
| 68 | + ), |
|
| 69 | + 'nikic/php-parser' => array( |
|
| 70 | + 'pretty_version' => 'v4.15.1', |
|
| 71 | + 'version' => '4.15.1.0', |
|
| 72 | + 'reference' => '0ef6c55a3f47f89d7a374e6f835197a0b5fcf900', |
|
| 73 | + 'type' => 'library', |
|
| 74 | + 'install_path' => __DIR__ . '/../nikic/php-parser', |
|
| 75 | + 'aliases' => array(), |
|
| 76 | + 'dev_requirement' => true, |
|
| 77 | + ), |
|
| 78 | + 'phar-io/manifest' => array( |
|
| 79 | + 'pretty_version' => '2.0.3', |
|
| 80 | + 'version' => '2.0.3.0', |
|
| 81 | + 'reference' => '97803eca37d319dfa7826cc2437fc020857acb53', |
|
| 82 | + 'type' => 'library', |
|
| 83 | + 'install_path' => __DIR__ . '/../phar-io/manifest', |
|
| 84 | + 'aliases' => array(), |
|
| 85 | + 'dev_requirement' => true, |
|
| 86 | + ), |
|
| 87 | + 'phar-io/version' => array( |
|
| 88 | + 'pretty_version' => '3.2.1', |
|
| 89 | + 'version' => '3.2.1.0', |
|
| 90 | + 'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74', |
|
| 91 | + 'type' => 'library', |
|
| 92 | + 'install_path' => __DIR__ . '/../phar-io/version', |
|
| 93 | + 'aliases' => array(), |
|
| 94 | + 'dev_requirement' => true, |
|
| 95 | + ), |
|
| 96 | + 'phenx/php-font-lib' => array( |
|
| 97 | + 'pretty_version' => '0.5.4', |
|
| 98 | + 'version' => '0.5.4.0', |
|
| 99 | + 'reference' => 'dd448ad1ce34c63d09baccd05415e361300c35b4', |
|
| 100 | + 'type' => 'library', |
|
| 101 | + 'install_path' => __DIR__ . '/../phenx/php-font-lib', |
|
| 102 | + 'aliases' => array(), |
|
| 103 | + 'dev_requirement' => false, |
|
| 104 | + ), |
|
| 105 | + 'phenx/php-svg-lib' => array( |
|
| 106 | + 'pretty_version' => '0.5.0', |
|
| 107 | + 'version' => '0.5.0.0', |
|
| 108 | + 'reference' => '76876c6cf3080bcb6f249d7d59705108166a6685', |
|
| 109 | + 'type' => 'library', |
|
| 110 | + 'install_path' => __DIR__ . '/../phenx/php-svg-lib', |
|
| 111 | + 'aliases' => array(), |
|
| 112 | + 'dev_requirement' => false, |
|
| 113 | + ), |
|
| 114 | + 'phpcompatibility/php-compatibility' => array( |
|
| 115 | + 'pretty_version' => '9.3.5', |
|
| 116 | + 'version' => '9.3.5.0', |
|
| 117 | + 'reference' => '9fb324479acf6f39452e0655d2429cc0d3914243', |
|
| 118 | + 'type' => 'phpcodesniffer-standard', |
|
| 119 | + 'install_path' => __DIR__ . '/../phpcompatibility/php-compatibility', |
|
| 120 | + 'aliases' => array(), |
|
| 121 | + 'dev_requirement' => true, |
|
| 122 | + ), |
|
| 123 | + 'phpcompatibility/phpcompatibility-paragonie' => array( |
|
| 124 | + 'pretty_version' => '1.3.2', |
|
| 125 | + 'version' => '1.3.2.0', |
|
| 126 | + 'reference' => 'bba5a9dfec7fcfbd679cfaf611d86b4d3759da26', |
|
| 127 | + 'type' => 'phpcodesniffer-standard', |
|
| 128 | + 'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-paragonie', |
|
| 129 | + 'aliases' => array(), |
|
| 130 | + 'dev_requirement' => true, |
|
| 131 | + ), |
|
| 132 | + 'phpcompatibility/phpcompatibility-wp' => array( |
|
| 133 | + 'pretty_version' => '2.1.4', |
|
| 134 | + 'version' => '2.1.4.0', |
|
| 135 | + 'reference' => 'b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5', |
|
| 136 | + 'type' => 'phpcodesniffer-standard', |
|
| 137 | + 'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-wp', |
|
| 138 | + 'aliases' => array(), |
|
| 139 | + 'dev_requirement' => true, |
|
| 140 | + ), |
|
| 141 | + 'phpunit/php-code-coverage' => array( |
|
| 142 | + 'pretty_version' => '9.2.18', |
|
| 143 | + 'version' => '9.2.18.0', |
|
| 144 | + 'reference' => '12fddc491826940cf9b7e88ad9664cf51f0f6d0a', |
|
| 145 | + 'type' => 'library', |
|
| 146 | + 'install_path' => __DIR__ . '/../phpunit/php-code-coverage', |
|
| 147 | + 'aliases' => array(), |
|
| 148 | + 'dev_requirement' => true, |
|
| 149 | + ), |
|
| 150 | + 'phpunit/php-file-iterator' => array( |
|
| 151 | + 'pretty_version' => '3.0.6', |
|
| 152 | + 'version' => '3.0.6.0', |
|
| 153 | + 'reference' => 'cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf', |
|
| 154 | + 'type' => 'library', |
|
| 155 | + 'install_path' => __DIR__ . '/../phpunit/php-file-iterator', |
|
| 156 | + 'aliases' => array(), |
|
| 157 | + 'dev_requirement' => true, |
|
| 158 | + ), |
|
| 159 | + 'phpunit/php-invoker' => array( |
|
| 160 | + 'pretty_version' => '3.1.1', |
|
| 161 | + 'version' => '3.1.1.0', |
|
| 162 | + 'reference' => '5a10147d0aaf65b58940a0b72f71c9ac0423cc67', |
|
| 163 | + 'type' => 'library', |
|
| 164 | + 'install_path' => __DIR__ . '/../phpunit/php-invoker', |
|
| 165 | + 'aliases' => array(), |
|
| 166 | + 'dev_requirement' => true, |
|
| 167 | + ), |
|
| 168 | + 'phpunit/php-text-template' => array( |
|
| 169 | + 'pretty_version' => '2.0.4', |
|
| 170 | + 'version' => '2.0.4.0', |
|
| 171 | + 'reference' => '5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28', |
|
| 172 | + 'type' => 'library', |
|
| 173 | + 'install_path' => __DIR__ . '/../phpunit/php-text-template', |
|
| 174 | + 'aliases' => array(), |
|
| 175 | + 'dev_requirement' => true, |
|
| 176 | + ), |
|
| 177 | + 'phpunit/php-timer' => array( |
|
| 178 | + 'pretty_version' => '5.0.3', |
|
| 179 | + 'version' => '5.0.3.0', |
|
| 180 | + 'reference' => '5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2', |
|
| 181 | + 'type' => 'library', |
|
| 182 | + 'install_path' => __DIR__ . '/../phpunit/php-timer', |
|
| 183 | + 'aliases' => array(), |
|
| 184 | + 'dev_requirement' => true, |
|
| 185 | + ), |
|
| 186 | + 'phpunit/phpunit' => array( |
|
| 187 | + 'pretty_version' => '9.5.25', |
|
| 188 | + 'version' => '9.5.25.0', |
|
| 189 | + 'reference' => '3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d', |
|
| 190 | + 'type' => 'library', |
|
| 191 | + 'install_path' => __DIR__ . '/../phpunit/phpunit', |
|
| 192 | + 'aliases' => array(), |
|
| 193 | + 'dev_requirement' => true, |
|
| 194 | + ), |
|
| 195 | + 'roave/security-advisories' => array( |
|
| 196 | + 'pretty_version' => 'dev-master', |
|
| 197 | + 'version' => 'dev-master', |
|
| 198 | + 'reference' => 'd55c618dc2c5141caa00a416ca21bb6f06cf00e0', |
|
| 199 | + 'type' => 'metapackage', |
|
| 200 | + 'install_path' => NULL, |
|
| 201 | + 'aliases' => array(), |
|
| 202 | + 'dev_requirement' => true, |
|
| 203 | + ), |
|
| 204 | + 'sabberworm/php-css-parser' => array( |
|
| 205 | + 'pretty_version' => '8.4.0', |
|
| 206 | + 'version' => '8.4.0.0', |
|
| 207 | + 'reference' => 'e41d2140031d533348b2192a83f02d8dd8a71d30', |
|
| 208 | + 'type' => 'library', |
|
| 209 | + 'install_path' => __DIR__ . '/../sabberworm/php-css-parser', |
|
| 210 | + 'aliases' => array(), |
|
| 211 | + 'dev_requirement' => false, |
|
| 212 | + ), |
|
| 213 | + 'sebastian/cli-parser' => array( |
|
| 214 | + 'pretty_version' => '1.0.1', |
|
| 215 | + 'version' => '1.0.1.0', |
|
| 216 | + 'reference' => '442e7c7e687e42adc03470c7b668bc4b2402c0b2', |
|
| 217 | + 'type' => 'library', |
|
| 218 | + 'install_path' => __DIR__ . '/../sebastian/cli-parser', |
|
| 219 | + 'aliases' => array(), |
|
| 220 | + 'dev_requirement' => true, |
|
| 221 | + ), |
|
| 222 | + 'sebastian/code-unit' => array( |
|
| 223 | + 'pretty_version' => '1.0.8', |
|
| 224 | + 'version' => '1.0.8.0', |
|
| 225 | + 'reference' => '1fc9f64c0927627ef78ba436c9b17d967e68e120', |
|
| 226 | + 'type' => 'library', |
|
| 227 | + 'install_path' => __DIR__ . '/../sebastian/code-unit', |
|
| 228 | + 'aliases' => array(), |
|
| 229 | + 'dev_requirement' => true, |
|
| 230 | + ), |
|
| 231 | + 'sebastian/code-unit-reverse-lookup' => array( |
|
| 232 | + 'pretty_version' => '2.0.3', |
|
| 233 | + 'version' => '2.0.3.0', |
|
| 234 | + 'reference' => 'ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5', |
|
| 235 | + 'type' => 'library', |
|
| 236 | + 'install_path' => __DIR__ . '/../sebastian/code-unit-reverse-lookup', |
|
| 237 | + 'aliases' => array(), |
|
| 238 | + 'dev_requirement' => true, |
|
| 239 | + ), |
|
| 240 | + 'sebastian/comparator' => array( |
|
| 241 | + 'pretty_version' => '4.0.8', |
|
| 242 | + 'version' => '4.0.8.0', |
|
| 243 | + 'reference' => 'fa0f136dd2334583309d32b62544682ee972b51a', |
|
| 244 | + 'type' => 'library', |
|
| 245 | + 'install_path' => __DIR__ . '/../sebastian/comparator', |
|
| 246 | + 'aliases' => array(), |
|
| 247 | + 'dev_requirement' => true, |
|
| 248 | + ), |
|
| 249 | + 'sebastian/complexity' => array( |
|
| 250 | + 'pretty_version' => '2.0.2', |
|
| 251 | + 'version' => '2.0.2.0', |
|
| 252 | + 'reference' => '739b35e53379900cc9ac327b2147867b8b6efd88', |
|
| 253 | + 'type' => 'library', |
|
| 254 | + 'install_path' => __DIR__ . '/../sebastian/complexity', |
|
| 255 | + 'aliases' => array(), |
|
| 256 | + 'dev_requirement' => true, |
|
| 257 | + ), |
|
| 258 | + 'sebastian/diff' => array( |
|
| 259 | + 'pretty_version' => '4.0.4', |
|
| 260 | + 'version' => '4.0.4.0', |
|
| 261 | + 'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d', |
|
| 262 | + 'type' => 'library', |
|
| 263 | + 'install_path' => __DIR__ . '/../sebastian/diff', |
|
| 264 | + 'aliases' => array(), |
|
| 265 | + 'dev_requirement' => true, |
|
| 266 | + ), |
|
| 267 | + 'sebastian/environment' => array( |
|
| 268 | + 'pretty_version' => '5.1.4', |
|
| 269 | + 'version' => '5.1.4.0', |
|
| 270 | + 'reference' => '1b5dff7bb151a4db11d49d90e5408e4e938270f7', |
|
| 271 | + 'type' => 'library', |
|
| 272 | + 'install_path' => __DIR__ . '/../sebastian/environment', |
|
| 273 | + 'aliases' => array(), |
|
| 274 | + 'dev_requirement' => true, |
|
| 275 | + ), |
|
| 276 | + 'sebastian/exporter' => array( |
|
| 277 | + 'pretty_version' => '4.0.5', |
|
| 278 | + 'version' => '4.0.5.0', |
|
| 279 | + 'reference' => 'ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d', |
|
| 280 | + 'type' => 'library', |
|
| 281 | + 'install_path' => __DIR__ . '/../sebastian/exporter', |
|
| 282 | + 'aliases' => array(), |
|
| 283 | + 'dev_requirement' => true, |
|
| 284 | + ), |
|
| 285 | + 'sebastian/global-state' => array( |
|
| 286 | + 'pretty_version' => '5.0.5', |
|
| 287 | + 'version' => '5.0.5.0', |
|
| 288 | + 'reference' => '0ca8db5a5fc9c8646244e629625ac486fa286bf2', |
|
| 289 | + 'type' => 'library', |
|
| 290 | + 'install_path' => __DIR__ . '/../sebastian/global-state', |
|
| 291 | + 'aliases' => array(), |
|
| 292 | + 'dev_requirement' => true, |
|
| 293 | + ), |
|
| 294 | + 'sebastian/lines-of-code' => array( |
|
| 295 | + 'pretty_version' => '1.0.3', |
|
| 296 | + 'version' => '1.0.3.0', |
|
| 297 | + 'reference' => 'c1c2e997aa3146983ed888ad08b15470a2e22ecc', |
|
| 298 | + 'type' => 'library', |
|
| 299 | + 'install_path' => __DIR__ . '/../sebastian/lines-of-code', |
|
| 300 | + 'aliases' => array(), |
|
| 301 | + 'dev_requirement' => true, |
|
| 302 | + ), |
|
| 303 | + 'sebastian/object-enumerator' => array( |
|
| 304 | + 'pretty_version' => '4.0.4', |
|
| 305 | + 'version' => '4.0.4.0', |
|
| 306 | + 'reference' => '5c9eeac41b290a3712d88851518825ad78f45c71', |
|
| 307 | + 'type' => 'library', |
|
| 308 | + 'install_path' => __DIR__ . '/../sebastian/object-enumerator', |
|
| 309 | + 'aliases' => array(), |
|
| 310 | + 'dev_requirement' => true, |
|
| 311 | + ), |
|
| 312 | + 'sebastian/object-reflector' => array( |
|
| 313 | + 'pretty_version' => '2.0.4', |
|
| 314 | + 'version' => '2.0.4.0', |
|
| 315 | + 'reference' => 'b4f479ebdbf63ac605d183ece17d8d7fe49c15c7', |
|
| 316 | + 'type' => 'library', |
|
| 317 | + 'install_path' => __DIR__ . '/../sebastian/object-reflector', |
|
| 318 | + 'aliases' => array(), |
|
| 319 | + 'dev_requirement' => true, |
|
| 320 | + ), |
|
| 321 | + 'sebastian/recursion-context' => array( |
|
| 322 | + 'pretty_version' => '4.0.4', |
|
| 323 | + 'version' => '4.0.4.0', |
|
| 324 | + 'reference' => 'cd9d8cf3c5804de4341c283ed787f099f5506172', |
|
| 325 | + 'type' => 'library', |
|
| 326 | + 'install_path' => __DIR__ . '/../sebastian/recursion-context', |
|
| 327 | + 'aliases' => array(), |
|
| 328 | + 'dev_requirement' => true, |
|
| 329 | + ), |
|
| 330 | + 'sebastian/resource-operations' => array( |
|
| 331 | + 'pretty_version' => '3.0.3', |
|
| 332 | + 'version' => '3.0.3.0', |
|
| 333 | + 'reference' => '0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8', |
|
| 334 | + 'type' => 'library', |
|
| 335 | + 'install_path' => __DIR__ . '/../sebastian/resource-operations', |
|
| 336 | + 'aliases' => array(), |
|
| 337 | + 'dev_requirement' => true, |
|
| 338 | + ), |
|
| 339 | + 'sebastian/type' => array( |
|
| 340 | + 'pretty_version' => '3.2.0', |
|
| 341 | + 'version' => '3.2.0.0', |
|
| 342 | + 'reference' => 'fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e', |
|
| 343 | + 'type' => 'library', |
|
| 344 | + 'install_path' => __DIR__ . '/../sebastian/type', |
|
| 345 | + 'aliases' => array(), |
|
| 346 | + 'dev_requirement' => true, |
|
| 347 | + ), |
|
| 348 | + 'sebastian/version' => array( |
|
| 349 | + 'pretty_version' => '3.0.2', |
|
| 350 | + 'version' => '3.0.2.0', |
|
| 351 | + 'reference' => 'c6c1022351a901512170118436c764e473f6de8c', |
|
| 352 | + 'type' => 'library', |
|
| 353 | + 'install_path' => __DIR__ . '/../sebastian/version', |
|
| 354 | + 'aliases' => array(), |
|
| 355 | + 'dev_requirement' => true, |
|
| 356 | + ), |
|
| 357 | + 'squizlabs/php_codesniffer' => array( |
|
| 358 | + 'pretty_version' => '3.7.1', |
|
| 359 | + 'version' => '3.7.1.0', |
|
| 360 | + 'reference' => '1359e176e9307e906dc3d890bcc9603ff6d90619', |
|
| 361 | + 'type' => 'library', |
|
| 362 | + 'install_path' => __DIR__ . '/../squizlabs/php_codesniffer', |
|
| 363 | + 'aliases' => array(), |
|
| 364 | + 'dev_requirement' => true, |
|
| 365 | + ), |
|
| 366 | + 'symfony/css-selector' => array( |
|
| 367 | + 'pretty_version' => 'v5.4.11', |
|
| 368 | + 'version' => '5.4.11.0', |
|
| 369 | + 'reference' => 'c1681789f059ab756001052164726ae88512ae3d', |
|
| 370 | + 'type' => 'library', |
|
| 371 | + 'install_path' => __DIR__ . '/../symfony/css-selector', |
|
| 372 | + 'aliases' => array(), |
|
| 373 | + 'dev_requirement' => false, |
|
| 374 | + ), |
|
| 375 | + 'symfony/polyfill-php80' => array( |
|
| 376 | + 'pretty_version' => 'v1.26.0', |
|
| 377 | + 'version' => '1.26.0.0', |
|
| 378 | + 'reference' => 'cfa0ae98841b9e461207c13ab093d76b0fa7bace', |
|
| 379 | + 'type' => 'library', |
|
| 380 | + 'install_path' => __DIR__ . '/../symfony/polyfill-php80', |
|
| 381 | + 'aliases' => array(), |
|
| 382 | + 'dev_requirement' => false, |
|
| 383 | + ), |
|
| 384 | + 'theseer/tokenizer' => array( |
|
| 385 | + 'pretty_version' => '1.2.1', |
|
| 386 | + 'version' => '1.2.1.0', |
|
| 387 | + 'reference' => '34a41e998c2183e22995f158c581e7b5e755ab9e', |
|
| 388 | + 'type' => 'library', |
|
| 389 | + 'install_path' => __DIR__ . '/../theseer/tokenizer', |
|
| 390 | + 'aliases' => array(), |
|
| 391 | + 'dev_requirement' => true, |
|
| 392 | + ), |
|
| 393 | + 'tijsverkoyen/css-to-inline-styles' => array( |
|
| 394 | + 'pretty_version' => '2.2.3', |
|
| 395 | + 'version' => '2.2.3.0', |
|
| 396 | + 'reference' => 'b43b05cf43c1b6d849478965062b6ef73e223bb5', |
|
| 397 | + 'type' => 'library', |
|
| 398 | + 'install_path' => __DIR__ . '/../tijsverkoyen/css-to-inline-styles', |
|
| 399 | + 'aliases' => array(), |
|
| 400 | + 'dev_requirement' => false, |
|
| 401 | + ), |
|
| 402 | + 'wp-coding-standards/wpcs' => array( |
|
| 403 | + 'pretty_version' => '2.3.0', |
|
| 404 | + 'version' => '2.3.0.0', |
|
| 405 | + 'reference' => '7da1894633f168fe244afc6de00d141f27517b62', |
|
| 406 | + 'type' => 'phpcodesniffer-standard', |
|
| 407 | + 'install_path' => __DIR__ . '/../wp-coding-standards/wpcs', |
|
| 408 | + 'aliases' => array(), |
|
| 409 | + 'dev_requirement' => true, |
|
| 410 | + ), |
|
| 411 | + 'yoast/phpunit-polyfills' => array( |
|
| 412 | + 'pretty_version' => '1.0.3', |
|
| 413 | + 'version' => '1.0.3.0', |
|
| 414 | + 'reference' => '5ea3536428944955f969bc764bbe09738e151ada', |
|
| 415 | + 'type' => 'library', |
|
| 416 | + 'install_path' => __DIR__ . '/../yoast/phpunit-polyfills', |
|
| 417 | + 'aliases' => array(), |
|
| 418 | + 'dev_requirement' => true, |
|
| 419 | + ), |
|
| 420 | + ), |
|
| 421 | 421 | ); |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | 'version' => 'dev-master', |
| 6 | 6 | 'reference' => '1b6228484125d76d73410e4081202e4e4ab8cdd2', |
| 7 | 7 | 'type' => 'wordpress-plugin', |
| 8 | - 'install_path' => __DIR__ . '/../../', |
|
| 8 | + 'install_path' => __DIR__.'/../../', |
|
| 9 | 9 | 'aliases' => array(), |
| 10 | 10 | 'dev' => true, |
| 11 | 11 | ), |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | 'version' => '1.4.1.0', |
| 16 | 16 | 'reference' => '10dcfce151b967d20fde1b34ae6640712c3891bc', |
| 17 | 17 | 'type' => 'library', |
| 18 | - 'install_path' => __DIR__ . '/../doctrine/instantiator', |
|
| 18 | + 'install_path' => __DIR__.'/../doctrine/instantiator', |
|
| 19 | 19 | 'aliases' => array(), |
| 20 | 20 | 'dev_requirement' => true, |
| 21 | 21 | ), |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | 'version' => '2.0.1.0', |
| 25 | 25 | 'reference' => 'c5310df0e22c758c85ea5288175fc6cd777bc085', |
| 26 | 26 | 'type' => 'library', |
| 27 | - 'install_path' => __DIR__ . '/../dompdf/dompdf', |
|
| 27 | + 'install_path' => __DIR__.'/../dompdf/dompdf', |
|
| 28 | 28 | 'aliases' => array(), |
| 29 | 29 | 'dev_requirement' => false, |
| 30 | 30 | ), |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | 'version' => 'dev-master', |
| 34 | 34 | 'reference' => 'f7bd4b8a0566f00342cd952c66b28077fcd3d260', |
| 35 | 35 | 'type' => 'phpcodesniffer-standard', |
| 36 | - 'install_path' => __DIR__ . '/../eventespresso/ee-coding-standards', |
|
| 36 | + 'install_path' => __DIR__.'/../eventespresso/ee-coding-standards', |
|
| 37 | 37 | 'aliases' => array( |
| 38 | 38 | 0 => '9999999-dev', |
| 39 | 39 | ), |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | 'version' => 'dev-master', |
| 45 | 45 | 'reference' => '1b6228484125d76d73410e4081202e4e4ab8cdd2', |
| 46 | 46 | 'type' => 'wordpress-plugin', |
| 47 | - 'install_path' => __DIR__ . '/../../', |
|
| 47 | + 'install_path' => __DIR__.'/../../', |
|
| 48 | 48 | 'aliases' => array(), |
| 49 | 49 | 'dev_requirement' => false, |
| 50 | 50 | ), |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | 'version' => '2.7.6.0', |
| 54 | 54 | 'reference' => '897eb517a343a2281f11bc5556d6548db7d93947', |
| 55 | 55 | 'type' => 'library', |
| 56 | - 'install_path' => __DIR__ . '/../masterminds/html5', |
|
| 56 | + 'install_path' => __DIR__.'/../masterminds/html5', |
|
| 57 | 57 | 'aliases' => array(), |
| 58 | 58 | 'dev_requirement' => false, |
| 59 | 59 | ), |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | 'version' => '1.11.0.0', |
| 63 | 63 | 'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614', |
| 64 | 64 | 'type' => 'library', |
| 65 | - 'install_path' => __DIR__ . '/../myclabs/deep-copy', |
|
| 65 | + 'install_path' => __DIR__.'/../myclabs/deep-copy', |
|
| 66 | 66 | 'aliases' => array(), |
| 67 | 67 | 'dev_requirement' => true, |
| 68 | 68 | ), |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | 'version' => '4.15.1.0', |
| 72 | 72 | 'reference' => '0ef6c55a3f47f89d7a374e6f835197a0b5fcf900', |
| 73 | 73 | 'type' => 'library', |
| 74 | - 'install_path' => __DIR__ . '/../nikic/php-parser', |
|
| 74 | + 'install_path' => __DIR__.'/../nikic/php-parser', |
|
| 75 | 75 | 'aliases' => array(), |
| 76 | 76 | 'dev_requirement' => true, |
| 77 | 77 | ), |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | 'version' => '2.0.3.0', |
| 81 | 81 | 'reference' => '97803eca37d319dfa7826cc2437fc020857acb53', |
| 82 | 82 | 'type' => 'library', |
| 83 | - 'install_path' => __DIR__ . '/../phar-io/manifest', |
|
| 83 | + 'install_path' => __DIR__.'/../phar-io/manifest', |
|
| 84 | 84 | 'aliases' => array(), |
| 85 | 85 | 'dev_requirement' => true, |
| 86 | 86 | ), |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | 'version' => '3.2.1.0', |
| 90 | 90 | 'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74', |
| 91 | 91 | 'type' => 'library', |
| 92 | - 'install_path' => __DIR__ . '/../phar-io/version', |
|
| 92 | + 'install_path' => __DIR__.'/../phar-io/version', |
|
| 93 | 93 | 'aliases' => array(), |
| 94 | 94 | 'dev_requirement' => true, |
| 95 | 95 | ), |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | 'version' => '0.5.4.0', |
| 99 | 99 | 'reference' => 'dd448ad1ce34c63d09baccd05415e361300c35b4', |
| 100 | 100 | 'type' => 'library', |
| 101 | - 'install_path' => __DIR__ . '/../phenx/php-font-lib', |
|
| 101 | + 'install_path' => __DIR__.'/../phenx/php-font-lib', |
|
| 102 | 102 | 'aliases' => array(), |
| 103 | 103 | 'dev_requirement' => false, |
| 104 | 104 | ), |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | 'version' => '0.5.0.0', |
| 108 | 108 | 'reference' => '76876c6cf3080bcb6f249d7d59705108166a6685', |
| 109 | 109 | 'type' => 'library', |
| 110 | - 'install_path' => __DIR__ . '/../phenx/php-svg-lib', |
|
| 110 | + 'install_path' => __DIR__.'/../phenx/php-svg-lib', |
|
| 111 | 111 | 'aliases' => array(), |
| 112 | 112 | 'dev_requirement' => false, |
| 113 | 113 | ), |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | 'version' => '9.3.5.0', |
| 117 | 117 | 'reference' => '9fb324479acf6f39452e0655d2429cc0d3914243', |
| 118 | 118 | 'type' => 'phpcodesniffer-standard', |
| 119 | - 'install_path' => __DIR__ . '/../phpcompatibility/php-compatibility', |
|
| 119 | + 'install_path' => __DIR__.'/../phpcompatibility/php-compatibility', |
|
| 120 | 120 | 'aliases' => array(), |
| 121 | 121 | 'dev_requirement' => true, |
| 122 | 122 | ), |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | 'version' => '1.3.2.0', |
| 126 | 126 | 'reference' => 'bba5a9dfec7fcfbd679cfaf611d86b4d3759da26', |
| 127 | 127 | 'type' => 'phpcodesniffer-standard', |
| 128 | - 'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-paragonie', |
|
| 128 | + 'install_path' => __DIR__.'/../phpcompatibility/phpcompatibility-paragonie', |
|
| 129 | 129 | 'aliases' => array(), |
| 130 | 130 | 'dev_requirement' => true, |
| 131 | 131 | ), |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | 'version' => '2.1.4.0', |
| 135 | 135 | 'reference' => 'b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5', |
| 136 | 136 | 'type' => 'phpcodesniffer-standard', |
| 137 | - 'install_path' => __DIR__ . '/../phpcompatibility/phpcompatibility-wp', |
|
| 137 | + 'install_path' => __DIR__.'/../phpcompatibility/phpcompatibility-wp', |
|
| 138 | 138 | 'aliases' => array(), |
| 139 | 139 | 'dev_requirement' => true, |
| 140 | 140 | ), |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | 'version' => '9.2.18.0', |
| 144 | 144 | 'reference' => '12fddc491826940cf9b7e88ad9664cf51f0f6d0a', |
| 145 | 145 | 'type' => 'library', |
| 146 | - 'install_path' => __DIR__ . '/../phpunit/php-code-coverage', |
|
| 146 | + 'install_path' => __DIR__.'/../phpunit/php-code-coverage', |
|
| 147 | 147 | 'aliases' => array(), |
| 148 | 148 | 'dev_requirement' => true, |
| 149 | 149 | ), |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | 'version' => '3.0.6.0', |
| 153 | 153 | 'reference' => 'cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf', |
| 154 | 154 | 'type' => 'library', |
| 155 | - 'install_path' => __DIR__ . '/../phpunit/php-file-iterator', |
|
| 155 | + 'install_path' => __DIR__.'/../phpunit/php-file-iterator', |
|
| 156 | 156 | 'aliases' => array(), |
| 157 | 157 | 'dev_requirement' => true, |
| 158 | 158 | ), |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | 'version' => '3.1.1.0', |
| 162 | 162 | 'reference' => '5a10147d0aaf65b58940a0b72f71c9ac0423cc67', |
| 163 | 163 | 'type' => 'library', |
| 164 | - 'install_path' => __DIR__ . '/../phpunit/php-invoker', |
|
| 164 | + 'install_path' => __DIR__.'/../phpunit/php-invoker', |
|
| 165 | 165 | 'aliases' => array(), |
| 166 | 166 | 'dev_requirement' => true, |
| 167 | 167 | ), |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | 'version' => '2.0.4.0', |
| 171 | 171 | 'reference' => '5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28', |
| 172 | 172 | 'type' => 'library', |
| 173 | - 'install_path' => __DIR__ . '/../phpunit/php-text-template', |
|
| 173 | + 'install_path' => __DIR__.'/../phpunit/php-text-template', |
|
| 174 | 174 | 'aliases' => array(), |
| 175 | 175 | 'dev_requirement' => true, |
| 176 | 176 | ), |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | 'version' => '5.0.3.0', |
| 180 | 180 | 'reference' => '5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2', |
| 181 | 181 | 'type' => 'library', |
| 182 | - 'install_path' => __DIR__ . '/../phpunit/php-timer', |
|
| 182 | + 'install_path' => __DIR__.'/../phpunit/php-timer', |
|
| 183 | 183 | 'aliases' => array(), |
| 184 | 184 | 'dev_requirement' => true, |
| 185 | 185 | ), |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | 'version' => '9.5.25.0', |
| 189 | 189 | 'reference' => '3e6f90ca7e3d02025b1d147bd8d4a89fd4ca8a1d', |
| 190 | 190 | 'type' => 'library', |
| 191 | - 'install_path' => __DIR__ . '/../phpunit/phpunit', |
|
| 191 | + 'install_path' => __DIR__.'/../phpunit/phpunit', |
|
| 192 | 192 | 'aliases' => array(), |
| 193 | 193 | 'dev_requirement' => true, |
| 194 | 194 | ), |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | 'version' => '8.4.0.0', |
| 207 | 207 | 'reference' => 'e41d2140031d533348b2192a83f02d8dd8a71d30', |
| 208 | 208 | 'type' => 'library', |
| 209 | - 'install_path' => __DIR__ . '/../sabberworm/php-css-parser', |
|
| 209 | + 'install_path' => __DIR__.'/../sabberworm/php-css-parser', |
|
| 210 | 210 | 'aliases' => array(), |
| 211 | 211 | 'dev_requirement' => false, |
| 212 | 212 | ), |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | 'version' => '1.0.1.0', |
| 216 | 216 | 'reference' => '442e7c7e687e42adc03470c7b668bc4b2402c0b2', |
| 217 | 217 | 'type' => 'library', |
| 218 | - 'install_path' => __DIR__ . '/../sebastian/cli-parser', |
|
| 218 | + 'install_path' => __DIR__.'/../sebastian/cli-parser', |
|
| 219 | 219 | 'aliases' => array(), |
| 220 | 220 | 'dev_requirement' => true, |
| 221 | 221 | ), |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | 'version' => '1.0.8.0', |
| 225 | 225 | 'reference' => '1fc9f64c0927627ef78ba436c9b17d967e68e120', |
| 226 | 226 | 'type' => 'library', |
| 227 | - 'install_path' => __DIR__ . '/../sebastian/code-unit', |
|
| 227 | + 'install_path' => __DIR__.'/../sebastian/code-unit', |
|
| 228 | 228 | 'aliases' => array(), |
| 229 | 229 | 'dev_requirement' => true, |
| 230 | 230 | ), |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | 'version' => '2.0.3.0', |
| 234 | 234 | 'reference' => 'ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5', |
| 235 | 235 | 'type' => 'library', |
| 236 | - 'install_path' => __DIR__ . '/../sebastian/code-unit-reverse-lookup', |
|
| 236 | + 'install_path' => __DIR__.'/../sebastian/code-unit-reverse-lookup', |
|
| 237 | 237 | 'aliases' => array(), |
| 238 | 238 | 'dev_requirement' => true, |
| 239 | 239 | ), |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | 'version' => '4.0.8.0', |
| 243 | 243 | 'reference' => 'fa0f136dd2334583309d32b62544682ee972b51a', |
| 244 | 244 | 'type' => 'library', |
| 245 | - 'install_path' => __DIR__ . '/../sebastian/comparator', |
|
| 245 | + 'install_path' => __DIR__.'/../sebastian/comparator', |
|
| 246 | 246 | 'aliases' => array(), |
| 247 | 247 | 'dev_requirement' => true, |
| 248 | 248 | ), |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | 'version' => '2.0.2.0', |
| 252 | 252 | 'reference' => '739b35e53379900cc9ac327b2147867b8b6efd88', |
| 253 | 253 | 'type' => 'library', |
| 254 | - 'install_path' => __DIR__ . '/../sebastian/complexity', |
|
| 254 | + 'install_path' => __DIR__.'/../sebastian/complexity', |
|
| 255 | 255 | 'aliases' => array(), |
| 256 | 256 | 'dev_requirement' => true, |
| 257 | 257 | ), |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | 'version' => '4.0.4.0', |
| 261 | 261 | 'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d', |
| 262 | 262 | 'type' => 'library', |
| 263 | - 'install_path' => __DIR__ . '/../sebastian/diff', |
|
| 263 | + 'install_path' => __DIR__.'/../sebastian/diff', |
|
| 264 | 264 | 'aliases' => array(), |
| 265 | 265 | 'dev_requirement' => true, |
| 266 | 266 | ), |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | 'version' => '5.1.4.0', |
| 270 | 270 | 'reference' => '1b5dff7bb151a4db11d49d90e5408e4e938270f7', |
| 271 | 271 | 'type' => 'library', |
| 272 | - 'install_path' => __DIR__ . '/../sebastian/environment', |
|
| 272 | + 'install_path' => __DIR__.'/../sebastian/environment', |
|
| 273 | 273 | 'aliases' => array(), |
| 274 | 274 | 'dev_requirement' => true, |
| 275 | 275 | ), |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | 'version' => '4.0.5.0', |
| 279 | 279 | 'reference' => 'ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d', |
| 280 | 280 | 'type' => 'library', |
| 281 | - 'install_path' => __DIR__ . '/../sebastian/exporter', |
|
| 281 | + 'install_path' => __DIR__.'/../sebastian/exporter', |
|
| 282 | 282 | 'aliases' => array(), |
| 283 | 283 | 'dev_requirement' => true, |
| 284 | 284 | ), |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | 'version' => '5.0.5.0', |
| 288 | 288 | 'reference' => '0ca8db5a5fc9c8646244e629625ac486fa286bf2', |
| 289 | 289 | 'type' => 'library', |
| 290 | - 'install_path' => __DIR__ . '/../sebastian/global-state', |
|
| 290 | + 'install_path' => __DIR__.'/../sebastian/global-state', |
|
| 291 | 291 | 'aliases' => array(), |
| 292 | 292 | 'dev_requirement' => true, |
| 293 | 293 | ), |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | 'version' => '1.0.3.0', |
| 297 | 297 | 'reference' => 'c1c2e997aa3146983ed888ad08b15470a2e22ecc', |
| 298 | 298 | 'type' => 'library', |
| 299 | - 'install_path' => __DIR__ . '/../sebastian/lines-of-code', |
|
| 299 | + 'install_path' => __DIR__.'/../sebastian/lines-of-code', |
|
| 300 | 300 | 'aliases' => array(), |
| 301 | 301 | 'dev_requirement' => true, |
| 302 | 302 | ), |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | 'version' => '4.0.4.0', |
| 306 | 306 | 'reference' => '5c9eeac41b290a3712d88851518825ad78f45c71', |
| 307 | 307 | 'type' => 'library', |
| 308 | - 'install_path' => __DIR__ . '/../sebastian/object-enumerator', |
|
| 308 | + 'install_path' => __DIR__.'/../sebastian/object-enumerator', |
|
| 309 | 309 | 'aliases' => array(), |
| 310 | 310 | 'dev_requirement' => true, |
| 311 | 311 | ), |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | 'version' => '2.0.4.0', |
| 315 | 315 | 'reference' => 'b4f479ebdbf63ac605d183ece17d8d7fe49c15c7', |
| 316 | 316 | 'type' => 'library', |
| 317 | - 'install_path' => __DIR__ . '/../sebastian/object-reflector', |
|
| 317 | + 'install_path' => __DIR__.'/../sebastian/object-reflector', |
|
| 318 | 318 | 'aliases' => array(), |
| 319 | 319 | 'dev_requirement' => true, |
| 320 | 320 | ), |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | 'version' => '4.0.4.0', |
| 324 | 324 | 'reference' => 'cd9d8cf3c5804de4341c283ed787f099f5506172', |
| 325 | 325 | 'type' => 'library', |
| 326 | - 'install_path' => __DIR__ . '/../sebastian/recursion-context', |
|
| 326 | + 'install_path' => __DIR__.'/../sebastian/recursion-context', |
|
| 327 | 327 | 'aliases' => array(), |
| 328 | 328 | 'dev_requirement' => true, |
| 329 | 329 | ), |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | 'version' => '3.0.3.0', |
| 333 | 333 | 'reference' => '0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8', |
| 334 | 334 | 'type' => 'library', |
| 335 | - 'install_path' => __DIR__ . '/../sebastian/resource-operations', |
|
| 335 | + 'install_path' => __DIR__.'/../sebastian/resource-operations', |
|
| 336 | 336 | 'aliases' => array(), |
| 337 | 337 | 'dev_requirement' => true, |
| 338 | 338 | ), |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | 'version' => '3.2.0.0', |
| 342 | 342 | 'reference' => 'fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e', |
| 343 | 343 | 'type' => 'library', |
| 344 | - 'install_path' => __DIR__ . '/../sebastian/type', |
|
| 344 | + 'install_path' => __DIR__.'/../sebastian/type', |
|
| 345 | 345 | 'aliases' => array(), |
| 346 | 346 | 'dev_requirement' => true, |
| 347 | 347 | ), |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | 'version' => '3.0.2.0', |
| 351 | 351 | 'reference' => 'c6c1022351a901512170118436c764e473f6de8c', |
| 352 | 352 | 'type' => 'library', |
| 353 | - 'install_path' => __DIR__ . '/../sebastian/version', |
|
| 353 | + 'install_path' => __DIR__.'/../sebastian/version', |
|
| 354 | 354 | 'aliases' => array(), |
| 355 | 355 | 'dev_requirement' => true, |
| 356 | 356 | ), |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | 'version' => '3.7.1.0', |
| 360 | 360 | 'reference' => '1359e176e9307e906dc3d890bcc9603ff6d90619', |
| 361 | 361 | 'type' => 'library', |
| 362 | - 'install_path' => __DIR__ . '/../squizlabs/php_codesniffer', |
|
| 362 | + 'install_path' => __DIR__.'/../squizlabs/php_codesniffer', |
|
| 363 | 363 | 'aliases' => array(), |
| 364 | 364 | 'dev_requirement' => true, |
| 365 | 365 | ), |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | 'version' => '5.4.11.0', |
| 369 | 369 | 'reference' => 'c1681789f059ab756001052164726ae88512ae3d', |
| 370 | 370 | 'type' => 'library', |
| 371 | - 'install_path' => __DIR__ . '/../symfony/css-selector', |
|
| 371 | + 'install_path' => __DIR__.'/../symfony/css-selector', |
|
| 372 | 372 | 'aliases' => array(), |
| 373 | 373 | 'dev_requirement' => false, |
| 374 | 374 | ), |
@@ -377,7 +377,7 @@ discard block |
||
| 377 | 377 | 'version' => '1.26.0.0', |
| 378 | 378 | 'reference' => 'cfa0ae98841b9e461207c13ab093d76b0fa7bace', |
| 379 | 379 | 'type' => 'library', |
| 380 | - 'install_path' => __DIR__ . '/../symfony/polyfill-php80', |
|
| 380 | + 'install_path' => __DIR__.'/../symfony/polyfill-php80', |
|
| 381 | 381 | 'aliases' => array(), |
| 382 | 382 | 'dev_requirement' => false, |
| 383 | 383 | ), |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | 'version' => '1.2.1.0', |
| 387 | 387 | 'reference' => '34a41e998c2183e22995f158c581e7b5e755ab9e', |
| 388 | 388 | 'type' => 'library', |
| 389 | - 'install_path' => __DIR__ . '/../theseer/tokenizer', |
|
| 389 | + 'install_path' => __DIR__.'/../theseer/tokenizer', |
|
| 390 | 390 | 'aliases' => array(), |
| 391 | 391 | 'dev_requirement' => true, |
| 392 | 392 | ), |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | 'version' => '2.2.3.0', |
| 396 | 396 | 'reference' => 'b43b05cf43c1b6d849478965062b6ef73e223bb5', |
| 397 | 397 | 'type' => 'library', |
| 398 | - 'install_path' => __DIR__ . '/../tijsverkoyen/css-to-inline-styles', |
|
| 398 | + 'install_path' => __DIR__.'/../tijsverkoyen/css-to-inline-styles', |
|
| 399 | 399 | 'aliases' => array(), |
| 400 | 400 | 'dev_requirement' => false, |
| 401 | 401 | ), |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | 'version' => '2.3.0.0', |
| 405 | 405 | 'reference' => '7da1894633f168fe244afc6de00d141f27517b62', |
| 406 | 406 | 'type' => 'phpcodesniffer-standard', |
| 407 | - 'install_path' => __DIR__ . '/../wp-coding-standards/wpcs', |
|
| 407 | + 'install_path' => __DIR__.'/../wp-coding-standards/wpcs', |
|
| 408 | 408 | 'aliases' => array(), |
| 409 | 409 | 'dev_requirement' => true, |
| 410 | 410 | ), |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | 'version' => '1.0.3.0', |
| 414 | 414 | 'reference' => '5ea3536428944955f969bc764bbe09738e151ada', |
| 415 | 415 | 'type' => 'library', |
| 416 | - 'install_path' => __DIR__ . '/../yoast/phpunit-polyfills', |
|
| 416 | + 'install_path' => __DIR__.'/../yoast/phpunit-polyfills', |
|
| 417 | 417 | 'aliases' => array(), |
| 418 | 418 | 'dev_requirement' => true, |
| 419 | 419 | ), |
@@ -4,40 +4,40 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | class ComposerAutoloaderInit26d66831fb8dc3cdcaf1413625b832dc |
| 6 | 6 | { |
| 7 | - private static $loader; |
|
| 8 | - |
|
| 9 | - public static function loadClassLoader($class) |
|
| 10 | - { |
|
| 11 | - if ('Composer\Autoload\ClassLoader' === $class) { |
|
| 12 | - require __DIR__ . '/ClassLoader.php'; |
|
| 13 | - } |
|
| 14 | - } |
|
| 15 | - |
|
| 16 | - /** |
|
| 17 | - * @return \Composer\Autoload\ClassLoader |
|
| 18 | - */ |
|
| 19 | - public static function getLoader() |
|
| 20 | - { |
|
| 21 | - if (null !== self::$loader) { |
|
| 22 | - return self::$loader; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - spl_autoload_register(array('ComposerAutoloaderInit26d66831fb8dc3cdcaf1413625b832dc', 'loadClassLoader'), true, true); |
|
| 26 | - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); |
|
| 27 | - spl_autoload_unregister(array('ComposerAutoloaderInit26d66831fb8dc3cdcaf1413625b832dc', 'loadClassLoader')); |
|
| 28 | - |
|
| 29 | - require __DIR__ . '/autoload_static.php'; |
|
| 30 | - call_user_func(\Composer\Autoload\ComposerStaticInit26d66831fb8dc3cdcaf1413625b832dc::getInitializer($loader)); |
|
| 31 | - |
|
| 32 | - $loader->register(true); |
|
| 33 | - |
|
| 34 | - $includeFiles = \Composer\Autoload\ComposerStaticInit26d66831fb8dc3cdcaf1413625b832dc::$files; |
|
| 35 | - foreach ($includeFiles as $fileIdentifier => $file) { |
|
| 36 | - composerRequire26d66831fb8dc3cdcaf1413625b832dc($fileIdentifier, $file); |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - return $loader; |
|
| 40 | - } |
|
| 7 | + private static $loader; |
|
| 8 | + |
|
| 9 | + public static function loadClassLoader($class) |
|
| 10 | + { |
|
| 11 | + if ('Composer\Autoload\ClassLoader' === $class) { |
|
| 12 | + require __DIR__ . '/ClassLoader.php'; |
|
| 13 | + } |
|
| 14 | + } |
|
| 15 | + |
|
| 16 | + /** |
|
| 17 | + * @return \Composer\Autoload\ClassLoader |
|
| 18 | + */ |
|
| 19 | + public static function getLoader() |
|
| 20 | + { |
|
| 21 | + if (null !== self::$loader) { |
|
| 22 | + return self::$loader; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + spl_autoload_register(array('ComposerAutoloaderInit26d66831fb8dc3cdcaf1413625b832dc', 'loadClassLoader'), true, true); |
|
| 26 | + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); |
|
| 27 | + spl_autoload_unregister(array('ComposerAutoloaderInit26d66831fb8dc3cdcaf1413625b832dc', 'loadClassLoader')); |
|
| 28 | + |
|
| 29 | + require __DIR__ . '/autoload_static.php'; |
|
| 30 | + call_user_func(\Composer\Autoload\ComposerStaticInit26d66831fb8dc3cdcaf1413625b832dc::getInitializer($loader)); |
|
| 31 | + |
|
| 32 | + $loader->register(true); |
|
| 33 | + |
|
| 34 | + $includeFiles = \Composer\Autoload\ComposerStaticInit26d66831fb8dc3cdcaf1413625b832dc::$files; |
|
| 35 | + foreach ($includeFiles as $fileIdentifier => $file) { |
|
| 36 | + composerRequire26d66831fb8dc3cdcaf1413625b832dc($fileIdentifier, $file); |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + return $loader; |
|
| 40 | + } |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -47,9 +47,9 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | function composerRequire26d66831fb8dc3cdcaf1413625b832dc($fileIdentifier, $file) |
| 49 | 49 | { |
| 50 | - if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { |
|
| 51 | - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; |
|
| 50 | + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { |
|
| 51 | + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; |
|
| 52 | 52 | |
| 53 | - require $file; |
|
| 54 | - } |
|
| 53 | + require $file; |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | public static function loadClassLoader($class) |
| 10 | 10 | { |
| 11 | 11 | if ('Composer\Autoload\ClassLoader' === $class) { |
| 12 | - require __DIR__ . '/ClassLoader.php'; |
|
| 12 | + require __DIR__.'/ClassLoader.php'; |
|
| 13 | 13 | } |
| 14 | 14 | } |
| 15 | 15 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); |
| 27 | 27 | spl_autoload_unregister(array('ComposerAutoloaderInit26d66831fb8dc3cdcaf1413625b832dc', 'loadClassLoader')); |
| 28 | 28 | |
| 29 | - require __DIR__ . '/autoload_static.php'; |
|
| 29 | + require __DIR__.'/autoload_static.php'; |
|
| 30 | 30 | call_user_func(\Composer\Autoload\ComposerStaticInit26d66831fb8dc3cdcaf1413625b832dc::getInitializer($loader)); |
| 31 | 31 | |
| 32 | 32 | $loader->register(true); |