Skip to content

Commit

Permalink
Change int parameter types to bool when the parameter behaves as bool
Browse files Browse the repository at this point in the history
Closes phpGH-6148
  • Loading branch information
kocsismate committed Sep 17, 2020
1 parent 36fd95b commit 46d22e4
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
4 changes: 4 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,8 @@ PHP 8.0 UPGRADE NOTES
. sem_get() will now return an SysvSemaphore object rather than a resource.
Return value checks using is_resource() should be replaced with checks
for `false`.
. The $auto_release parameter of sem_get() was changed to accept bool values
rather than int.

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

- Zip:
. Extension updated to version 1.19.0
Expand Down
3 changes: 1 addition & 2 deletions ext/standard/basic_functions.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ function ob_list_handlers(): array {}

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

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

function output_reset_rewrite_vars(): bool {}

Expand Down
4 changes: 2 additions & 2 deletions ext/standard/basic_functions_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 8f80246569ba9de48eebc8b68f476723f78b8f77 */
* Stub hash: df6d5ebb0449274b94f1e8707ab54978fd4b7d2f */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
Expand Down Expand Up @@ -45,7 +45,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ob_get_status, 0, 0, IS_ARRAY, 0
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ob_implicit_flush, 0, 0, IS_VOID, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flag, IS_LONG, 0, "1")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flag, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()

#define arginfo_output_reset_rewrite_vars arginfo_ob_flush
Expand Down
7 changes: 4 additions & 3 deletions ext/sysvsem/sysvsem.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,14 @@ PHP_MINFO_FUNCTION(sysvsem)
/* {{{ Return an id for the semaphore with the given key, and allow max_acquire (default 1) processes to acquire it simultaneously */
PHP_FUNCTION(sem_get)
{
zend_long key, max_acquire = 1, perm = 0666, auto_release = 1;
zend_long key, max_acquire = 1, perm = 0666;
zend_bool auto_release = 1;
int semid;
struct sembuf sop[3];
int count;
sysvsem_sem *sem_ptr;

if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l|lll", &key, &max_acquire, &perm, &auto_release)) {
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l|llb", &key, &max_acquire, &perm, &auto_release)) {
RETURN_THROWS();
}

Expand Down Expand Up @@ -289,7 +290,7 @@ PHP_FUNCTION(sem_get)
sem_ptr->key = key;
sem_ptr->semid = semid;
sem_ptr->count = 0;
sem_ptr->auto_release = auto_release;
sem_ptr->auto_release = (int) auto_release;
}
/* }}} */

Expand Down
5 changes: 1 addition & 4 deletions ext/sysvsem/sysvsem.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ final class SysvSemaphore
{
}

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

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

Expand Down
4 changes: 2 additions & 2 deletions ext/sysvsem/sysvsem_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: a9de9877facd28112e1fe21cf7c6f1c7fdc8014d */
* Stub hash: d00524488977b77475f9aa78c132a6dd53ab4dd0 */

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_sem_get, 0, 1, SysvSemaphore, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, key, IS_LONG, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, max_acquire, IS_LONG, 0, "1")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, perm, IS_LONG, 0, "0666")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, auto_release, IS_LONG, 0, "1")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, auto_release, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_sem_acquire, 0, 1, _IS_BOOL, 0)
Expand Down
4 changes: 2 additions & 2 deletions main/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1507,11 +1507,11 @@ PHP_FUNCTION(ob_implicit_flush)
{
zend_long flag = 1;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flag) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &flag) == FAILURE) {
RETURN_THROWS();
}

php_output_set_implicit_flush(flag);
php_output_set_implicit_flush((int) flag);
}
/* }}} */

Expand Down

0 comments on commit 46d22e4

Please sign in to comment.