File tree Expand file tree Collapse file tree 3 files changed +30
-20
lines changed Expand file tree Collapse file tree 3 files changed +30
-20
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ PHP NEWS
13
13
- MBString:
14
14
. Fixed bug #78579 (mb_decode_numericentity: args number inconsistency).
15
15
(cmb)
16
+ . Fixed bug #78609 (mb_check_encoding() no longer supports stringable
17
+ objects). (cmb)
16
18
17
19
- Standard:
18
20
. Fixed bug #76342 (file_get_contents waits twice specified timeout).
Original file line number Diff line number Diff line change @@ -5027,27 +5027,15 @@ PHP_FUNCTION(mb_check_encoding)
5027
5027
RETURN_FALSE ;
5028
5028
}
5029
5029
5030
- switch (Z_TYPE_P (input )) {
5031
- case IS_LONG :
5032
- case IS_DOUBLE :
5033
- case IS_NULL :
5034
- case IS_TRUE :
5035
- case IS_FALSE :
5036
- RETURN_TRUE ;
5037
- break ;
5038
- case IS_STRING :
5039
- if (!php_mb_check_encoding (Z_STRVAL_P (input ), Z_STRLEN_P (input ), enc ? ZSTR_VAL (enc ): NULL )) {
5040
- RETURN_FALSE ;
5041
- }
5042
- break ;
5043
- case IS_ARRAY :
5044
- if (!php_mb_check_encoding_recursive (HASH_OF (input ), enc )) {
5045
- RETURN_FALSE ;
5046
- }
5047
- break ;
5048
- default :
5049
- php_error_docref (NULL , E_WARNING , "Input is something other than scalar or array" );
5030
+ if (Z_TYPE_P (input ) == IS_ARRAY ) {
5031
+ if (!php_mb_check_encoding_recursive (HASH_OF (input ), enc )) {
5050
5032
RETURN_FALSE ;
5033
+ }
5034
+ } else {
5035
+ convert_to_string (input );
5036
+ if (!php_mb_check_encoding (Z_STRVAL_P (input ), Z_STRLEN_P (input ), enc ? ZSTR_VAL (enc ): NULL )) {
5037
+ RETURN_FALSE ;
5038
+ }
5051
5039
}
5052
5040
RETURN_TRUE ;
5053
5041
}
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #78609 (mb_check_encoding() no longer supports stringable objects)
3
+ --SKIPIF--
4
+ <?php
5
+ if (!extension_loaded ('mbstring ' )) die ('skip mbstring extension not available ' );
6
+ ?>
7
+ --FILE--
8
+ <?php
9
+ class Foo
10
+ {
11
+ public function __toString ()
12
+ {
13
+ return 'string_representation ' ;
14
+ }
15
+ }
16
+
17
+ var_dump (mb_check_encoding (new Foo , 'UTF-8 ' ));
18
+ ?>
19
+ --EXPECT--
20
+ bool(true)
You can’t perform that action at this time.
0 commit comments