File tree 2 files changed +30
-20
lines changed 2 files changed +30
-20
lines changed Original file line number Diff line number Diff line change @@ -4820,27 +4820,17 @@ PHP_FUNCTION(mb_check_encoding)
4820
4820
RETURN_FALSE ;
4821
4821
}
4822
4822
4823
- switch (Z_TYPE_P (input )) {
4824
- case IS_LONG :
4825
- case IS_DOUBLE :
4826
- case IS_NULL :
4827
- case IS_TRUE :
4828
- case IS_FALSE :
4829
- RETURN_TRUE ;
4830
- break ;
4831
- case IS_STRING :
4832
- if (!php_mb_check_encoding (Z_STRVAL_P (input ), Z_STRLEN_P (input ), enc ? ZSTR_VAL (enc ): NULL )) {
4833
- RETURN_FALSE ;
4834
- }
4835
- break ;
4836
- case IS_ARRAY :
4837
- if (!php_mb_check_encoding_recursive (Z_ARRVAL_P (input ), enc )) {
4838
- RETURN_FALSE ;
4839
- }
4840
- break ;
4841
- default :
4842
- php_error_docref (NULL , E_WARNING , "Input is something other than scalar or array" );
4823
+ if (Z_TYPE_P (input ) == IS_ARRAY ) {
4824
+ if (!php_mb_check_encoding_recursive (HASH_OF (input ), enc )) {
4825
+ RETURN_FALSE ;
4826
+ }
4827
+ } else {
4828
+ if (!try_convert_to_string (input )) {
4829
+ RETURN_FALSE ;
4830
+ }
4831
+ if (!php_mb_check_encoding (Z_STRVAL_P (input ), Z_STRLEN_P (input ), enc ? ZSTR_VAL (enc ): NULL )) {
4843
4832
RETURN_FALSE ;
4833
+ }
4844
4834
}
4845
4835
RETURN_TRUE ;
4846
4836
}
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