Skip to content

Commit c9c7e08

Browse files
committed
Add ZEND_ACC_NODISCARD flag
1 parent 5fcdd24 commit c9c7e08

File tree

5 files changed

+31
-14
lines changed

5 files changed

+31
-14
lines changed

Zend/zend_compile.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8353,6 +8353,16 @@ static zend_op_array *zend_compile_func_decl_ex(
83538353
if (deprecated_attribute) {
83548354
op_array->fn_flags |= ZEND_ACC_DEPRECATED;
83558355
}
8356+
8357+
zend_attribute *nodiscard_attribute = zend_get_attribute_str(
8358+
op_array->attributes,
8359+
"nodiscard",
8360+
sizeof("nodiscard")-1
8361+
);
8362+
8363+
if (nodiscard_attribute) {
8364+
op_array->fn_flags |= ZEND_ACC_NODISCARD;
8365+
}
83568366
}
83578367

83588368
/* Do not leak the class scope into free standing functions, even if they are dynamically

Zend/zend_compile.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ typedef struct _zend_oparray_context {
333333
/* Class cannot be serialized or unserialized | | | */
334334
#define ZEND_ACC_NOT_SERIALIZABLE (1 << 29) /* X | | | */
335335
/* | | | */
336-
/* Function Flags (unused: 29-30) | | | */
336+
/* Function Flags (unused: 30) | | | */
337337
/* ============== | | | */
338338
/* | | | */
339339
/* deprecation flag | | | */
@@ -395,6 +395,9 @@ typedef struct _zend_oparray_context {
395395
/* has #[\Override] attribute | | | */
396396
#define ZEND_ACC_OVERRIDE (1 << 28) /* | X | | */
397397
/* | | | */
398+
/* has #[\NoDiscard] attribute | | | */
399+
#define ZEND_ACC_NODISCARD (1 << 29) /* | X | | */
400+
/* | | | */
398401
/* op_array uses strict mode types | | | */
399402
#define ZEND_ACC_STRICT_TYPES (1U << 31) /* | X | | */
400403

build/gen_stub.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,9 +1519,13 @@ private function getArginfoFlagsByPhpVersions(): array
15191519
}
15201520

15211521
foreach ($this->attributes as $attr) {
1522-
if ($attr->class === "Deprecated") {
1523-
$flags[] = "ZEND_ACC_DEPRECATED";
1524-
break;
1522+
switch ($attr->class) {
1523+
case "Deprecated":
1524+
$flags[] = "ZEND_ACC_DEPRECATED";
1525+
break;
1526+
case "NoDiscard":
1527+
$flags[] = "ZEND_ACC_NODISCARD";
1528+
break;
15251529
}
15261530
}
15271531

ext/date/php_date_arginfo.h

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/basic_functions_arginfo.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)