Skip to content

Commit 8a0965e

Browse files
committed
Remove zpp L specifier
We don't use this internally anymore, and external usages should be encouraged to move towards 'l'.
1 parent b1e52ca commit 8a0965e

File tree

3 files changed

+10
-67
lines changed

3 files changed

+10
-67
lines changed

UPGRADING.INTERNALS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ PHP 8.0 INTERNALS UPGRADE NOTES
55
b. ZEND_OVERLOADED_FUNCTION and corresponding call_method() object handler
66
c. TSRM changes
77
d. get() and set() object handlers
8+
e. zend_parse_parameters 'L' specifier
89

910
2. Build system changes
1011
a. Abstract
@@ -47,6 +48,9 @@ PHP 8.0 INTERNALS UPGRADE NOTES
4748
functionality should be provided in some other way (for example, as
4849
modification of an object property).
4950

51+
e. The zend_parse_parameters 'L' specifier and the Z_PARAM_STRICT_LONG()
52+
family of macros have been removed. Use 'l' and Z_PARAM_LONG() insead,
53+
which, despite the confusing name, actually have stricter input validation.
5054

5155
========================
5256
2. Build system changes

Zend/zend_API.c

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -343,47 +343,6 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest)
343343
}
344344
/* }}} */
345345

346-
ZEND_API int ZEND_FASTCALL zend_parse_arg_long_cap_weak(zval *arg, zend_long *dest) /* {{{ */
347-
{
348-
if (EXPECTED(Z_TYPE_P(arg) == IS_DOUBLE)) {
349-
if (UNEXPECTED(zend_isnan(Z_DVAL_P(arg)))) {
350-
return 0;
351-
}
352-
*dest = zend_dval_to_lval_cap(Z_DVAL_P(arg));
353-
} else if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
354-
double d;
355-
int type;
356-
357-
if (UNEXPECTED((type = is_numeric_str_function(Z_STR_P(arg), dest, &d)) != IS_LONG)) {
358-
if (EXPECTED(type != 0)) {
359-
if (UNEXPECTED(zend_isnan(d))) {
360-
return 0;
361-
}
362-
*dest = zend_dval_to_lval_cap(d);
363-
} else {
364-
return 0;
365-
}
366-
}
367-
} else if (EXPECTED(Z_TYPE_P(arg) < IS_TRUE)) {
368-
*dest = 0;
369-
} else if (EXPECTED(Z_TYPE_P(arg) == IS_TRUE)) {
370-
*dest = 1;
371-
} else {
372-
return 0;
373-
}
374-
return 1;
375-
}
376-
/* }}} */
377-
378-
ZEND_API int ZEND_FASTCALL zend_parse_arg_long_cap_slow(zval *arg, zend_long *dest) /* {{{ */
379-
{
380-
if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
381-
return 0;
382-
}
383-
return zend_parse_arg_long_cap_weak(arg, dest);
384-
}
385-
/* }}} */
386-
387346
ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest) /* {{{ */
388347
{
389348
if (EXPECTED(Z_TYPE_P(arg) == IS_LONG)) {
@@ -481,7 +440,6 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
481440

482441
switch (c) {
483442
case 'l':
484-
case 'L':
485443
{
486444
zend_long *p = va_arg(*va, zend_long *);
487445
zend_bool *is_null = NULL;
@@ -490,7 +448,7 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
490448
is_null = va_arg(*va, zend_bool *);
491449
}
492450

493-
if (!zend_parse_arg_long(arg, p, is_null, check_null, c == 'L')) {
451+
if (!zend_parse_arg_long(arg, p, is_null, check_null)) {
494452
return "int";
495453
}
496454
}
@@ -688,9 +646,9 @@ static const char *zend_parse_arg_impl(int arg_num, zval *arg, va_list *va, cons
688646
}
689647
break;
690648

691-
case 'Z':
692-
/* 'Z' iz not supported anymore and should be replaced with 'z' */
693-
ZEND_ASSERT(c != 'Z');
649+
case 'Z': /* replace with 'z' */
650+
case 'L': /* replace with 'l' */
651+
ZEND_ASSERT(0 && "ZPP modifier no longer supported");
694652
default:
695653
return "unknown";
696654
}

Zend/zend_API.h

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *e
13311331
/* old "l" */
13321332
#define Z_PARAM_LONG_EX2(dest, is_null, check_null, deref, separate) \
13331333
Z_PARAM_PROLOGUE(deref, separate); \
1334-
if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null, 0))) { \
1334+
if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null))) { \
13351335
_expected_type = Z_EXPECTED_LONG; \
13361336
_error_code = ZPP_ERROR_WRONG_ARG; \
13371337
break; \
@@ -1343,21 +1343,6 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_wrong_callback_error(int num, char *e
13431343
#define Z_PARAM_LONG(dest) \
13441344
Z_PARAM_LONG_EX(dest, _dummy, 0, 0)
13451345

1346-
/* old "L" */
1347-
#define Z_PARAM_STRICT_LONG_EX2(dest, is_null, check_null, deref, separate) \
1348-
Z_PARAM_PROLOGUE(deref, separate); \
1349-
if (UNEXPECTED(!zend_parse_arg_long(_arg, &dest, &is_null, check_null, 1))) { \
1350-
_expected_type = Z_EXPECTED_LONG; \
1351-
_error_code = ZPP_ERROR_WRONG_ARG; \
1352-
break; \
1353-
}
1354-
1355-
#define Z_PARAM_STRICT_LONG_EX(dest, is_null, check_null, separate) \
1356-
Z_PARAM_STRICT_LONG_EX2(dest, is_null, check_null, separate, separate)
1357-
1358-
#define Z_PARAM_STRICT_LONG(dest) \
1359-
Z_PARAM_STRICT_LONG_EX(dest, _dummy, 0, 0)
1360-
13611346
/* old "o" */
13621347
#define Z_PARAM_OBJECT_EX2(dest, check_null, deref, separate) \
13631348
Z_PARAM_PROLOGUE(deref, separate); \
@@ -1514,8 +1499,6 @@ ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_slow(zval *arg, zend_bool *dest);
15141499
ZEND_API int ZEND_FASTCALL zend_parse_arg_bool_weak(zval *arg, zend_bool *dest);
15151500
ZEND_API int ZEND_FASTCALL zend_parse_arg_long_slow(zval *arg, zend_long *dest);
15161501
ZEND_API int ZEND_FASTCALL zend_parse_arg_long_weak(zval *arg, zend_long *dest);
1517-
ZEND_API int ZEND_FASTCALL zend_parse_arg_long_cap_slow(zval *arg, zend_long *dest);
1518-
ZEND_API int ZEND_FASTCALL zend_parse_arg_long_cap_weak(zval *arg, zend_long *dest);
15191502
ZEND_API int ZEND_FASTCALL zend_parse_arg_double_slow(zval *arg, double *dest);
15201503
ZEND_API int ZEND_FASTCALL zend_parse_arg_double_weak(zval *arg, double *dest);
15211504
ZEND_API int ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest);
@@ -1539,7 +1522,7 @@ static zend_always_inline int zend_parse_arg_bool(zval *arg, zend_bool *dest, ze
15391522
return 1;
15401523
}
15411524

1542-
static zend_always_inline int zend_parse_arg_long(zval *arg, zend_long *dest, zend_bool *is_null, int check_null, int cap)
1525+
static zend_always_inline int zend_parse_arg_long(zval *arg, zend_long *dest, zend_bool *is_null, int check_null)
15431526
{
15441527
if (check_null) {
15451528
*is_null = 0;
@@ -1549,8 +1532,6 @@ static zend_always_inline int zend_parse_arg_long(zval *arg, zend_long *dest, ze
15491532
} else if (check_null && Z_TYPE_P(arg) == IS_NULL) {
15501533
*is_null = 1;
15511534
*dest = 0;
1552-
} else if (cap) {
1553-
return zend_parse_arg_long_cap_slow(arg, dest);
15541535
} else {
15551536
return zend_parse_arg_long_slow(arg, dest);
15561537
}

0 commit comments

Comments
 (0)