File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -4933,6 +4933,15 @@ PHP_FUNCTION(setlocale)
49334933 Z_PARAM_VARIADIC ('+ ', args, num_args)
49344934 ZEND_PARSE_PARAMETERS_END ();
49354935
4936+ if (ZEND_ARG_USES_STRICT_TYPES ()) {
4937+ for (uint32_t i = 0 ; i < num_args ; i ++ ) {
4938+ if (UNEXPECTED (Z_TYPE (args [i ]) != IS_ARRAY && Z_TYPE (args [i ]) != IS_STRING )) {
4939+ zend_wrong_parameter_type_error (i + 2 , Z_EXPECTED_ARRAY_OR_STRING , & args [i ]);
4940+ RETURN_THROWS ();
4941+ }
4942+ }
4943+ }
4944+
49364945 for (uint32_t i = 0 ; i < num_args ; i ++ ) {
49374946 if (Z_TYPE (args [i ]) == IS_ARRAY ) {
49384947 zval * elem ;
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-18823 (setlocale's 2nd and 3rd argument ignores strict_types)
3+ --FILE--
4+ <?php
5+ declare (strict_types=1 );
6+ try {
7+ setlocale (LC_ALL , 0 , "0 " );
8+ } catch (TypeError $ e ) {
9+ echo $ e ->getMessage (), "\n" ;
10+ }
11+ try {
12+ setlocale (LC_ALL , "0 " , 0 );
13+ } catch (TypeError $ e ) {
14+ echo $ e ->getMessage (), "\n" ;
15+ }
16+ ?>
17+ --EXPECT--
18+ setlocale(): Argument #2 ($locales) must be of type array|string, int given
19+ setlocale(): Argument #3 must be of type array|string, int given
You can’t perform that action at this time.
0 commit comments