@@ -3158,7 +3158,7 @@ public function setLocale(string $locale): bool
3158
3158
{
3159
3159
// Identify our locale and language
3160
3160
$ language = $ locale = strtolower ($ locale );
3161
- if (strpos ($ locale , '_ ' ) !== false ) {
3161
+ if (str_contains ($ locale , '_ ' )) {
3162
3162
[$ language ] = explode ('_ ' , $ locale );
3163
3163
}
3164
3164
if (count (self ::$ validLocaleLanguages ) == 1 ) {
@@ -3187,9 +3187,9 @@ public function setLocale(string $locale): bool
3187
3187
$ localeFunctions = file ($ functionNamesFile , FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) ?: [];
3188
3188
foreach ($ localeFunctions as $ localeFunction ) {
3189
3189
[$ localeFunction ] = explode ('## ' , $ localeFunction ); // Strip out comments
3190
- if (strpos ($ localeFunction , '= ' ) !== false ) {
3190
+ if (str_contains ($ localeFunction , '= ' )) {
3191
3191
[$ fName , $ lfName ] = array_map ('trim ' , explode ('= ' , $ localeFunction ));
3192
- if ((substr ($ fName , 0 , 1 ) === '* ' || isset (self ::$ phpSpreadsheetFunctions [$ fName ])) && ($ lfName != '' ) && ($ fName != $ lfName )) {
3192
+ if ((str_starts_with ($ fName , '* ' ) || isset (self ::$ phpSpreadsheetFunctions [$ fName ])) && ($ lfName != '' ) && ($ fName != $ lfName )) {
3193
3193
self ::$ localeFunctions [$ fName ] = $ lfName ;
3194
3194
}
3195
3195
}
@@ -3211,7 +3211,7 @@ public function setLocale(string $locale): bool
3211
3211
$ localeSettings = file ($ configFile , FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES ) ?: [];
3212
3212
foreach ($ localeSettings as $ localeSetting ) {
3213
3213
[$ localeSetting ] = explode ('## ' , $ localeSetting ); // Strip out comments
3214
- if (strpos ($ localeSetting , '= ' ) !== false ) {
3214
+ if (str_contains ($ localeSetting , '= ' )) {
3215
3215
[$ settingName , $ settingValue ] = array_map ('trim ' , explode ('= ' , $ localeSetting ));
3216
3216
$ settingName = strtoupper ($ settingName );
3217
3217
if ($ settingValue !== '' ) {
@@ -3298,7 +3298,7 @@ private static function translateFormula(array $from, array $to, string $formula
3298
3298
$ inFunctionBracesLevel = 0 ;
3299
3299
$ inMatrixBracesLevel = 0 ;
3300
3300
// If there is the possibility of separators within a quoted string, then we treat them as literals
3301
- if (strpos ($ formula , self ::FORMULA_STRING_QUOTE ) !== false ) {
3301
+ if (str_contains ($ formula , self ::FORMULA_STRING_QUOTE )) {
3302
3302
// So instead we skip replacing in any quoted strings by only replacing in every other array element
3303
3303
// after we've exploded the formula
3304
3304
$ temp = explode (self ::FORMULA_STRING_QUOTE , $ formula );
@@ -3992,9 +3992,9 @@ private function convertMatrixReferences(string $formula): false|string
3992
3992
static $ matrixReplaceTo = ['MKMATRIX(MKMATRIX( ' , '),MKMATRIX( ' , ')) ' ];
3993
3993
3994
3994
// Convert any Excel matrix references to the MKMATRIX() function
3995
- if (strpos ($ formula , self ::FORMULA_OPEN_MATRIX_BRACE ) !== false ) {
3995
+ if (str_contains ($ formula , self ::FORMULA_OPEN_MATRIX_BRACE )) {
3996
3996
// If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators
3997
- if (strpos ($ formula , self ::FORMULA_STRING_QUOTE ) !== false ) {
3997
+ if (str_contains ($ formula , self ::FORMULA_STRING_QUOTE )) {
3998
3998
// So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded
3999
3999
// the formula
4000
4000
$ temp = explode (self ::FORMULA_STRING_QUOTE , $ formula );
@@ -4354,7 +4354,7 @@ private function internalParseFormula($formula, ?Cell $cell = null): bool|array
4354
4354
return $ this ->raiseFormulaError ('3D Range references are not yet supported ' );
4355
4355
}
4356
4356
}
4357
- } elseif (strpos ($ val , '! ' ) === false && $ pCellParent !== null ) {
4357
+ } elseif (! str_contains ($ val , '! ' ) && $ pCellParent !== null ) {
4358
4358
$ worksheet = $ pCellParent ->getTitle ();
4359
4359
$ val = "' {$ worksheet }'! {$ val }" ;
4360
4360
}
@@ -4398,7 +4398,7 @@ private function internalParseFormula($formula, ?Cell $cell = null): bool|array
4398
4398
$ stackItemType = 'Defined Name ' ;
4399
4399
$ address = str_replace ('$ ' , '' , $ namedRange ->getValue ());
4400
4400
$ stackItemReference = $ val ;
4401
- if (strpos ($ address , ': ' ) !== false ) {
4401
+ if (str_contains ($ address , ': ' )) {
4402
4402
// We'll need to manipulate the stack for an actual named range rather than a named cell
4403
4403
$ fromTo = explode (': ' , $ address );
4404
4404
$ to = array_pop ($ fromTo );
@@ -4492,7 +4492,7 @@ private function internalParseFormula($formula, ?Cell $cell = null): bool|array
4492
4492
$ stackItemType = 'Defined Name ' ;
4493
4493
$ stackItemReference = $ val ;
4494
4494
} elseif (is_numeric ($ val )) {
4495
- if ((strpos ((string ) $ val , '. ' ) !== false ) || (stripos ((string ) $ val , 'e ' ) !== false ) || ($ val > PHP_INT_MAX ) || ($ val < -PHP_INT_MAX )) {
4495
+ if ((str_contains ((string ) $ val , '. ' )) || (stripos ((string ) $ val , 'e ' ) !== false ) || ($ val > PHP_INT_MAX ) || ($ val < -PHP_INT_MAX )) {
4496
4496
$ val = (float ) $ val ;
4497
4497
} else {
4498
4498
$ val = (int ) $ val ;
@@ -4706,7 +4706,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null)
4706
4706
4707
4707
try {
4708
4708
$ cellRange = $ token ->parse ($ cell );
4709
- if (strpos ($ cellRange , ': ' ) !== false ) {
4709
+ if (str_contains ($ cellRange , ': ' )) {
4710
4710
$ this ->debugLog ->writeDebugLog ('Evaluating Structured Reference %s as Cell Range %s ' , $ token ->value (), $ cellRange );
4711
4711
$ rangeValue = self ::getInstance ($ cell ->getWorksheet ()->getParent ())->_calculateFormulaValue ("= {$ cellRange }" , $ cellRange , $ cell );
4712
4712
$ stack ->push ('Value ' , $ rangeValue );
@@ -4770,7 +4770,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null)
4770
4770
}
4771
4771
}
4772
4772
}
4773
- if (strpos ($ operand1Data ['reference ' ] ?? '' , '! ' ) !== false ) {
4773
+ if (str_contains ($ operand1Data ['reference ' ] ?? '' , '! ' )) {
4774
4774
[$ sheet1 , $ operand1Data ['reference ' ]] = Worksheet::extractSheetTitle ($ operand1Data ['reference ' ], true );
4775
4775
} else {
4776
4776
$ sheet1 = ($ pCellWorksheet !== null ) ? $ pCellWorksheet ->getTitle () : '' ;
@@ -4962,7 +4962,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null)
4962
4962
$ cellRef = $ matches [6 ] . $ matches [7 ] . ': ' . $ matches [9 ] . $ matches [10 ];
4963
4963
if ($ matches [2 ] > '' ) {
4964
4964
$ matches [2 ] = trim ($ matches [2 ], "\"' " );
4965
- if ((strpos ($ matches [2 ], '[ ' ) !== false ) || (strpos ($ matches [2 ], '] ' ) !== false )) {
4965
+ if ((str_contains ($ matches [2 ], '[ ' )) || (str_contains ($ matches [2 ], '] ' ))) {
4966
4966
// It's a Reference to an external spreadsheet (not currently supported)
4967
4967
return $ this ->raiseFormulaError ('Unable to access External Workbook ' );
4968
4968
}
@@ -4992,7 +4992,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null)
4992
4992
$ cellRef = $ matches [6 ] . $ matches [7 ];
4993
4993
if ($ matches [2 ] > '' ) {
4994
4994
$ matches [2 ] = trim ($ matches [2 ], "\"' " );
4995
- if ((strpos ($ matches [2 ], '[ ' ) !== false ) || (strpos ($ matches [2 ], '] ' ) !== false )) {
4995
+ if ((str_contains ($ matches [2 ], '[ ' )) || (str_contains ($ matches [2 ], '] ' ))) {
4996
4996
// It's a Reference to an external spreadsheet (not currently supported)
4997
4997
return $ this ->raiseFormulaError ('Unable to access External Workbook ' );
4998
4998
}
@@ -5465,7 +5465,7 @@ public function extractCellRange(&$range = 'A1', ?Worksheet $worksheet = null, b
5465
5465
if ($ worksheet !== null ) {
5466
5466
$ worksheetName = $ worksheet ->getTitle ();
5467
5467
5468
- if (strpos ($ range , '! ' ) !== false ) {
5468
+ if (str_contains ($ range , '! ' )) {
5469
5469
[$ worksheetName , $ range ] = Worksheet::extractSheetTitle ($ range , true );
5470
5470
$ worksheet = ($ this ->spreadsheet === null ) ? null : $ this ->spreadsheet ->getSheetByName ($ worksheetName );
5471
5471
}
@@ -5515,7 +5515,7 @@ public function extractNamedRange(string &$range = 'A1', ?Worksheet $worksheet =
5515
5515
$ returnValue = [];
5516
5516
5517
5517
if ($ worksheet !== null ) {
5518
- if (strpos ($ range , '! ' ) !== false ) {
5518
+ if (str_contains ($ range , '! ' )) {
5519
5519
[$ worksheetName , $ range ] = Worksheet::extractSheetTitle ($ range , true );
5520
5520
$ worksheet = ($ this ->spreadsheet === null ) ? null : $ this ->spreadsheet ->getSheetByName ($ worksheetName );
5521
5521
}
@@ -5636,7 +5636,7 @@ private function getArgumentDefaultValue(ReflectionParameter $methodArgument)
5636
5636
if ($ methodArgument ->isDefaultValueConstant ()) {
5637
5637
$ constantName = $ methodArgument ->getDefaultValueConstantName () ?? '' ;
5638
5638
// read constant value
5639
- if (strpos ($ constantName , ':: ' ) !== false ) {
5639
+ if (str_contains ($ constantName , ':: ' )) {
5640
5640
[$ className , $ constantName ] = explode (':: ' , $ constantName );
5641
5641
$ constantReflector = new ReflectionClassConstant ($ className , $ constantName );
5642
5642
0 commit comments