4
4
5
5
use PhpOffice \PhpSpreadsheet \Calculation \Calculation ;
6
6
use PhpOffice \PhpSpreadsheet \Calculation \Engine \FormattedNumber ;
7
- use PhpOffice \PhpSpreadsheet \RichText \RichText ;
8
7
use PhpOffice \PhpSpreadsheet \Shared \Date ;
9
8
use PhpOffice \PhpSpreadsheet \Shared \StringHelper ;
10
9
use PhpOffice \PhpSpreadsheet \Style \NumberFormat ;
@@ -30,7 +29,7 @@ public function bindValue(Cell $cell, mixed $value = null): bool
30
29
$ dataType = parent ::dataTypeForValue ($ value );
31
30
32
31
// Style logic - strings
33
- if ($ dataType === DataType::TYPE_STRING && ! $ value instanceof RichText ) {
32
+ if ($ dataType === DataType::TYPE_STRING && is_string ( $ value) ) {
34
33
// Test for booleans using locale-setting
35
34
if (StringHelper::strToUpper ($ value ) === Calculation::getTRUE ()) {
36
35
$ cell ->setValueExplicit (true , DataType::TYPE_BOOL );
@@ -54,17 +53,17 @@ public function bindValue(Cell $cell, mixed $value = null): bool
54
53
$ thousandsSeparator = preg_quote (StringHelper::getThousandsSeparator (), '/ ' );
55
54
56
55
// 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 );
59
58
}
60
59
61
60
// 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 )) {
63
62
// Convert value to number
64
63
$ sign = ($ matches ['PrefixedSign ' ] ?? $ matches ['PrefixedSign2 ' ] ?? $ matches ['PostfixedSign ' ]) ?? null ;
65
64
$ currencyCode = $ matches ['PrefixedCurrency ' ] ?? $ matches ['PostfixedCurrency ' ];
66
65
/** @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 ));
68
67
$ value = (float ) ($ sign . trim ($ temp ));
69
68
70
69
return $ this ->setCurrency ($ value , $ cell , $ currencyCode ?? '' );
0 commit comments