doyolabs /
behat-code-coverage
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of the doyo/behat-coverage-extension project. |
||
| 5 | * |
||
| 6 | * (c) Anthonius Munthi <[email protected]> |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view the LICENSE |
||
| 9 | * file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | declare(strict_types=1); |
||
| 13 | |||
| 14 | namespace Doyo\Behat\Coverage\Bridge\CodeCoverage; |
||
| 15 | |||
| 16 | use SebastianBergmann\CodeCoverage\CodeCoverage; |
||
| 17 | use SebastianBergmann\CodeCoverage\Driver\Driver; |
||
| 18 | use SebastianBergmann\CodeCoverage\Filter; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Provide bridge to PHP Code Coverage. |
||
| 22 | * |
||
| 23 | * @method append(array $data, $id = null, $append = true, $linesToBeCovered = [], array $linesToBeUsed = [], $ignoreForceCoversAnnotation = false) |
||
| 24 | * @method setAddUncoveredFilesFromWhitelist(bool $flag) |
||
| 25 | * @method clear() |
||
| 26 | * @method array getTests() |
||
| 27 | * @method Driver getDriver() |
||
| 28 | * @method Filter filter() |
||
| 29 | * @method array stop(bool $append = true, $linesToBeCovered = [], array $linesToBeUsed = [], bool $ignoreForceCoversAnnotation = false) |
||
| 30 | */ |
||
| 31 | class Processor |
||
| 32 | { |
||
| 33 | /** |
||
| 34 | * @var CodeCoverage |
||
| 35 | */ |
||
| 36 | private $codeCoverage; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var TestCase[] |
||
| 40 | */ |
||
| 41 | private $testCases; |
||
| 42 | |||
| 43 | private $completed = false; |
||
| 44 | |||
| 45 | 18 | public function __construct($driver = null, $filter = null) |
|
| 46 | { |
||
| 47 | 18 | $codeCoverage = new CodeCoverage($driver, $filter); |
|
| 48 | 18 | $this->codeCoverage = $codeCoverage; |
|
| 49 | } |
||
| 50 | |||
| 51 | public function setCodeCoverage(self $codeCoverage) |
||
| 52 | { |
||
| 53 | $this->codeCoverage = $codeCoverage; |
||
|
0 ignored issues
–
show
|
|||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return CodeCoverage |
||
| 58 | */ |
||
| 59 | 2 | public function getCodeCoverage() |
|
| 60 | { |
||
| 61 | 2 | return $this->codeCoverage; |
|
| 62 | } |
||
| 63 | |||
| 64 | 2 | public function addTestCase(TestCase $testCase) |
|
| 65 | { |
||
| 66 | 2 | $this->testCases[$testCase->getName()] = $testCase; |
|
| 67 | } |
||
| 68 | |||
| 69 | 2 | public function complete() |
|
| 70 | { |
||
| 71 | 2 | $coverage = $this->codeCoverage; |
|
| 72 | 2 | $testCases = $this->testCases; |
|
| 73 | 2 | $tests = $coverage->getTests(); |
|
| 74 | |||
| 75 | 2 | foreach ($testCases as $testCase) { |
|
| 76 | 2 | $name = $testCase->getName(); |
|
| 77 | 2 | $tests[$name]['status'] = $testCase->getResult(); |
|
| 78 | } |
||
| 79 | |||
| 80 | 2 | $coverage->setTests($tests); |
|
| 81 | 2 | $this->completed = true; |
|
| 82 | } |
||
| 83 | |||
| 84 | 3 | public function start(TestCase $testCase, $clear = false) |
|
| 85 | { |
||
| 86 | 3 | $this->codeCoverage->start($testCase->getName(), $clear); |
|
| 87 | } |
||
| 88 | |||
| 89 | 4 | public function __call($name, $arguments) |
|
| 90 | { |
||
| 91 | 4 | $codeCoverage = $this->codeCoverage; |
|
| 92 | 4 | if (method_exists($codeCoverage, $name)) { |
|
| 93 | 4 | return \call_user_func_array([$codeCoverage, $name], $arguments); |
|
| 94 | } |
||
| 95 | throw new \RuntimeException('Method name: '.$name.' not supported.'); |
||
| 96 | } |
||
| 97 | } |
||
| 98 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..