Skip to content

Commit ae05eca

Browse files
committed
Fix conflicts
1 parent b3d3bc1 commit ae05eca

File tree

2 files changed

+91
-153
lines changed

2 files changed

+91
-153
lines changed

build/gen_stub.php

Lines changed: 7 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,8 +1399,8 @@ function initializeZval(string $zvalName, $value): string
13991399
if ($value === "") {
14001400
$code .= "\tZVAL_EMPTY_STRING(&$zvalName);\n";
14011401
} else {
1402-
$strValue = addslashes($value);
1403-
$code .= "\tzend_string *{$zvalName}_str = zend_string_init(\"$strValue\", sizeof(\"$strValue\") - 1, 1);\n";
1402+
$value = addslashes($value);
1403+
$code .= "\tzend_string *{$zvalName}_str = zend_string_init(\"$value\", sizeof(\"$value\") - 1, 1);\n";
14041404
$code .= "\tZVAL_STR(&$zvalName, {$zvalName}_str);\n";
14051405
}
14061406
break;
@@ -1435,66 +1435,6 @@ abstract protected function getFieldsynopsisLinkend(): string;
14351435

14361436
abstract protected function getFieldsynopsisValueString(): ?string;
14371437

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

16211561
public function getDeclaration(): string
16221562
{
1623-
$constName = $this->name->const;
1624-
16251563
$constantValue = false;
16261564
$value = $this->evaluateValue($this->value, $constantValue);
16271565
$valueType = gettype($value);
@@ -1678,16 +1616,16 @@ private function getConstDeclaration(string $code, $value, string $valueType): s
16781616
return $code;
16791617
}
16801618

1681-
private function getClassConstDeclaration(string $code, mixed $value, string $valueType): string
1619+
private function getClassConstDeclaration(string $code, mixed $value): string
16821620
{
1683-
$constName = $this->name;
1621+
$constName = $this->getVariableLikeName();
16841622

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

16871625
$code .= "\tzend_string *const_{$constName}_name = zend_string_init_interned(\"$constName\", sizeof(\"$constName\") - 1, 1);\n";
16881626
$nameCode = "const_{$constName}_name";
16891627

1690-
$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";
16911629
$code .= "\tzend_string_release(const_{$constName}_name);\n";
16921630

16931631
return $code;
@@ -1786,7 +1724,7 @@ public function getDeclaration(): string {
17861724
if ($this->defaultValue === null) {
17871725
$defaultValue = null;
17881726
} else {
1789-
$defaultValue = $this->evaluateValue($defaultValueConstant);
1727+
$defaultValue = $this->evaluateValue($this->defaultValue, $defaultValueConstant);
17901728
}
17911729

17921730
if ($defaultValueConstant) {

0 commit comments

Comments
 (0)