44
55use PhpOffice \PhpSpreadsheet \Calculation \Calculation ;
66use PhpOffice \PhpSpreadsheet \Calculation \Engine \FormattedNumber ;
7- use PhpOffice \PhpSpreadsheet \RichText \RichText ;
87use PhpOffice \PhpSpreadsheet \Shared \Date ;
98use PhpOffice \PhpSpreadsheet \Shared \StringHelper ;
109use PhpOffice \PhpSpreadsheet \Style \NumberFormat ;
@@ -30,7 +29,7 @@ public function bindValue(Cell $cell, mixed $value = null): bool
3029 $ dataType = parent ::dataTypeForValue ($ value );
3130
3231 // Style logic - strings
33- if ($ dataType === DataType::TYPE_STRING && ! $ value instanceof RichText ) {
32+ if ($ dataType === DataType::TYPE_STRING && is_string ( $ value) ) {
3433 // Test for booleans using locale-setting
3534 if (StringHelper::strToUpper ($ value ) === Calculation::getTRUE ()) {
3635 $ cell ->setValueExplicit (true , DataType::TYPE_BOOL );
@@ -54,17 +53,17 @@ public function bindValue(Cell $cell, mixed $value = null): bool
5453 $ thousandsSeparator = preg_quote (StringHelper::getThousandsSeparator (), '/ ' );
5554
5655 // Check for percentage
57- if (preg_match ('/^\-?\d* ' . $ decimalSeparator . '?\d*\s?\%$/ ' , preg_replace ('/(\d) ' . $ thousandsSeparator . '(\d)/u ' , '$1$2 ' , $ value ))) {
58- return $ this ->setPercentage (preg_replace ('/(\d) ' . $ thousandsSeparator . '(\d)/u ' , '$1$2 ' , $ value ), $ cell );
56+ if (preg_match ('/^\-?\d* ' . $ decimalSeparator . '?\d*\s?\%$/ ' , ( string ) preg_replace ('/(\d) ' . $ thousandsSeparator . '(\d)/u ' , '$1$2 ' , $ value ))) {
57+ return $ this ->setPercentage (( string ) preg_replace ('/(\d) ' . $ thousandsSeparator . '(\d)/u ' , '$1$2 ' , $ value ), $ cell );
5958 }
6059
6160 // Check for currency
62- if (preg_match (FormattedNumber::currencyMatcherRegexp (), preg_replace ('/(\d) ' . $ thousandsSeparator . '(\d)/u ' , '$1$2 ' , $ value ), $ matches , PREG_UNMATCHED_AS_NULL )) {
61+ if (preg_match (FormattedNumber::currencyMatcherRegexp (), ( string ) preg_replace ('/(\d) ' . $ thousandsSeparator . '(\d)/u ' , '$1$2 ' , $ value ), $ matches , PREG_UNMATCHED_AS_NULL )) {
6362 // Convert value to number
6463 $ sign = ($ matches ['PrefixedSign ' ] ?? $ matches ['PrefixedSign2 ' ] ?? $ matches ['PostfixedSign ' ]) ?? null ;
6564 $ currencyCode = $ matches ['PrefixedCurrency ' ] ?? $ matches ['PostfixedCurrency ' ];
6665 /** @var string */
67- $ temp = str_replace ([$ decimalSeparatorNoPreg , $ currencyCode , ' ' , '- ' ], ['. ' , '' , '' , '' ], preg_replace ('/(\d) ' . $ thousandsSeparator . '(\d)/u ' , '$1$2 ' , $ value ));
66+ $ temp = str_replace ([$ decimalSeparatorNoPreg , $ currencyCode , ' ' , '- ' ], ['. ' , '' , '' , '' ], ( string ) preg_replace ('/(\d) ' . $ thousandsSeparator . '(\d)/u ' , '$1$2 ' , $ value ));
6867 $ value = (float ) ($ sign . trim ($ temp ));
6968
7069 return $ this ->setCurrency ($ value , $ cell , $ currencyCode ?? '' );
0 commit comments