|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace whm\Smoke\Extensions\SmokeReporter; |
|
4
|
|
|
|
|
5
|
|
|
use PhmLabs\Components\Init\Init; |
|
6
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
7
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
8
|
|
|
use whm\Smoke\Config\Configuration; |
|
9
|
|
|
use whm\Smoke\Extensions\SmokeReporter\Reporter\ExceptionAwareReporter; |
|
10
|
|
|
use whm\Smoke\Extensions\SmokeReporter\Reporter\Reporter; |
|
11
|
|
|
use whm\Smoke\Extensions\SmokeResponseRetriever\Retriever\Retriever; |
|
12
|
|
|
use whm\Smoke\Rules\CheckResult; |
|
13
|
|
|
|
|
14
|
|
|
class ReporterExtension |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @var Reporter[] |
|
18
|
|
|
*/ |
|
19
|
|
|
private $reporters = array(); |
|
20
|
|
|
private $output; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var Configuration |
|
24
|
|
|
*/ |
|
25
|
|
|
private $config; |
|
26
|
|
|
|
|
27
|
|
|
public function init(OutputInterface $_output, Configuration $_configuration) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->output = $_output; |
|
30
|
|
|
$this->config = $_configuration; |
|
31
|
|
|
|
|
32
|
|
|
if ($_configuration->hasSection('reporter')) { |
|
33
|
|
|
$this->reporters = Init::initializeAll($_configuration->getSection('reporter')); |
|
|
|
|
|
|
34
|
|
|
} |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @Event("Scanner.Init.ResponseRetriever") |
|
39
|
|
|
*/ |
|
40
|
|
|
public function getResponseRetriever(Retriever $responseRetriever) |
|
41
|
|
|
{ |
|
42
|
|
|
foreach ($this->reporters as $reporter) { |
|
43
|
|
|
if (method_exists($reporter, 'setResponseRetriever')) { |
|
44
|
|
|
$reporter->setResponseRetriever($responseRetriever); |
|
|
|
|
|
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var CheckResult[] |
|
51
|
|
|
* |
|
52
|
|
|
* @Event("Scanner.Scan.Validate") |
|
53
|
|
|
*/ |
|
54
|
|
|
public function process($results, ResponseInterface $response) |
|
55
|
|
|
{ |
|
56
|
|
|
foreach ($this->reporters as $reporter) { |
|
57
|
|
|
$reporter->processResults($results, $response); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @Event("Scanner.Scan.Finish") |
|
63
|
|
|
*/ |
|
64
|
|
|
public function finish() |
|
65
|
|
|
{ |
|
66
|
|
|
foreach ($this->reporters as $reporter) { |
|
67
|
|
|
$reporter->finish(); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @Event("Scanner.Scan.Exceptions.Handle") |
|
73
|
|
|
*/ |
|
74
|
|
|
public function handleExceptions($occuredExceptions) |
|
75
|
|
|
{ |
|
76
|
|
|
foreach ($this->reporters as $reporter) { |
|
77
|
|
|
if ($reporter instanceof ExceptionAwareReporter) { |
|
78
|
|
|
$reporter->handleExceptions($occuredExceptions); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
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..