Skip to content

Commit df04bee

Browse files
committed
use enum instead of bool type
1 parent 2744622 commit df04bee

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

ext/date/php_date.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3213,7 +3213,12 @@ PHP_FUNCTION(date_format)
32133213
}
32143214
/* }}} */
32153215

3216-
static bool php_date_modify(zval *object, char *modify, size_t modify_len, const bool should_throw) /* {{{ */
3216+
typedef enum {
3217+
PHP_DATE_MODIFY_WARNING,
3218+
PHP_DATE_MODIFY_THROW
3219+
} php_date_modify_error_mode;
3220+
3221+
static bool php_date_modify(zval *object, char *modify, size_t modify_len, const php_date_modify_error_mode error_mode) /* {{{ */
32173222
{
32183223
php_date_obj *dateobj;
32193224
timelib_time *tmp_time;
@@ -3233,7 +3238,7 @@ static bool php_date_modify(zval *object, char *modify, size_t modify_len, const
32333238

32343239
if (err && err->error_count) {
32353240
/* spit out the first library error message, at least */
3236-
if (should_throw) {
3241+
if (error_mode == PHP_DATE_MODIFY_THROW) {
32373242
zend_string *func_name = get_active_function_or_method_name();
32383243
zend_throw_exception_ex(date_ce_date_malformed_string_exception, 0,
32393244
"%s(): Failed to parse time string (%s) at position %d (%c): %s",
@@ -3317,7 +3322,7 @@ PHP_FUNCTION(date_modify)
33173322
RETURN_THROWS();
33183323
}
33193324

3320-
if (!php_date_modify(object, modify, modify_len, false)) {
3325+
if (!php_date_modify(object, modify, modify_len, PHP_DATE_MODIFY_WARNING)) {
33213326
RETURN_FALSE;
33223327
}
33233328

@@ -3337,7 +3342,7 @@ PHP_METHOD(DateTime, modify)
33373342
Z_PARAM_STRING(modify, modify_len)
33383343
ZEND_PARSE_PARAMETERS_END();
33393344

3340-
if (!php_date_modify(object, modify, modify_len, true)) {
3345+
if (!php_date_modify(object, modify, modify_len, PHP_DATE_MODIFY_THROW)) {
33413346
RETURN_THROWS();
33423347
}
33433348

@@ -3359,7 +3364,7 @@ PHP_METHOD(DateTimeImmutable, modify)
33593364

33603365
date_clone_immutable(object, &new_object);
33613366

3362-
if (!php_date_modify(&new_object, modify, modify_len, true)) {
3367+
if (!php_date_modify(&new_object, modify, modify_len, PHP_DATE_MODIFY_THROW)) {
33633368
zval_ptr_dtor(&new_object);
33643369
RETURN_THROWS();
33653370
}

0 commit comments

Comments
 (0)