forked from phpstan/phpstan-src
/
InceptionResult.php
90 lines (73 loc) · 1.78 KB
/
InceptionResult.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php declare(strict_types = 1);
namespace PHPStan\Command;
use PHPStan\DependencyInjection\Container;
use PHPStan\Internal\BytesHelper;
use function sprintf;
class InceptionResult
{
/** @var callable(): (array{string[], bool}) */
private $filesCallback;
/**
* @param callable(): (array{string[], bool}) $filesCallback
* @param mixed[]|null $projectConfigArray
*/
public function __construct(
callable $filesCallback,
private Output $stdOutput,
private Output $errorOutput,
private Container $container,
private bool $isDefaultLevelUsed,
private ?string $projectConfigFile,
private ?array $projectConfigArray,
private ?string $generateBaselineFile,
)
{
$this->filesCallback = $filesCallback;
}
/**
* @return array{string[], bool}
*/
public function getFiles(): array
{
$callback = $this->filesCallback;
return $callback();
}
public function getStdOutput(): Output
{
return $this->stdOutput;
}
public function getErrorOutput(): Output
{
return $this->errorOutput;
}
public function getContainer(): Container
{
return $this->container;
}
public function isDefaultLevelUsed(): bool
{
return $this->isDefaultLevelUsed;
}
public function getProjectConfigFile(): ?string
{
return $this->projectConfigFile;
}
/**
* @return mixed[]|null
*/
public function getProjectConfigArray(): ?array
{
return $this->projectConfigArray;
}
public function getGenerateBaselineFile(): ?string
{
return $this->generateBaselineFile;
}
public function handleReturn(int $exitCode, ?int $peakMemoryUsageBytes): int
{
if ($peakMemoryUsageBytes !== null && $this->getErrorOutput()->isVerbose()) {
$this->getErrorOutput()->writeLineFormatted(sprintf('Used memory: %s', BytesHelper::bytes($peakMemoryUsageBytes)));
}
return $exitCode;
}
}