Skip to content

Commit 46d22e4

Browse files
committed
Change int parameter types to bool when the parameter behaves as bool
Closes phpGH-6148
1 parent 36fd95b commit 46d22e4

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

UPGRADING

+4
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,8 @@ PHP 8.0 UPGRADE NOTES
598598
. sem_get() will now return an SysvSemaphore object rather than a resource.
599599
Return value checks using is_resource() should be replaced with checks
600600
for `false`.
601+
. The $auto_release parameter of sem_get() was changed to accept bool values
602+
rather than int.
601603

602604
- Sysvshm:
603605
. shm_attach() will now return an SysvSharedMemory object rather than a resource.
@@ -786,6 +788,8 @@ PHP 8.0 UPGRADE NOTES
786788
array_diff($array, ...$excludes);
787789
// OK even if $arrays only contains a single array.
788790
array_intersect(...$arrays);
791+
. The $flag parameter of ob_implicit_flush() was changed to accept bool
792+
values rather than int.
789793

790794
- Zip:
791795
. Extension updated to version 1.19.0

ext/standard/basic_functions.stub.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ function ob_list_handlers(): array {}
3737

3838
function ob_get_status(bool $full_status = false): array {}
3939

40-
// TODO: Shouldn't this be a bool argument?
41-
function ob_implicit_flush(int $flag = 1): void {}
40+
function ob_implicit_flush(bool $flag = true): void {}
4241

4342
function output_reset_rewrite_vars(): bool {}
4443

ext/standard/basic_functions_arginfo.h

+2-2
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: 8f80246569ba9de48eebc8b68f476723f78b8f77 */
2+
* Stub hash: df6d5ebb0449274b94f1e8707ab54978fd4b7d2f */
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)
@@ -45,7 +45,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ob_get_status, 0, 0, IS_ARRAY, 0
4545
ZEND_END_ARG_INFO()
4646

4747
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ob_implicit_flush, 0, 0, IS_VOID, 0)
48-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flag, IS_LONG, 0, "1")
48+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flag, _IS_BOOL, 0, "true")
4949
ZEND_END_ARG_INFO()
5050

5151
#define arginfo_output_reset_rewrite_vars arginfo_ob_flush

ext/sysvsem/sysvsem.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,14 @@ PHP_MINFO_FUNCTION(sysvsem)
187187
/* {{{ Return an id for the semaphore with the given key, and allow max_acquire (default 1) processes to acquire it simultaneously */
188188
PHP_FUNCTION(sem_get)
189189
{
190-
zend_long key, max_acquire = 1, perm = 0666, auto_release = 1;
190+
zend_long key, max_acquire = 1, perm = 0666;
191+
zend_bool auto_release = 1;
191192
int semid;
192193
struct sembuf sop[3];
193194
int count;
194195
sysvsem_sem *sem_ptr;
195196

196-
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l|lll", &key, &max_acquire, &perm, &auto_release)) {
197+
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l|llb", &key, &max_acquire, &perm, &auto_release)) {
197198
RETURN_THROWS();
198199
}
199200

@@ -289,7 +290,7 @@ PHP_FUNCTION(sem_get)
289290
sem_ptr->key = key;
290291
sem_ptr->semid = semid;
291292
sem_ptr->count = 0;
292-
sem_ptr->auto_release = auto_release;
293+
sem_ptr->auto_release = (int) auto_release;
293294
}
294295
/* }}} */
295296

ext/sysvsem/sysvsem.stub.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ final class SysvSemaphore
66
{
77
}
88

9-
/**
10-
* @todo use bool for $auto_release
11-
*/
12-
function sem_get(int $key, int $max_acquire = 1, int $perm = 0666, int $auto_release = 1): SysvSemaphore|false {}
9+
function sem_get(int $key, int $max_acquire = 1, int $perm = 0666, bool $auto_release = true): SysvSemaphore|false {}
1310

1411
function sem_acquire(SysvSemaphore $semaphore, bool $nowait = false): bool {}
1512

ext/sysvsem/sysvsem_arginfo.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: a9de9877facd28112e1fe21cf7c6f1c7fdc8014d */
2+
* Stub hash: d00524488977b77475f9aa78c132a6dd53ab4dd0 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_sem_get, 0, 1, SysvSemaphore, MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(0, key, IS_LONG, 0)
66
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, max_acquire, IS_LONG, 0, "1")
77
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, perm, IS_LONG, 0, "0666")
8-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, auto_release, IS_LONG, 0, "1")
8+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, auto_release, _IS_BOOL, 0, "true")
99
ZEND_END_ARG_INFO()
1010

1111
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_sem_acquire, 0, 1, _IS_BOOL, 0)

main/output.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1507,11 +1507,11 @@ PHP_FUNCTION(ob_implicit_flush)
15071507
{
15081508
zend_long flag = 1;
15091509

1510-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flag) == FAILURE) {
1510+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &flag) == FAILURE) {
15111511
RETURN_THROWS();
15121512
}
15131513

1514-
php_output_set_implicit_flush(flag);
1514+
php_output_set_implicit_flush((int) flag);
15151515
}
15161516
/* }}} */
15171517

0 commit comments

Comments
 (0)