Skip to content

Commit 142e378

Browse files
Arginfo: add and use known strings for attribute values
1 parent 0c920ec commit 142e378

26 files changed

+149
-472
lines changed

Zend/zend_constants_arginfo.h

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

Zend/zend_string.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,12 @@ EMPTY_SWITCH_DEFAULT_CASE()
636636
_(ZEND_STR_SINCE, "since") \
637637
_(ZEND_STR_GET, "get") \
638638
_(ZEND_STR_SET, "set") \
639+
_(ZEND_STR_8_DOT_0, "8.0") \
640+
_(ZEND_STR_8_DOT_1, "8.1") \
641+
_(ZEND_STR_8_DOT_2, "8.2") \
642+
_(ZEND_STR_8_DOT_3, "8.3") \
643+
_(ZEND_STR_8_DOT_4, "8.4") \
644+
_(ZEND_STR_8_DOT_5, "8.5") \
639645

640646

641647
typedef enum _zend_known_string_id {

build/gen_stub.php

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3058,6 +3058,12 @@ class StringBuilder {
30583058
"username" => "ZEND_STR_USERNAME",
30593059
"password" => "ZEND_STR_PASSWORD",
30603060
"clone" => "ZEND_STR_CLONE",
3061+
'8.0' => 'ZEND_STR_8_DOT_0',
3062+
'8.1' => 'ZEND_STR_8_DOT_1',
3063+
'8.2' => 'ZEND_STR_8_DOT_2',
3064+
'8.3' => 'ZEND_STR_8_DOT_3',
3065+
'8.4' => 'ZEND_STR_8_DOT_4',
3066+
'8.5' => 'ZEND_STR_8_DOT_5',
30613067
];
30623068

30633069
/**
@@ -3358,10 +3364,26 @@ public function generateCode(string $invocation, string $nameSuffix, array $allC
33583364
$code .= $stringRelease;
33593365

33603366
foreach ($this->args as $i => $arg) {
3361-
$value = EvaluatedValue::createFromExpression($arg->value, null, null, $allConstInfos);
3362-
$zvalName = "attribute_{$escapedAttributeName}_{$nameSuffix}_arg$i";
3363-
$code .= $value->initializeZval($zvalName);
3364-
$code .= "\tZVAL_COPY_VALUE(&attribute_{$escapedAttributeName}_{$nameSuffix}->args[$i].value, &$zvalName);\n";
3367+
$initValue = '';
3368+
if ($arg->value instanceof Node\Scalar\String_) {
3369+
$strVal = $arg->value->value;
3370+
[$strInit, $strUse, $strRelease] = StringBuilder::getString(
3371+
'unused',
3372+
$strVal,
3373+
$phpVersionIdMinimumCompatibility
3374+
);
3375+
if ($strInit === '') {
3376+
$initValue = "\tZVAL_STR(&attribute_{$escapedAttributeName}_{$nameSuffix}->args[$i].value, $strUse);\n";
3377+
}
3378+
}
3379+
if ($initValue === '') {
3380+
$value = EvaluatedValue::createFromExpression($arg->value, null, null, $allConstInfos);
3381+
$zvalName = "attribute_{$escapedAttributeName}_{$nameSuffix}_arg$i";
3382+
$code .= $value->initializeZval($zvalName);
3383+
$code .= "\tZVAL_COPY_VALUE(&attribute_{$escapedAttributeName}_{$nameSuffix}->args[$i].value, &$zvalName);\n";
3384+
} else {
3385+
$code .= $initValue;
3386+
}
33653387
if ($arg->name) {
33663388
[$stringInit, $nameCode, $stringRelease] = StringBuilder::getString(
33673389
"",

ext/curl/curl_arginfo.h

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

ext/date/php_date_arginfo.h

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

ext/dom/php_dom_arginfo.h

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy