Skip to content

Commit c4d39c9

Browse files
committed
issue-bot - support more options
1 parent ed784db commit c4d39c9

File tree

3 files changed

+44
-7
lines changed

3 files changed

+44
-7
lines changed

issue-bot/src/Console/RunCommand.php

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,35 @@ private function analyseHash(LoopInterface $loop, OutputInterface $output, int $
181181
}
182182
$tmpDir = sys_get_temp_dir() . '/phpstan-issue-bot-' . $result->getHash();
183183
@mkdir($tmpDir, 0777, true);
184+
185+
$options = $result->getOptions();
186+
$parameters = [
187+
'level' => $result->getLevel(),
188+
'inferPrivatePropertyTypeFromConstructor' => $options['inferPrivatePropertyTypeFromConstructor'] ?? true,
189+
'treatPhpDocTypesAsCertain' => $result->isTreatPhpDocTypesAsCertain(),
190+
'phpVersion' => $phpVersion,
191+
'tmpDir' => $tmpDir,
192+
'rememberPossiblyImpureFunctionValues' => $options['rememberPossiblyImpureFunctionValues'] ?? true,
193+
'checkBenevolentUnionTypes' => $options['checkBenevolentUnionTypes'] ?? false,
194+
'checkTooWideReturnTypesInProtectedAndPublicMethods' => $options['checkTooWideTypesInProtectedAndPublicMethods'] ?? false,
195+
'checkTooWideParameterOutInProtectedAndPublicMethods' => $options['checkTooWideTypesInProtectedAndPublicMethods'] ?? false,
196+
'checkTooWideThrowTypesInProtectedAndPublicMethods' => $options['checkTooWideTypesInProtectedAndPublicMethods'] ?? false,
197+
];
198+
$parameters['exceptions'] = [
199+
'implicitThrows' => $options['implicitThrows'] ?? true,
200+
'reportUncheckedExceptionDeadCatch' => $options['reportUncheckedExceptionDeadCatch'] ?? false,
201+
'uncheckedExceptionClasses' => $options['uncheckedExceptionClasses'] ?? [],
202+
'checkedExceptionClasses' => $options['checkedExceptionClasses'] ?? [],
203+
'check' => [
204+
'missingCheckedExceptionInThrows' => $options['missingCheckedExceptionInThrows'] ?? false,
205+
'tooWideThrowType' => $options['tooWideThrowType'] ?? false,
206+
'tooWideImplicitThrowType' => $options['tooWideImplicitThrowType'] ?? false,
207+
],
208+
];
209+
184210
$neon = Neon::encode([
185211
'includes' => $configFiles,
186-
'parameters' => [
187-
'level' => $result->getLevel(),
188-
'inferPrivatePropertyTypeFromConstructor' => true,
189-
'treatPhpDocTypesAsCertain' => $result->isTreatPhpDocTypesAsCertain(),
190-
'phpVersion' => $phpVersion,
191-
'tmpDir' => $tmpDir,
192-
],
212+
'parameters' => $parameters,
193213
]);
194214

195215
$hash = $result->getHash();

issue-bot/src/Playground/PlaygroundClient.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Nette\Utils\Json;
77
use function array_map;
88
use function array_values;
9+
use function is_array;
910
use function sprintf;
1011

1112
class PlaygroundClient
@@ -27,6 +28,11 @@ public function getResult(string $hash): PlaygroundResult
2728
$versionedErrors[(int) $phpVersion] = array_map(static fn (array $error) => new PlaygroundError($error['line'] ?? -1, $error['message'], $error['identifier'] ?? null), array_values($errors));
2829
}
2930

31+
$options = [];
32+
if (isset($json['config']['options']) && is_array($json['config']['options'])) {
33+
$options = $json['config']['options'];
34+
}
35+
3036
return new PlaygroundResult(
3137
sprintf('https://phpstan.org/r/%s', $hash),
3238
$hash,
@@ -35,6 +41,7 @@ public function getResult(string $hash): PlaygroundResult
3541
$json['config']['strictRules'],
3642
$json['config']['bleedingEdge'],
3743
$json['config']['treatPhpDocTypesAsCertain'],
44+
$options,
3845
$versionedErrors,
3946
);
4047
}

issue-bot/src/Playground/PlaygroundResult.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class PlaygroundResult
66
{
77

88
/**
9+
* @param array<string, mixed> $options
910
* @param array<int, list<PlaygroundError>> $versionedErrors
1011
*/
1112
public function __construct(
@@ -16,6 +17,7 @@ public function __construct(
1617
private bool $strictRules,
1718
private bool $bleedingEdge,
1819
private bool $treatPhpDocTypesAsCertain,
20+
private array $options,
1921
private array $versionedErrors,
2022
)
2123
{
@@ -56,6 +58,14 @@ public function isTreatPhpDocTypesAsCertain(): bool
5658
return $this->treatPhpDocTypesAsCertain;
5759
}
5860

61+
/**
62+
* @return array<string, mixed>
63+
*/
64+
public function getOptions(): array
65+
{
66+
return $this->options;
67+
}
68+
5969
/**
6070
* @return array<int, list<PlaygroundError>>
6171
*/

0 commit comments

Comments
 (0)