Skip to content

Phpstan Level 9 - Part 2 of Many #4399

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
384 changes: 0 additions & 384 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion samples/Engineering/BESSELI.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
$formula = "BESSELI({$x}, {$n})";
$worksheet->setCellValue('A1', "=$formula");

$helper->log("$formula = " . $worksheet->getCell('A1')->getCalculatedValue());
$helper->log("$formula = " . $worksheet->getCell('A1')->getCalculatedValueString());
}
}
2 changes: 1 addition & 1 deletion samples/Engineering/BESSELJ.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
$formula = "BESSELJ({$x}, {$n})";
$worksheet->setCellValue('A1', "=$formula");

$helper->log("$formula = " . $worksheet->getCell('A1')->getCalculatedValue());
$helper->log("$formula = " . $worksheet->getCell('A1')->getCalculatedValueString());
}
}
2 changes: 1 addition & 1 deletion samples/Engineering/BESSELK.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
$formula = "BESSELK({$x}, {$n})";
$worksheet->setCellValue('A1', "=$formula");

$helper->log("$formula = " . $worksheet->getCell('A1')->getCalculatedValue());
$helper->log("$formula = " . $worksheet->getCell('A1')->getCalculatedValueString());
}
}
2 changes: 1 addition & 1 deletion samples/Engineering/BESSELY.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
$formula = "BESSELY({$x}, {$n})";
$worksheet->setCellValue('A1', "=$formula");

$helper->log("$formula = " . $worksheet->getCell('A1')->getCalculatedValue());
$helper->log("$formula = " . $worksheet->getCell('A1')->getCalculatedValueString());
}
}
14 changes: 7 additions & 7 deletions samples/Engineering/CONVERT.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,23 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(A$row): Unit of Measure Conversion Formula "
. $worksheet->getCell('D' . $row)->getValue()
. $worksheet->getCell('D' . $row)->getValueString()
. ' - '
. $worksheet->getCell('A' . $row)->getValue()
. $worksheet->getCell('A' . $row)->getValueString()
. ' '
. $worksheet->getCell('B' . $row)->getValue()
. $worksheet->getCell('B' . $row)->getValueString()
. ' is '
. $worksheet->getCell('D' . $row)->getCalculatedValue()
. $worksheet->getCell('D' . $row)->getCalculatedValueString()
. ' '
. $worksheet->getCell('C' . $row)->getValue()
. $worksheet->getCell('C' . $row)->getValueString()
);
}

$helper->log('Old method for area conversions, before MS Excel introduced area Units of Measure');

$helper->log(
"(A$row): Unit of Measure Conversion Formula "
. $worksheet->getCell('H1')->getValue()
. $worksheet->getCell('H1')->getValueString()
. ' result is '
. $worksheet->getCell('H1')->getCalculatedValue()
. $worksheet->getCell('H1')->getCalculatedValueString()
);
30 changes: 18 additions & 12 deletions samples/Engineering/Convert-Online.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use PhpOffice\PhpSpreadsheet\Calculation\Engineering\ConvertUOM;
use PhpOffice\PhpSpreadsheet\Helper\Sample;
use PhpOffice\PhpSpreadsheet\Settings;
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;

require __DIR__ . '/../Header.php';

Expand All @@ -12,9 +13,14 @@

return;
}

$post = [];
foreach (['category', 'quantity', 'fromUnit', 'toUnit'] as $value) {
if (isset($_POST[$value])) {
$post[$value] = StringHelper::convertToString($_POST[$value]);
}
}
$categories = ConvertUOM::getConversionCategories();
$defaultCategory = $_POST['category'] ?? $categories[0];
$defaultCategory = $post['category'] ?? $categories[0];
$units = [];
foreach ($categories as $category) {
$categoryUnits = ConvertUOM::getConversionCategoryUnitDetails($category)[$category];
Expand All @@ -34,23 +40,23 @@
<div class="col-sm-10">
<select name="category" class="form-select" onchange="this.form.submit()">
<?php foreach ($categories as $category) {
echo "<option value=\"{$category}\" " . ((isset($_POST['category']) && $_POST['category'] === $category) ? 'selected' : '') . ">{$category}</option>", PHP_EOL;
echo "<option value=\"{$category}\" " . ((isset($post['category']) && $post['category'] === $category) ? 'selected' : '') . ">{$category}</option>", PHP_EOL;
} ?>
</select>
</div>
</div>
<div class="mb-3 row">
<label for="quantity" class="col-sm-2 col-form-label">Quantity</label>
<div class="col-sm-10">
<input name="quantity" type="text" size="8" value="<?php echo (isset($_POST['quantity'])) ? htmlentities($_POST['quantity'], Settings::htmlEntityFlags()) : '1.0'; ?>">
<input name="quantity" type="text" size="8" value="<?php echo (isset($post['quantity'])) ? htmlentities($post['quantity'], Settings::htmlEntityFlags()) : '1.0'; ?>">
</div>
</div>
<div class="mb-3 row">
<label for="fromUnit" class="col-sm-2 col-form-label">From Unit</label>
<div class="col-sm-10">
<select name="fromUnit" class="form-select">
<?php foreach ($units[$defaultCategory] as $fromUnitCode => $fromUnitName) {
echo "<option value=\"{$fromUnitCode}\" " . ((isset($_POST['fromUnit']) && $_POST['fromUnit'] === $fromUnitCode) ? 'selected' : '') . ">{$fromUnitName}</option>", PHP_EOL;
echo "<option value=\"{$fromUnitCode}\" " . ((isset($post['fromUnit']) && $post['fromUnit'] === $fromUnitCode) ? 'selected' : '') . ">{$fromUnitName}</option>", PHP_EOL;
} ?>
</select>
</div>
Expand All @@ -60,7 +66,7 @@
<div class="col-sm-10">
<select name="toUnit" class="form-select">
<?php foreach ($units[$defaultCategory] as $toUnitCode => $toUnitName) {
echo "<option value=\"{$toUnitCode}\" " . ((isset($_POST['toUnit']) && $_POST['toUnit'] === $toUnitCode) ? 'selected' : '') . ">{$toUnitName}</option>", PHP_EOL;
echo "<option value=\"{$toUnitCode}\" " . ((isset($post['toUnit']) && $post['toUnit'] === $toUnitCode) ? 'selected' : '') . ">{$toUnitName}</option>", PHP_EOL;
} ?>
</select>
</div>
Expand All @@ -74,17 +80,17 @@

<?php
/** If the user has submitted the form, then we need to calculate the value and display the result */
if (isset($_POST['quantity'], $_POST['fromUnit'], $_POST['toUnit'])) {
$quantity = $_POST['quantity'];
$fromUnit = $_POST['fromUnit'];
$toUnit = $_POST['toUnit'];
if (isset($post['quantity'], $post['fromUnit'], $post['toUnit'])) {
$quantity = $post['quantity'];
$fromUnit = $post['fromUnit'];
$toUnit = $post['toUnit'];
if (!is_numeric($quantity)) {
$helper->log('Quantity is not numeric');
} elseif (isset($units[$_POST['category']][$fromUnit], $units[$_POST['category']][$toUnit])) {
} elseif (isset($units[$post['category']][$fromUnit], $units[$post['category']][$toUnit])) {
/** @var float|string */
$result = ConvertUOM::CONVERT($quantity, $fromUnit, $toUnit);

$helper->log("{$quantity} {$units[$_POST['category']][$fromUnit]} is {$result} {$units[$_POST['category']][$toUnit]}");
$helper->log("{$quantity} {$units[$post['category']][$fromUnit]} is {$result} {$units[$post['category']][$toUnit]}");
} else {
$helper->log('Please enter quantity and select From Unit and To Unit');
}
Expand Down
8 changes: 4 additions & 4 deletions samples/Engineering/DELTA.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(E$row): Compare values "
. $worksheet->getCell('A' . $row)->getValue()
. $worksheet->getCell('A' . $row)->getValueString()
. ' and '
. $worksheet->getCell('B' . $row)->getValue()
. $worksheet->getCell('B' . $row)->getValueString()
. ' - Result is '
. $worksheet->getCell('C' . $row)->getCalculatedValue()
. $worksheet->getCell('C' . $row)->getCalculatedValueString()
. ' - '
. $comparison[$worksheet->getCell('C' . $row)->getCalculatedValue()]
. $comparison[$worksheet->getCell('C' . $row)->getCalculatedValueString()]
);
}
14 changes: 7 additions & 7 deletions samples/Engineering/ERF.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,24 @@
for ($row = 1; $row <= $testDataCount1; ++$row) {
$helper->log(
"(C$row): "
. $worksheet->getCell('C' . $row)->getValue()
. $worksheet->getCell('C' . $row)->getValueString()
. ' The error function integrated between 0 and '
. $worksheet->getCell('A' . $row)->getValue()
. $worksheet->getCell('A' . $row)->getValueString()
. ' is '
. $worksheet->getCell('C' . $row)->getCalculatedValue()
. $worksheet->getCell('C' . $row)->getCalculatedValueString()
);
}

$helper->log('ERF() With two arguments');
for ($row = $testDataCount1 + 1; $row <= $testDataCount2 + $testDataCount1; ++$row) {
$helper->log(
"(C$row): "
. $worksheet->getCell('C' . $row)->getValue()
. $worksheet->getCell('C' . $row)->getValueString()
. ' The error function integrated between '
. $worksheet->getCell('A' . $row)->getValue()
. $worksheet->getCell('A' . $row)->getValueString()
. ' and '
. $worksheet->getCell('B' . $row)->getValue()
. $worksheet->getCell('B' . $row)->getValueString()
. ' is '
. $worksheet->getCell('C' . $row)->getCalculatedValue()
. $worksheet->getCell('C' . $row)->getCalculatedValueString()
);
}
6 changes: 3 additions & 3 deletions samples/Engineering/ERFC.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(E$row): "
. $worksheet->getCell('C' . $row)->getValue()
. $worksheet->getCell('C' . $row)->getValueString()
. ' The complementary error function integrated by '
. $worksheet->getCell('A' . $row)->getValue()
. $worksheet->getCell('A' . $row)->getValueString()
. ' and infinity is '
. $worksheet->getCell('C' . $row)->getCalculatedValue()
. $worksheet->getCell('C' . $row)->getCalculatedValueString()
);
}
4 changes: 2 additions & 2 deletions samples/HexEtcConversions/BIN2DEC.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(B$row): "
. 'Binary ' . $worksheet->getCell("A$row")->getValue()
. ' is decimal ' . $worksheet->getCell("B$row")->getCalculatedValue()
. 'Binary ' . $worksheet->getCell("A$row")->getValueString()
. ' is decimal ' . $worksheet->getCell("B$row")->getCalculatedValueString()
);
}
4 changes: 2 additions & 2 deletions samples/HexEtcConversions/BIN2HEX.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(B$row): "
. 'Binary ' . $worksheet->getCell("A$row")->getValue()
. ' is hexadecimal ' . $worksheet->getCell("B$row")->getCalculatedValue()
. 'Binary ' . $worksheet->getCell("A$row")->getValueString()
. ' is hexadecimal ' . $worksheet->getCell("B$row")->getCalculatedValueString()
);
}
4 changes: 2 additions & 2 deletions samples/HexEtcConversions/BIN2OCT.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(B$row): "
. 'Binary ' . $worksheet->getCell("A$row")->getValue()
. ' is octal ' . $worksheet->getCell("B$row")->getCalculatedValue()
. 'Binary ' . $worksheet->getCell("A$row")->getValueString()
. ' is octal ' . $worksheet->getCell("B$row")->getCalculatedValueString()
);
}
4 changes: 2 additions & 2 deletions samples/HexEtcConversions/DEC2BIN.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(B$row): "
. 'Decimal ' . $worksheet->getCell("A$row")->getValue()
. ' is binary ' . $worksheet->getCell("B$row")->getCalculatedValue()
. 'Decimal ' . $worksheet->getCell("A$row")->getValueString()
. ' is binary ' . $worksheet->getCell("B$row")->getCalculatedValueString()
);
}
4 changes: 2 additions & 2 deletions samples/HexEtcConversions/DEC2HEX.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(B$row): "
. 'Decimal ' . $worksheet->getCell("A$row")->getValue()
. ' is hexadecimal ' . $worksheet->getCell("B$row")->getCalculatedValue()
. 'Decimal ' . $worksheet->getCell("A$row")->getValueString()
. ' is hexadecimal ' . $worksheet->getCell("B$row")->getCalculatedValueString()
);
}
4 changes: 2 additions & 2 deletions samples/HexEtcConversions/DEC2OCT.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(B$row): "
. 'Decimal ' . $worksheet->getCell("A$row")->getValue()
. ' is octal ' . $worksheet->getCell("B$row")->getCalculatedValue()
. 'Decimal ' . $worksheet->getCell("A$row")->getValueString()
. ' is octal ' . $worksheet->getCell("B$row")->getCalculatedValueString()
);
}
4 changes: 2 additions & 2 deletions samples/HexEtcConversions/HEX2BIN.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(B$row): "
. 'Hexadecimal ' . $worksheet->getCell("A$row")->getValue()
. ' is binary ' . $worksheet->getCell("B$row")->getCalculatedValue()
. 'Hexadecimal ' . $worksheet->getCell("A$row")->getValueString()
. ' is binary ' . $worksheet->getCell("B$row")->getCalculatedValueString()
);
}
4 changes: 2 additions & 2 deletions samples/HexEtcConversions/HEX2DEC.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(B$row): "
. 'Hexadecimal ' . $worksheet->getCell("A$row")->getValue()
. ' is decimal ' . $worksheet->getCell("B$row")->getCalculatedValue()
. 'Hexadecimal ' . $worksheet->getCell("A$row")->getValueString()
. ' is decimal ' . $worksheet->getCell("B$row")->getCalculatedValueString()
);
}
4 changes: 2 additions & 2 deletions samples/HexEtcConversions/HEX2OCT.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(B$row): "
. 'Hexadecimal ' . $worksheet->getCell("A$row")->getValue()
. ' is octal ' . $worksheet->getCell("B$row")->getCalculatedValue()
. 'Hexadecimal ' . $worksheet->getCell("A$row")->getValueString()
. ' is octal ' . $worksheet->getCell("B$row")->getCalculatedValueString()
);
}
4 changes: 2 additions & 2 deletions samples/HexEtcConversions/OCT2BIN.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(B$row): "
. 'Octal ' . $worksheet->getCell("A$row")->getValue()
. ' is binary ' . $worksheet->getCell("B$row")->getCalculatedValue()
. 'Octal ' . $worksheet->getCell("A$row")->getValueString()
. ' is binary ' . $worksheet->getCell("B$row")->getCalculatedValueString()
);
}
4 changes: 2 additions & 2 deletions samples/HexEtcConversions/OCT2DEC.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(B$row): "
. 'Octal ' . $worksheet->getCell("A$row")->getValue()
. ' is decimal ' . $worksheet->getCell("B$row")->getCalculatedValue()
. 'Octal ' . $worksheet->getCell("A$row")->getValueString()
. ' is decimal ' . $worksheet->getCell("B$row")->getCalculatedValueString()
);
}
4 changes: 2 additions & 2 deletions samples/HexEtcConversions/OCT2HEX.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
for ($row = 1; $row <= $testDataCount; ++$row) {
$helper->log(
"(B$row): "
. 'Octal ' . $worksheet->getCell("A$row")->getValue()
. ' is hexadecimal ' . $worksheet->getCell("B$row")->getCalculatedValue()
. 'Octal ' . $worksheet->getCell("A$row")->getValueString()
. ' is hexadecimal ' . $worksheet->getCell("B$row")->getCalculatedValueString()
);
}
2 changes: 1 addition & 1 deletion samples/LookupRef/ADDRESS.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@

for ($row = 1; $row <= 5; ++$row) {
$cell = $worksheet->getCell("A{$row}");
$helper->log("A{$row}: " . $cell->getValue() . ' => ' . $cell->getCalculatedValue());
$helper->log("A{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString());
}
4 changes: 2 additions & 2 deletions samples/LookupRef/COLUMN.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

for ($row = 1; $row <= 2; ++$row) {
$cell = $worksheet->getCell("A{$row}");
$helper->log("A{$row}: " . $cell->getValue() . ' => ' . $cell->getCalculatedValue());
$helper->log("A{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString());
}

$cell = $worksheet->getCell('F1');
$helper->log('F1: ' . $cell->getValue() . ' => ' . $cell->getCalculatedValue());
$helper->log('F1: ' . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString());
2 changes: 1 addition & 1 deletion samples/LookupRef/COLUMNS.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@

for ($row = 1; $row <= 4; ++$row) {
$cell = $worksheet->getCell("A{$row}");
$helper->log("A{$row}: " . $cell->getValue() . ' => ' . $cell->getCalculatedValue());
$helper->log("A{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString());
}
2 changes: 1 addition & 1 deletion samples/LookupRef/INDEX.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@

for ($row = 11; $row <= 16; ++$row) {
$cell = $worksheet->getCell("A{$row}");
$helper->log("A{$row}: " . $cell->getValue() . ' => ' . $cell->getCalculatedValue());
$helper->log("A{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString());
}
2 changes: 1 addition & 1 deletion samples/LookupRef/INDIRECT.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@

for ($row = 1; $row <= 5; ++$row) {
$cell = $worksheet->getCell("A{$row}");
$helper->log("A{$row}: " . $cell->getValue() . ' => ' . $cell->getCalculatedValue());
$helper->log("A{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString());
}
2 changes: 1 addition & 1 deletion samples/LookupRef/OFFSET.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@

for ($row = 1; $row <= 4; ++$row) {
$cell = $worksheet->getCell("H{$row}");
$helper->log("H{$row}: " . $cell->getValue() . ' => ' . $cell->getCalculatedValue());
$helper->log("H{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString());
}
2 changes: 1 addition & 1 deletion samples/LookupRef/ROW.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@

for ($row = 1; $row <= 3; ++$row) {
$cell = $worksheet->getCell("A{$row}");
$helper->log("A{$row}: " . $cell->getValue() . ' => ' . $cell->getCalculatedValue());
$helper->log("A{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString());
}
2 changes: 1 addition & 1 deletion samples/LookupRef/ROWS.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@

for ($row = 1; $row <= 3; ++$row) {
$cell = $worksheet->getCell("A{$row}");
$helper->log("A{$row}: " . $cell->getValue() . ' => ' . $cell->getCalculatedValue());
$helper->log("A{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString());
}
2 changes: 1 addition & 1 deletion samples/LookupRef/VLOOKUP.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
for ($column = 'H'; $column !== 'K'; ++$column) {
for ($row = 4; $row <= 5; ++$row) {
$cell = $worksheet->getCell("{$column}{$row}");
$helper->log("{$column}{$row}: " . $cell->getValue() . ' => ' . $cell->getCalculatedValue());
$helper->log("{$column}{$row}: " . $cell->getValueString() . ' => ' . $cell->getCalculatedValueString());
}
}
Loading