Skip to content

Commit 85bf2e1

Browse files
committed
Fix conflicts
1 parent 34357db commit 85bf2e1

File tree

2 files changed

+90
-151
lines changed

2 files changed

+90
-151
lines changed

build/gen_stub.php

Lines changed: 6 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,6 +1399,7 @@ function initializeZval(string $zvalName, $value): string
13991399
if ($value === "") {
14001400
$code .= "\tZVAL_EMPTY_STRING(&$zvalName);\n";
14011401
} else {
1402+
$value = addslashes($value);
14021403
$code .= "\tzend_string *{$zvalName}_str = zend_string_init(\"$value\", sizeof(\"$value\") - 1, 1);\n";
14031404
$code .= "\tZVAL_STR(&$zvalName, {$zvalName}_str);\n";
14041405
}
@@ -1434,66 +1435,6 @@ abstract protected function getFieldsynopsisLinkend(): string;
14341435

14351436
abstract protected function getFieldsynopsisValueString(): ?string;
14361437

1437-
/**
1438-
* @param mixed $value
1439-
*/
1440-
protected function initializeValue(string $type, $value, bool $isTyped): string
1441-
{
1442-
$name = $this->getVariableLikeName();
1443-
$zvalName = $this->getVariableTypeCode() . "_{$name}_value";
1444-
1445-
$code = "\tzval $zvalName;\n";
1446-
1447-
switch ($type) {
1448-
case "undefined":
1449-
if ($isTyped) {
1450-
$code .= "\tZVAL_UNDEF(&$zvalName);\n";
1451-
} else {
1452-
$code .= "\tZVAL_NULL(&$zvalName);\n";
1453-
}
1454-
break;
1455-
1456-
case "NULL":
1457-
$code .= "\tZVAL_NULL(&$zvalName);\n";
1458-
break;
1459-
1460-
case "boolean":
1461-
$code .= "\tZVAL_BOOL(&$zvalName, " . ((int) $value) . ");\n";
1462-
break;
1463-
1464-
case "integer":
1465-
$code .= "\tZVAL_LONG(&$zvalName, $value);\n";
1466-
break;
1467-
1468-
case "double":
1469-
$code .= "\tZVAL_DOUBLE(&$zvalName, $value);\n";
1470-
break;
1471-
1472-
case "string":
1473-
if ($value === "") {
1474-
$code .= "\tZVAL_EMPTY_STRING(&$zvalName);\n";
1475-
} else {
1476-
$value = addslashes($value);
1477-
$code .= "\tzend_string *{$zvalName}_str = zend_string_init(\"$value\", sizeof(\"$value\") - 1, 1);\n";
1478-
$code .= "\tZVAL_STR(&$zvalName, {$zvalName}_str);\n";
1479-
}
1480-
break;
1481-
1482-
case "array":
1483-
if (empty($value)) {
1484-
$code .= "\tZVAL_EMPTY_ARRAY(&$zvalName);\n";
1485-
} else {
1486-
throw new Exception("Unimplemented " . $this->getVariableTypeName() . " value");
1487-
}
1488-
break;
1489-
1490-
default:
1491-
throw new Exception("Invalid " . $this->getVariableTypeName() . " value");
1492-
}
1493-
1494-
return $code;
1495-
}
1496-
14971438
protected function getFlagsAsString(): string
14981439
{
14991440
$flags = "ZEND_ACC_PUBLIC";
@@ -1619,8 +1560,6 @@ protected function getFieldsynopsisValueString(): ?string
16191560

16201561
public function getDeclaration(): string
16211562
{
1622-
$constName = $this->name->const;
1623-
16241563
$constantValue = false;
16251564
$value = $this->evaluateValue($this->value, $constantValue);
16261565
$valueType = gettype($value);
@@ -1677,16 +1616,16 @@ private function getConstDeclaration(string $code, $value, string $valueType): s
16771616
return $code;
16781617
}
16791618

1680-
private function getClassConstDeclaration(string $code, mixed $value, string $valueType): string
1619+
private function getClassConstDeclaration(string $code, mixed $value): string
16811620
{
1682-
$constName = $this->name;
1621+
$constName = $this->getVariableLikeName();
16831622

1684-
$code .= "\n" . $this->initializeValue($valueType, $value, false);
1623+
$code .= "\n" . initializeZval("const_{$constName}_value", $value);
16851624

16861625
$code .= "\tzend_string *const_{$constName}_name = zend_string_init_interned(\"$constName\", sizeof(\"$constName\") - 1, 1);\n";
16871626
$nameCode = "const_{$constName}_name";
16881627

1689-
$code .= "\tzend_declare_class_constant_ex(class_entry, $nameCode, &const_{$constName}_value, " . $this->getFlagsAsString($this->isDeprecated) . ", NULL);\n";
1628+
$code .= "\tzend_declare_class_constant_ex(class_entry, $nameCode, &const_{$constName}_value, " . $this->getFlagsAsString() . ", NULL);\n";
16901629
$code .= "\tzend_string_release(const_{$constName}_name);\n";
16911630

16921631
return $code;
@@ -1785,7 +1724,7 @@ public function getDeclaration(): string {
17851724
if ($this->defaultValue === null) {
17861725
$defaultValue = null;
17871726
} else {
1788-
$defaultValue = $this->evaluateValue($defaultValueConstant);
1727+
$defaultValue = $this->evaluateValue($this->defaultValue, $defaultValueConstant);
17891728
}
17901729

17911730
if ($defaultValueConstant) {

0 commit comments

Comments
 (0)