Let Phpstan Run on Samples (#3808)

* Let Phpstan Run on Samples

Phpstan currently analyzes all source and test members. We already run phpcs and php-cs-fixer on samples as well. I would expect that samples are often used as templates for code in userland; it behooves us to be at least as careful with those members as for the others which are already being analyzed.  Aside from 1300+ messages `Variable $helper might not be defined.`, which will be suppressed in phpstan.neon.dist, there are really only a few changes needed for sample members, so that part of the code base was already in good shape, and is now even better. No annotations were needed.

* Scrutinizer 2 out of 3

1 false positive, now suppressed; fix other 2.

* Remove Dead Code

* Very Minor Changes

* Add infra
This commit is contained in:
oleibman
2023-12-06 09:40:27 -08:00
committed by GitHub
parent 5bcbc7db0c
commit 29c0162e2a
48 changed files with 367 additions and 134 deletions
+6 -6
View File
@@ -18,7 +18,7 @@ if ((isset($argc)) && ($argc > 1)) {
$inputFileNames[] = __DIR__ . '/../templates/' . $argv[$i];
}
} else {
$inputFileNames = glob($inputFileNames);
$inputFileNames = glob($inputFileNames) ?: [];
}
foreach ($inputFileNames as $inputFileName) {
$inputFileNameShort = basename($inputFileName);
@@ -46,22 +46,22 @@ foreach ($inputFileNames as $inputFileName) {
} else {
natsort($chartNames);
foreach ($chartNames as $i => $chartName) {
$chart = $worksheet->getChartByName($chartName);
$chart = $worksheet->getChartByNameOrThrow($chartName);
if ($chart->getTitle() !== null) {
$caption = '"' . implode(' ', $chart->getTitle()->getCaption()) . '"';
$caption = '"' . $chart->getTitle()->getCaptionText($spreadsheet) . '"';
} else {
$caption = 'Untitled';
}
$helper->log(' ' . $chartName . ' - ' . $caption);
$helper->log(str_repeat(' ', strlen($chartName) + 3));
$groupCount = $chart->getPlotArea()->getPlotGroupCount();
$groupCount = $chart->getPlotAreaOrThrow()->getPlotGroupCount();
if ($groupCount == 1) {
$chartType = $chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotType();
$chartType = $chart->getPlotAreaOrThrow()->getPlotGroupByIndex(0)->getPlotType();
$helper->log(' ' . $chartType);
} else {
$chartTypes = [];
for ($i = 0; $i < $groupCount; ++$i) {
$chartTypes[] = $chart->getPlotArea()->getPlotGroupByIndex($i)->getPlotType();
$chartTypes[] = $chart->getPlotAreaOrThrow()->getPlotGroupByIndex($i)->getPlotType();
}
$chartTypes = array_unique($chartTypes);
if (count($chartTypes) == 1) {