1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Paraunit\Parser; |
4
|
|
|
|
5
|
|
|
use Paraunit\Lifecycle\ProcessEvent; |
6
|
|
|
use Paraunit\Process\AbstractParaunitProcess; |
7
|
|
|
use Paraunit\TestResult\Interfaces\TestResultContainerInterface; |
8
|
|
|
use Paraunit\TestResult\Interfaces\TestResultHandlerInterface; |
9
|
|
|
use Paraunit\TestResult\TestResultWithMessage; |
10
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
11
|
|
|
|
12
|
|
|
class DeprecationParser implements EventSubscriberInterface |
13
|
|
|
{ |
14
|
|
|
/** @var TestResultHandlerInterface */ |
15
|
|
|
private $testResultContainer; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* DeprecationParser constructor. |
19
|
|
|
* @param TestResultContainerInterface $testResultContainer |
20
|
|
|
*/ |
21
|
29 |
|
public function __construct(TestResultContainerInterface $testResultContainer) |
22
|
|
|
{ |
23
|
29 |
|
$this->testResultContainer = $testResultContainer; |
|
|
|
|
24
|
|
|
} |
25
|
|
|
|
26
|
59 |
|
public static function getSubscribedEvents(): array |
27
|
|
|
{ |
28
|
|
|
return [ |
29
|
59 |
|
ProcessEvent::PROCESS_PARSING_COMPLETED => 'handleDeprecations', |
30
|
|
|
]; |
31
|
|
|
} |
32
|
|
|
|
33
|
29 |
|
public function handleDeprecations(ProcessEvent $event) |
34
|
|
|
{ |
35
|
29 |
|
$process = $event->getProcess(); |
36
|
|
|
|
37
|
29 |
|
if ($process->getExitCode() === 0) { |
38
|
19 |
|
return; |
39
|
|
|
} |
40
|
|
|
|
41
|
12 |
|
if (strpos($process->getOutput(), 'deprecation') !== false) { |
42
|
3 |
|
$testResult = $this->createTestResult($process); |
43
|
3 |
|
$this->testResultContainer->handleTestResult($process, $testResult); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
47
|
3 |
|
private function createTestResult(AbstractParaunitProcess $process): TestResultWithMessage |
48
|
|
|
{ |
49
|
3 |
|
return new TestResultWithMessage( |
50
|
3 |
|
$process->getTestClassName() ?? $process->getFilename(), |
51
|
3 |
|
$process->getOutput() |
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
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..