Skip to content

Commit 0998e72

Browse files
author
MarkBaker
committed
Eliminate underscore prefix in method names... no longer needed as an indicator that a method should be internal only
1 parent 703604c commit 0998e72

File tree

228 files changed

+240
-260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+240
-260
lines changed

docs/topics/recipes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ internal English coding.
187187

188188
```php
189189
$formula = $spreadsheet->getActiveSheet()->getCell('B8')->getValue();
190-
$translatedFormula = \PhpOffice\PhpSpreadsheet\Calculation\Calculation::getInstance()->_translateFormulaToLocale($formula);
190+
$translatedFormula = \PhpOffice\PhpSpreadsheet\Calculation\Calculation::getInstance()->translateFormulaToLocale($formula);
191191
```
192192

193193
You can also create a formula using the function names and argument

phpstan-baseline.neon

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,6 @@ parameters:
5555
count: 1
5656
path: src/PhpSpreadsheet/Calculation/Calculation.php
5757

58-
-
59-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:_translateFormulaToEnglish\\(\\) has no return type specified\\.$#"
60-
count: 1
61-
path: src/PhpSpreadsheet/Calculation/Calculation.php
62-
63-
-
64-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:_translateFormulaToEnglish\\(\\) has parameter \\$formula with no type specified\\.$#"
65-
count: 1
66-
path: src/PhpSpreadsheet/Calculation/Calculation.php
67-
68-
-
69-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:_translateFormulaToLocale\\(\\) has no return type specified\\.$#"
70-
count: 1
71-
path: src/PhpSpreadsheet/Calculation/Calculation.php
72-
73-
-
74-
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:_translateFormulaToLocale\\(\\) has parameter \\$formula with no type specified\\.$#"
75-
count: 1
76-
path: src/PhpSpreadsheet/Calculation/Calculation.php
77-
7858
-
7959
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Calculation\\:\\:dataTestReference\\(\\) has no return type specified\\.$#"
8060
count: 1

src/PhpSpreadsheet/Calculation/Calculation.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class Calculation
294294
],
295295
'ARABIC' => [
296296
'category' => Category::CATEGORY_MATH_AND_TRIG,
297-
'functionCall' => [MathTrig\Arabic::class, 'evaluate'],
297+
'functionCall' => [MathTrig\Arabic::class, 'toRoman'],
298298
'argumentCount' => '1',
299299
],
300300
'AREAS' => [
@@ -2141,7 +2141,7 @@ class Calculation
21412141
],
21422142
'ROMAN' => [
21432143
'category' => Category::CATEGORY_MATH_AND_TRIG,
2144-
'functionCall' => [MathTrig\Roman::class, 'evaluate'],
2144+
'functionCall' => [MathTrig\Roman::class, 'toArabic'],
21452145
'argumentCount' => '1,2',
21462146
],
21472147
'ROUND' => [
@@ -3176,7 +3176,7 @@ private static function translateFormula(array $from, array $to, string $formula
31763176

31773177
private static $functionReplaceToLocale;
31783178

3179-
public function _translateFormulaToLocale($formula)
3179+
public function translateFormulaToLocale(string $formula): string
31803180
{
31813181
// Build list of function names and constants for translation
31823182
if (self::$functionReplaceFromExcel === null) {
@@ -3212,7 +3212,7 @@ public function _translateFormulaToLocale($formula)
32123212

32133213
private static $functionReplaceToExcel;
32143214

3215-
public function _translateFormulaToEnglish($formula)
3215+
public function translateFormulaToEnglish(string $formula): string
32163216
{
32173217
if (self::$functionReplaceFromLocale === null) {
32183218
self::$functionReplaceFromLocale = [];
@@ -3350,7 +3350,7 @@ public function calculateCellValue(?Cell $cell = null, $resetLog = true)
33503350
];
33513351

33523352
try {
3353-
$result = self::unwrapResult($this->_calculateFormulaValue($cell->getValue(), $cell->getCoordinate(), $cell));
3353+
$result = self::unwrapResult($this->calculateFormulaValue($cell->getValue(), $cell->getCoordinate(), $cell));
33543354
$cellAddress = array_pop($this->cellStack);
33553355
$this->spreadsheet->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);
33563356
} catch (\Exception $e) {
@@ -3447,7 +3447,7 @@ public function calculateFormula($formula, $cellID = null, ?Cell $cell = null)
34473447

34483448
// Execute the calculation
34493449
try {
3450-
$result = self::unwrapResult($this->_calculateFormulaValue($formula, $cellID, $cell));
3450+
$result = self::unwrapResult($this->calculateFormulaValue($formula, $cellID, $cell));
34513451
} catch (\Exception $e) {
34523452
throw new Exception($e->getMessage());
34533453
}
@@ -3500,7 +3500,7 @@ public function saveValueToCache($cellReference, $cellValue): void
35003500
*
35013501
* @return mixed
35023502
*/
3503-
public function _calculateFormulaValue($formula, $cellID = null, ?Cell $cell = null)
3503+
public function calculateFormulaValue($formula, $cellID = null, ?Cell $cell = null)
35043504
{
35053505
$cellValue = null;
35063506

@@ -5431,7 +5431,7 @@ private function evaluateDefinedName(Cell $cell, DefinedName $namedRange, Worksh
54315431
$recursiveCalculator = new self($this->spreadsheet);
54325432
$recursiveCalculator->getDebugLog()->setWriteDebugLog($this->getDebugLog()->getWriteDebugLog());
54335433
$recursiveCalculator->getDebugLog()->setEchoDebugLog($this->getDebugLog()->getEchoDebugLog());
5434-
$result = $recursiveCalculator->_calculateFormulaValue($definedNameValue, $recursiveCalculationCellAddress, $recursiveCalculationCell);
5434+
$result = $recursiveCalculator->calculateFormulaValue($definedNameValue, $recursiveCalculationCellAddress, $recursiveCalculationCell);
54355435

54365436
if ($this->getDebugLog()->getWriteDebugLog()) {
54375437
$this->debugLog->mergeDebugLog(array_slice($recursiveCalculator->getDebugLog()->getLog(), 3));

src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private static function executeQuery(array $database, string $query, array $crit
142142
}
143143

144144
// evaluate the criteria against the row data
145-
$result = Calculation::getInstance()->_calculateFormulaValue('=' . $conditions);
145+
$result = Calculation::getInstance()->calculateFormulaValue('=' . $conditions);
146146

147147
// If the row failed to meet the criteria, remove it from the database
148148
if ($result !== true) {

src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private static function strSplit(string $roman): array
7979
* If an array of numbers is passed as the argument, then the returned result will also be an array
8080
* with the same dimensions
8181
*/
82-
public static function evaluate($roman)
82+
public static function toRoman($roman)
8383
{
8484
if (is_array($roman)) {
8585
return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $roman);

src/PhpSpreadsheet/Calculation/MathTrig/Roman.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ public static function calculateRoman(int $aValue, int $style): string
825825
* If an array of numbers is passed as an argument, then the returned result will also be an array
826826
* with the same dimensions
827827
*/
828-
public static function evaluate($aValue, $style = 0)
828+
public static function toArabic($aValue, $style = 0)
829829
{
830830
if (is_array($aValue) || is_array($style)) {
831831
return self::evaluateArrayArguments([self::class, __FUNCTION__], $aValue, $style);

src/PhpSpreadsheet/Chart/DataSeriesValues.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ public function refresh(Worksheet $worksheet, $flatten = true): void
357357
if ($this->dataSource !== null) {
358358
$calcEngine = Calculation::getInstance($worksheet->getParent());
359359
$newDataValues = Calculation::unwrapResult(
360-
$calcEngine->_calculateFormulaValue(
360+
$calcEngine->calculateFormulaValue(
361361
'=' . $this->dataSource,
362362
null,
363363
$worksheet->getCell('A1')

src/PhpSpreadsheet/Shared/StringHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ public static function convertToNumberIfFraction(&$operand)
565565
if (preg_match('/^' . self::STRING_REGEXP_FRACTION . '$/i', $operand, $match)) {
566566
$sign = ($match[1] == '-') ? '-' : '+';
567567
$fractionFormula = '=' . $sign . $match[2] . $sign . $match[3];
568-
$operand = Calculation::getInstance()->_calculateFormulaValue($fractionFormula);
568+
$operand = Calculation::getInstance()->calculateFormulaValue($fractionFormula);
569569

570570
return true;
571571
}

tests/PhpSpreadsheetTests/Calculation/ArrayFormulaTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected function tearDown(): void
4040
*/
4141
public function testArrayFormula(string $formula, $expectedResult): void
4242
{
43-
$result = Calculation::getInstance()->_calculateFormulaValue($formula);
43+
$result = Calculation::getInstance()->calculateFormulaValue($formula);
4444
self::assertEquals($expectedResult, $result);
4545
}
4646

tests/PhpSpreadsheetTests/Calculation/CalculationErrorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public function testCalculationException(): void
1414
$this->expectException(CalcException::class);
1515
$this->expectExceptionMessage('Formula Error:');
1616
$calculation = Calculation::getInstance();
17-
$result = $calculation->_calculateFormulaValue('=SUM(');
17+
$result = $calculation->calculateFormulaValue('=SUM(');
1818
self::assertFalse($result);
1919
}
2020

@@ -25,7 +25,7 @@ public function testCalculationError(): void
2525
$error = false;
2626

2727
try {
28-
$calculation->_calculateFormulaValue('=SUM(');
28+
$calculation->calculateFormulaValue('=SUM(');
2929
} catch (Throwable $e) {
3030
self::assertSame("Formula Error: Expecting ')'", $e->getMessage());
3131
self::assertSame('PHPUnit\\Framework\\Error\\Error', get_class($e));
@@ -47,7 +47,7 @@ public function testCalculationErrorTrulySuppressed(): void
4747
$calculation = Calculation::getInstance();
4848
$calculation->suppressFormulaErrors = true;
4949
set_error_handler([self::class, 'errhandler2']);
50-
$result = $calculation->_calculateFormulaValue('=SUM(');
50+
$result = $calculation->calculateFormulaValue('=SUM(');
5151
restore_error_handler();
5252
self::assertFalse($result);
5353
}

0 commit comments

Comments
 (0)