Skip to content

Commit f1e7caf

Browse files
committed
Review fixes
1 parent e3f3448 commit f1e7caf

File tree

8 files changed

+33
-43
lines changed

8 files changed

+33
-43
lines changed

ext/standard/basic_functions.stub.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ function link(string $target, string $link): bool {}
10431043

10441044
/* mail.c */
10451045

1046-
function mail(string $to, string $subject, string $message, array|string|null $additional_headers = null, string $additional_parameters = ""): bool {}
1046+
function mail(string $to, string $subject, string $message, array|string $additional_headers = [], string $additional_parameters = ""): bool {}
10471047

10481048
/* math.c */
10491049

@@ -1193,9 +1193,9 @@ function mt_srand(int $seed = 0, int $mode = MT_RAND_MT19937): void {}
11931193
/** @alias mt_srand */
11941194
function srand(int $seed = 0, int $mode = MT_RAND_MT19937): void {}
11951195

1196-
function rand(?int $min = null, ?int $max = null): int {}
1196+
function rand(int $min = UNKNOWN, int $max = UNKNOWN): int {}
11971197

1198-
function mt_rand(?int $min = null, ?int $max = null): int {}
1198+
function mt_rand(int $min = UNKNOWN, int $max = UNKNOWN): int {}
11991199

12001200
function mt_getrandmax(): int {}
12011201

ext/standard/basic_functions_arginfo.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: ea127c860262164d9b3397780878263d6aa12361 */
2+
* Stub hash: c51ad7a5f254f8d28f2b2c0b46e214c44f0f96cf */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
55
ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
@@ -1601,7 +1601,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_mail, 0, 3, _IS_BOOL, 0)
16011601
ZEND_ARG_TYPE_INFO(0, to, IS_STRING, 0)
16021602
ZEND_ARG_TYPE_INFO(0, subject, IS_STRING, 0)
16031603
ZEND_ARG_TYPE_INFO(0, message, IS_STRING, 0)
1604-
ZEND_ARG_TYPE_MASK(0, additional_headers, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null")
1604+
ZEND_ARG_TYPE_MASK(0, additional_headers, MAY_BE_ARRAY|MAY_BE_STRING, "[]")
16051605
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, additional_parameters, IS_STRING, 0, "\"\"")
16061606
ZEND_END_ARG_INFO()
16071607

@@ -1830,8 +1830,8 @@ ZEND_END_ARG_INFO()
18301830
#define arginfo_srand arginfo_mt_srand
18311831

18321832
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rand, 0, 0, IS_LONG, 0)
1833-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, min, IS_LONG, 1, "null")
1834-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, max, IS_LONG, 1, "null")
1833+
ZEND_ARG_TYPE_INFO(0, min, IS_LONG, 0)
1834+
ZEND_ARG_TYPE_INFO(0, max, IS_LONG, 0)
18351835
ZEND_END_ARG_INFO()
18361836

18371837
#define arginfo_mt_rand arginfo_rand

ext/standard/filestat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,8 @@ PHP_FUNCTION(touch)
621621
} else if (!filetime_is_null && fileatime_is_null) {
622622
newtime->modtime = newtime->actime = filetime;
623623
} else if (filetime_is_null && !fileatime_is_null) {
624-
newtime->modtime = fileatime;
625-
newtime->actime = fileatime;
624+
zend_argument_value_error(2, "cannot be null when argument #3 ($atime) is an integer");
625+
RETURN_THROWS();
626626
} else {
627627
newtime->modtime = filetime;
628628
newtime->actime = fileatime;

ext/standard/mail.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ PHP_FUNCTION(mail)
267267
Z_PARAM_STRING(subject, subject_len)
268268
Z_PARAM_STRING(message, message_len)
269269
Z_PARAM_OPTIONAL
270-
Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(headers_str, headers_ht)
270+
Z_PARAM_STR_OR_ARRAY_HT(headers_str, headers_ht)
271271
Z_PARAM_STR(extra_cmd)
272272
ZEND_PARSE_PARAMETERS_END();
273273

ext/standard/mt_rand.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -303,27 +303,19 @@ PHPAPI zend_long php_mt_rand_common(zend_long min, zend_long max)
303303
/* {{{ Returns a random number from Mersenne Twister */
304304
PHP_FUNCTION(mt_rand)
305305
{
306-
zend_long min, max;
307-
zend_bool min_is_null = 1, max_is_null = 1;
306+
zend_long min;
307+
zend_long max;
308+
int argc = ZEND_NUM_ARGS();
308309

309-
ZEND_PARSE_PARAMETERS_START(0, 2)
310-
Z_PARAM_OPTIONAL
311-
Z_PARAM_LONG_OR_NULL(min, min_is_null)
312-
Z_PARAM_LONG_OR_NULL(max, max_is_null)
313-
ZEND_PARSE_PARAMETERS_END();
314-
315-
if (min_is_null && max_is_null) {
310+
if (argc == 0) {
316311
// genrand_int31 in mt19937ar.c performs a right shift
317312
RETURN_LONG(php_mt_rand() >> 1);
318313
}
319314

320-
if (min_is_null) {
321-
min = 0;
322-
}
323-
324-
if (max_is_null) {
325-
max = PHP_MT_RAND_MAX;
326-
}
315+
ZEND_PARSE_PARAMETERS_START(2, 2)
316+
Z_PARAM_LONG(min)
317+
Z_PARAM_LONG(max)
318+
ZEND_PARSE_PARAMETERS_END();
327319

328320
if (UNEXPECTED(max < min)) {
329321
zend_argument_value_error(2, "must be greater than or equal to argument #1 ($min)");

ext/standard/rand.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,18 @@ PHPAPI zend_long php_rand(void)
4343
/* {{{ Returns a random number from Mersenne Twister */
4444
PHP_FUNCTION(rand)
4545
{
46-
zend_long min, max;
47-
zend_bool min_is_null = 1, max_is_null = 1;
46+
zend_long min;
47+
zend_long max;
48+
int argc = ZEND_NUM_ARGS();
4849

49-
ZEND_PARSE_PARAMETERS_START(0, 2)
50-
Z_PARAM_OPTIONAL
51-
Z_PARAM_LONG_OR_NULL(min, min_is_null)
52-
Z_PARAM_LONG_OR_NULL(max, max_is_null)
53-
ZEND_PARSE_PARAMETERS_END();
54-
55-
if (min_is_null && max_is_null) {
50+
if (argc == 0) {
5651
RETURN_LONG(php_mt_rand() >> 1);
5752
}
5853

59-
if (min_is_null) {
60-
min = 0;
61-
}
62-
63-
if (max_is_null) {
64-
max = PHP_MT_RAND_MAX;
65-
}
54+
ZEND_PARSE_PARAMETERS_START(2, 2)
55+
Z_PARAM_LONG(min)
56+
Z_PARAM_LONG(max)
57+
ZEND_PARSE_PARAMETERS_END();
6658

6759
if (max < min) {
6860
RETURN_LONG(php_mt_rand_common(max, min));

ext/standard/tests/file/touch.phpt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ var_dump(touch("/no/such/file/or/directory"));
3535

3636
@unlink($filename);
3737

38+
try {
39+
touch("/no/such/file/or/directory", null, 1599492068);
40+
} catch (ValueError $exception) {
41+
echo $exception->getMessage() . "\n";
42+
}
43+
3844
echo "Done\n";
3945
?>
4046
--EXPECTF--
@@ -51,4 +57,5 @@ int(100)
5157

5258
Warning: touch(): Unable to create file /no/such/file/or/directory because %s in %s on line %d
5359
bool(false)
60+
touch(): Argument #2 ($time) cannot be null when argument #3 ($atime) is an integer
5461
Done

ext/standard/tests/streams/test048HKz

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)