Skip to content

Commit 9b3b222

Browse files
gen_stub: ZEND_ACC_NODISCARD is for PHP 8.5+
1 parent 26dbcb7 commit 9b3b222

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

build/gen_stub.php

+20-5
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,13 @@ public function getFunctionEntry(): string {
13901390
$name = "zim_" . $this->name->getDeclarationClassName() . "_" . $this->name->methodName;
13911391

13921392
if ($isVanillaEntry) {
1393-
$functionEntryCode = "\tZEND_ME(" . $this->name->getDeclarationClassName() . ", " . $this->name->methodName . ", $argInfoName, " . implode("|", reset($flagsByPhpVersions)) . ")";
1393+
$template = "\tZEND_ME(" . $this->name->getDeclarationClassName() . ", " . $this->name->methodName . ", $argInfoName, %s)\n";
1394+
$flagsCode = generateVersionDependentFlagCode(
1395+
$template,
1396+
$flagsByPhpVersions,
1397+
$this->minimumPhpVersionIdCompatibility
1398+
);
1399+
$functionEntryCode = rtrim( implode("", $flagsCode) );
13941400
}
13951401
}
13961402
}
@@ -1523,9 +1529,6 @@ private function getArginfoFlagsByPhpVersions(): array
15231529
case "Deprecated":
15241530
$flags[] = "ZEND_ACC_DEPRECATED";
15251531
break;
1526-
case "NoDiscard":
1527-
$flags[] = "ZEND_ACC_NODISCARD";
1528-
break;
15291532
}
15301533
}
15311534

@@ -1534,12 +1537,24 @@ private function getArginfoFlagsByPhpVersions(): array
15341537
$php82AndAboveFlags[] = "ZEND_ACC_COMPILE_TIME_EVAL";
15351538
}
15361539

1540+
$php85AndAboveFlags = $php82AndAboveFlags;
1541+
foreach ($this->attributes as $attr) {
1542+
switch ($attr->class) {
1543+
case "NoDiscard":
1544+
$php85AndAboveFlags[] = "ZEND_ACC_NODISCARD";
1545+
break;
1546+
}
1547+
}
1548+
15371549
if (empty($flags)) {
15381550
$flags[] = "0";
15391551
}
15401552
if (empty($php82AndAboveFlags)) {
15411553
$php82AndAboveFlags[] = "0";
15421554
}
1555+
if (empty($php85AndAboveFlags)) {
1556+
$php85AndAboveFlags[] = "0";
1557+
}
15431558

15441559
return [
15451560
PHP_70_VERSION_ID => $flags,
@@ -1548,7 +1563,7 @@ private function getArginfoFlagsByPhpVersions(): array
15481563
PHP_82_VERSION_ID => $php82AndAboveFlags,
15491564
PHP_83_VERSION_ID => $php82AndAboveFlags,
15501565
PHP_84_VERSION_ID => $php82AndAboveFlags,
1551-
PHP_85_VERSION_ID => $php82AndAboveFlags,
1566+
PHP_85_VERSION_ID => $php85AndAboveFlags,
15521567
];
15531568
}
15541569

ext/zend_test/test_arginfo.h

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)