Skip to content

Rename @cname to @cvalue in stubs #9043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Zend/zend_attributes.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ final class Attribute
{
/**
* @var int
* @cname ZEND_ATTRIBUTE_TARGET_CLASS
* @cvalue ZEND_ATTRIBUTE_TARGET_CLASS
*/
const TARGET_CLASS = UNKNOWN;
/**
* @var int
* @cname ZEND_ATTRIBUTE_TARGET_FUNCTION
* @cvalue ZEND_ATTRIBUTE_TARGET_FUNCTION
*/
const TARGET_FUNCTION = UNKNOWN;
/**
* @var int
* @cname ZEND_ATTRIBUTE_TARGET_METHOD
* @cvalue ZEND_ATTRIBUTE_TARGET_METHOD
*/
const TARGET_METHOD = UNKNOWN;
/**
* @var int
* @cname ZEND_ATTRIBUTE_TARGET_PROPERTY
* @cvalue ZEND_ATTRIBUTE_TARGET_PROPERTY
*/
const TARGET_PROPERTY = UNKNOWN;
/**
* @var int
* @cname ZEND_ATTRIBUTE_TARGET_CLASS_CONST
* @cvalue ZEND_ATTRIBUTE_TARGET_CLASS_CONST
*/
const TARGET_CLASS_CONSTANT = UNKNOWN;
/**
* @var int
* @cname ZEND_ATTRIBUTE_TARGET_PARAMETER
* @cvalue ZEND_ATTRIBUTE_TARGET_PARAMETER
*/
const TARGET_PARAMETER = UNKNOWN;
/**
* @var int
* @cname ZEND_ATTRIBUTE_TARGET_ALL
* @cvalue ZEND_ATTRIBUTE_TARGET_ALL
*/
const TARGET_ALL = UNKNOWN;
/**
* @var int
* @cname ZEND_ATTRIBUTE_IS_REPEATABLE
* @cvalue ZEND_ATTRIBUTE_IS_REPEATABLE
*/
const IS_REPEATABLE = UNKNOWN;

Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_attributes_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions Zend/zend_constants.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,96 +4,96 @@

/**
* @var int
* @cname E_ERROR
* @cvalue E_ERROR
*/
const E_ERROR = UNKNOWN;

/**
* @var int
* @cname E_WARNING
* @cvalue E_WARNING
*/
const E_WARNING = UNKNOWN;

/**
* @var int
* @cname E_PARSE
* @cvalue E_PARSE
*/
const E_PARSE = UNKNOWN;

/**
* @var int
* @cname E_NOTICE
* @cvalue E_NOTICE
*/
const E_NOTICE = UNKNOWN;

/**
* @var int
* @cname E_CORE_ERROR
* @cvalue E_CORE_ERROR
*/
const E_CORE_ERROR = UNKNOWN;

/**
* @var int
* @cname E_CORE_WARNING
* @cvalue E_CORE_WARNING
*/
const E_CORE_WARNING = UNKNOWN;

/**
* @var int
* @cname E_COMPILE_ERROR
* @cvalue E_COMPILE_ERROR
*/
const E_COMPILE_ERROR = UNKNOWN;

/**
* @var int
* @cname E_COMPILE_WARNING
* @cvalue E_COMPILE_WARNING
*/
const E_COMPILE_WARNING = UNKNOWN;

/**
* @var int
* @cname E_USER_ERROR
* @cvalue E_USER_ERROR
*/
const E_USER_ERROR = UNKNOWN;

/**
* @var int
* @cname E_USER_WARNING
* @cvalue E_USER_WARNING
*/
const E_USER_WARNING = UNKNOWN;

/**
* @var int
* @cname E_USER_NOTICE
* @cvalue E_USER_NOTICE
*/
const E_USER_NOTICE = UNKNOWN;

/**
* @var int
* @cname E_STRICT
* @cvalue E_STRICT
*/
const E_STRICT = UNKNOWN;

/**
* @var int
* @cname E_RECOVERABLE_ERROR
* @cvalue E_RECOVERABLE_ERROR
*/
const E_RECOVERABLE_ERROR = UNKNOWN;

/**
* @var int
* @cname E_DEPRECATED
* @cvalue E_DEPRECATED
*/
const E_DEPRECATED = UNKNOWN;

/**
* @var int
* @cname E_USER_DEPRECATED
* @cvalue E_USER_DEPRECATED
*/
const E_USER_DEPRECATED = UNKNOWN;

/**
* @var int
* @cname E_ALL
* @cvalue E_ALL
*/
const E_ALL = UNKNOWN;
2 changes: 1 addition & 1 deletion Zend/zend_constants_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 23 additions & 23 deletions build/gen_stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ class EvaluatedValue
public $type;

/** @var string|null */
public $cConstName;
public $cConstValue;

/** @var bool */
public $isUnknownConstValue;
Expand Down Expand Up @@ -1671,7 +1671,7 @@ private function __construct($value, SimpleType $type, ?string $cConstName, ?Con
{
$this->value = $value;
$this->type = $type;
$this->cConstName = $cConstName;
$this->cConstValue = $cConstName;
$this->originatingConst = $originatingConst;
$this->isUnknownConstValue = $isUnknownConstValue;
}
Expand Down Expand Up @@ -1719,8 +1719,8 @@ public function initializeZval(string $zvalName, iterable $allConstInfos): strin
*/
public function getCConstValue(iterable $allConstInfos): ?string
{
if ($this->cConstName) {
return $this->cConstName;
if ($this->cConstValue) {
return $this->cConstValue;
}

if ($this->originatingConst) {
Expand Down Expand Up @@ -1872,7 +1872,7 @@ class ConstInfo extends VariableLike
/** @var string|null */
public $cond;
/** @var string|null */
public $cname;
public $cValue;

public function __construct(
ConstOrClassConstName $name,
Expand All @@ -1882,7 +1882,7 @@ public function __construct(
?Type $phpDocType,
bool $isDeprecated,
?string $cond,
?string $cname,
?string $cValue,
?string $link,
?int $phpVersionIdMinimumCompatibility
) {
Expand All @@ -1891,7 +1891,7 @@ public function __construct(
$this->valueString = $valueString;
$this->isDeprecated = $isDeprecated;
$this->cond = $cond;
$this->cname = $cname;
$this->cValue = $cValue;
parent::__construct($flags, $phpDocType, $link, $phpVersionIdMinimumCompatibility);
}

Expand All @@ -1903,7 +1903,7 @@ public function getValue(iterable $allConstInfos): EvaluatedValue
return EvaluatedValue::createFromExpression(
$this->value,
$this->phpDocType->tryToSimpleType(),
$this->cname,
$this->cValue,
$allConstInfos
);
}
Expand Down Expand Up @@ -1948,7 +1948,7 @@ protected function addTypeToFieldSynopsis(DOMDocument $doc, DOMElement $fieldsyn
*/
protected function getFieldSynopsisValueString(iterable $allConstInfos): ?string
{
$value = EvaluatedValue::createFromExpression($this->value, null, $this->cname, $allConstInfos);
$value = EvaluatedValue::createFromExpression($this->value, null, $this->cValue, $allConstInfos);
if ($value->originatingConst) {
return $value->originatingConst->getFieldSynopsisValueString($allConstInfos);
}
Expand All @@ -1971,9 +1971,9 @@ public function getDeclaration(iterable $allConstInfos): string
throw new Exception("Constant " . $this->name->__toString() . " must have a simple built-in type");
}

$value = EvaluatedValue::createFromExpression($this->value, $type, $this->cname, $allConstInfos);
if ($value->isUnknownConstValue && !$value->cConstName) {
throw new Exception("Constant " . $this->name->__toString() . " must have a @cname annotation");
$value = EvaluatedValue::createFromExpression($this->value, $type, $this->cValue, $allConstInfos);
if ($value->isUnknownConstValue && !$value->cConstValue) {
throw new Exception("Constant " . $this->name->__toString() . " must have a @cvalue annotation");
}

$code = "";
Expand Down Expand Up @@ -2059,35 +2059,35 @@ private function getClassConstDeclaration(EvaluatedValue $value, iterable $allCo

private function getValueAssertion(EvaluatedValue $value): string
{
if ($value->isUnknownConstValue || $value->originatingConst || $value->cConstName === null) {
if ($value->isUnknownConstValue || $value->originatingConst || $value->cConstValue === null) {
return "";
}

$cName = $value->cConstName;
$cConstValue = $value->cConstValue;
$constValue = $value->value;

if ($value->type->isNull()) {
return "\tZEND_ASSERT($cName == NULL);\n";
return "\tZEND_ASSERT($cConstValue == NULL);\n";
}

if ($value->type->isBool()) {
$cValue = $constValue ? "true" : "false";
return "\tZEND_ASSERT($cName == $cValue);\n";
return "\tZEND_ASSERT($cConstValue == $cValue);\n";
}

if ($value->type->isInt()) {
$cValue = (int) $constValue;
return "\tZEND_ASSERT($cName == $cValue);\n";
return "\tZEND_ASSERT($cConstValue == $cValue);\n";
}

if ($value->type->isFloat()) {
$cValue = (float) $constValue;
return "\tZEND_ASSERT($cName == $cValue);\n";
return "\tZEND_ASSERT($cConstValue == $cValue);\n";
}

if ($value->type->isString()) {
$cValue = '"' . addslashes($constValue) . '"';
return "\tZEND_ASSERT(strcmp($cName, $cValue) == 0);\n";
return "\tZEND_ASSERT(strcmp($cConstValue, $cValue) == 0);\n";
}

throw new Exception("Unimplemented constant type");
Expand Down Expand Up @@ -3376,7 +3376,7 @@ function parseConstLike(
): ConstInfo {
$phpDocType = null;
$deprecated = false;
$cname = null;
$cValue = null;
$link = null;
if ($docComment) {
$tags = parseDocComment($docComment);
Expand All @@ -3385,8 +3385,8 @@ function parseConstLike(
$phpDocType = $tag->getType();
} elseif ($tag->name === 'deprecated') {
$deprecated = true;
} elseif ($tag->name === 'cname') {
$cname = $tag->value;
} elseif ($tag->name === 'cvalue') {
$cValue = $tag->value;
} elseif ($tag->name === 'link') {
$link = $tag->value;
}
Expand All @@ -3405,7 +3405,7 @@ function parseConstLike(
Type::fromString($phpDocType),
$deprecated,
$cond,
$cname,
$cValue,
$link,
$phpVersionIdMinimumCompatibility
);
Expand Down
Loading