mirror of
https://github.com/php/php-src.git
synced 2024-11-23 09:54:15 +08:00
Add the last few remaining constants to stubs (#13751)
Basically all constants are now declared via stubs. The rest of the constants are either deprecated (`SID` or `MHASH_*`) or out of interest (`__COMPILER_HALT_OFFSET__` and `PHP_CLI_PROCESS_TITLE`).
This commit is contained in:
parent
51dafc6054
commit
5bb03158b6
@ -2526,6 +2526,7 @@ class ConstInfo extends VariableLike
|
||||
public ?string $cond;
|
||||
public ?string $cValue;
|
||||
public bool $isUndocumentable;
|
||||
public bool $isFileCacheAllowed;
|
||||
|
||||
/**
|
||||
* @var AttributeInfo[] $attributes
|
||||
@ -2544,7 +2545,8 @@ class ConstInfo extends VariableLike
|
||||
?string $link,
|
||||
?int $phpVersionIdMinimumCompatibility,
|
||||
array $attributes,
|
||||
?ExposedDocComment $exposedDocComment
|
||||
?ExposedDocComment $exposedDocComment,
|
||||
bool $isFileCacheAllowed
|
||||
) {
|
||||
$this->name = $name;
|
||||
$this->value = $value;
|
||||
@ -2553,6 +2555,7 @@ class ConstInfo extends VariableLike
|
||||
$this->cond = $cond;
|
||||
$this->cValue = $cValue;
|
||||
$this->isUndocumentable = $isUndocumentable;
|
||||
$this->isFileCacheAllowed = $isFileCacheAllowed;
|
||||
parent::__construct($flags, $type, $phpDocType, $link, $phpVersionIdMinimumCompatibility, $attributes, $exposedDocComment);
|
||||
}
|
||||
|
||||
@ -2698,6 +2701,9 @@ class ConstInfo extends VariableLike
|
||||
$cExpr = $value->getCExpr();
|
||||
|
||||
$flags = "CONST_PERSISTENT";
|
||||
if (!$this->isFileCacheAllowed) {
|
||||
$flags .= " | CONST_NO_FILE_CACHE";
|
||||
}
|
||||
if ($this->phpVersionIdMinimumCompatibility !== null && $this->phpVersionIdMinimumCompatibility < 80000) {
|
||||
$flags .= " | CONST_CS";
|
||||
}
|
||||
@ -2725,7 +2731,8 @@ class ConstInfo extends VariableLike
|
||||
return "\tREGISTER_STRING_CONSTANT(\"$constName\", " . ($cExpr ?: '"' . addslashes($constValue) . '"') . ", $flags);\n";
|
||||
}
|
||||
|
||||
throw new Exception("Unimplemented constant type");}
|
||||
throw new Exception("Unimplemented constant type");
|
||||
}
|
||||
|
||||
/** @param array<string, ConstInfo> $allConstInfos */
|
||||
private function getClassConstDeclaration(EvaluatedValue $value, array $allConstInfos): string
|
||||
@ -4304,6 +4311,7 @@ function parseConstLike(
|
||||
$deprecated = false;
|
||||
$cValue = null;
|
||||
$link = null;
|
||||
$isFileCacheAllowed = true;
|
||||
if ($comments) {
|
||||
$tags = parseDocComments($comments);
|
||||
foreach ($tags as $tag) {
|
||||
@ -4317,6 +4325,8 @@ function parseConstLike(
|
||||
$isUndocumentable = true;
|
||||
} elseif ($tag->name === 'link') {
|
||||
$link = $tag->value;
|
||||
} elseif ($tag->name === 'no-file-cache') {
|
||||
$isFileCacheAllowed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4339,7 +4349,8 @@ function parseConstLike(
|
||||
$link,
|
||||
$phpVersionIdMinimumCompatibility,
|
||||
$attributes,
|
||||
createExposedDocComment($comments)
|
||||
createExposedDocComment($comments),
|
||||
$isFileCacheAllowed
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,11 @@ PHP_RINIT_FUNCTION(dir)
|
||||
|
||||
PHP_MINIT_FUNCTION(dir)
|
||||
{
|
||||
static char dirsep_str[2], pathsep_str[2];
|
||||
dirsep_str[0] = DEFAULT_SLASH;
|
||||
dirsep_str[1] = '\0';
|
||||
|
||||
pathsep_str[0] = ZEND_PATHS_SEPARATOR;
|
||||
pathsep_str[1] = '\0';
|
||||
|
||||
register_dir_symbols(module_number);
|
||||
|
||||
@ -117,14 +121,6 @@ PHP_MINIT_FUNCTION(dir)
|
||||
ts_allocate_id(&dir_globals_id, sizeof(php_dir_globals), NULL, NULL);
|
||||
#endif
|
||||
|
||||
dirsep_str[0] = DEFAULT_SLASH;
|
||||
dirsep_str[1] = '\0';
|
||||
REGISTER_STRING_CONSTANT("DIRECTORY_SEPARATOR", dirsep_str, CONST_PERSISTENT);
|
||||
|
||||
pathsep_str[0] = ZEND_PATHS_SEPARATOR;
|
||||
pathsep_str[1] = '\0';
|
||||
REGISTER_STRING_CONSTANT("PATH_SEPARATOR", pathsep_str, CONST_PERSISTENT);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -2,6 +2,17 @@
|
||||
|
||||
/** @generate-class-entries */
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue dirsep_str
|
||||
*/
|
||||
const DIRECTORY_SEPARATOR = UNKNOWN;
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue pathsep_str
|
||||
*/
|
||||
const PATH_SEPARATOR = UNKNOWN;
|
||||
|
||||
#ifdef HAVE_GLOB
|
||||
#if (defined(GLOB_BRACE) && GLOB_BRACE != 0)
|
||||
/**
|
||||
|
4
ext/standard/dir_arginfo.h
generated
4
ext/standard/dir_arginfo.h
generated
@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: f2571fbbcff57095abcb846f148644e10b2db2e8 */
|
||||
* Stub hash: 4b0f093770ff9a6cad9db033e0b62b412408b937 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Directory_close, 0, 0, IS_VOID, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
@ -22,6 +22,8 @@ static const zend_function_entry class_Directory_methods[] = {
|
||||
|
||||
static void register_dir_symbols(int module_number)
|
||||
{
|
||||
REGISTER_STRING_CONSTANT("DIRECTORY_SEPARATOR", dirsep_str, CONST_PERSISTENT);
|
||||
REGISTER_STRING_CONSTANT("PATH_SEPARATOR", pathsep_str, CONST_PERSISTENT);
|
||||
#if defined(HAVE_GLOB) && (defined(GLOB_BRACE) && GLOB_BRACE != 0)
|
||||
REGISTER_LONG_CONSTANT("GLOB_BRACE", GLOB_BRACE, CONST_PERSISTENT);
|
||||
#endif
|
||||
|
@ -62,4 +62,6 @@
|
||||
|
||||
#endif /* HAVE_GLOB */
|
||||
|
||||
char dirsep_str[2], pathsep_str[2];
|
||||
|
||||
#endif /* PHP_DIR_INT_H */
|
||||
|
10
main/main.c
10
main/main.c
@ -2137,16 +2137,8 @@ zend_result php_module_startup(sapi_module_struct *sf, zend_module_entry *additi
|
||||
|
||||
le_index_ptr = zend_register_list_destructors_ex(NULL, NULL, "index pointer", 0);
|
||||
|
||||
register_main_symbols(module_number);
|
||||
|
||||
REGISTER_MAIN_STRINGL_CONSTANT("PHP_SAPI", sapi_module.name, strlen(sapi_module.name), CONST_PERSISTENT | CONST_NO_FILE_CACHE);
|
||||
|
||||
php_binary_init();
|
||||
if (PG(php_binary)) {
|
||||
REGISTER_MAIN_STRINGL_CONSTANT("PHP_BINARY", PG(php_binary), strlen(PG(php_binary)), CONST_PERSISTENT | CONST_NO_FILE_CACHE);
|
||||
} else {
|
||||
REGISTER_MAIN_STRINGL_CONSTANT("PHP_BINARY", "", 0, CONST_PERSISTENT | CONST_NO_FILE_CACHE);
|
||||
}
|
||||
register_main_symbols(module_number);
|
||||
|
||||
/* this will read in php.ini, set up the configuration parameters,
|
||||
load zend extensions and register php function extensions
|
||||
|
@ -354,3 +354,15 @@ const UPLOAD_ERR_EXTENSION = UNKNOWN;
|
||||
*/
|
||||
const ZEND_VERIFY_TYPE_INFERENCE = UNKNOWN;
|
||||
#endif
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue sapi_module.name
|
||||
* @no-file-cache
|
||||
*/
|
||||
const PHP_SAPI = UNKNOWN;
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue PG(php_binary) ? PG(php_binary) : ""
|
||||
* @no-file-cache
|
||||
*/
|
||||
const PHP_BINARY = UNKNOWN;
|
||||
|
4
main/main_arginfo.h
generated
4
main/main_arginfo.h
generated
@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 2542736c885829255e4226783b60db1453342b65 */
|
||||
* Stub hash: 7ff3d7dc2636153044513390669cb46e9a5b5a0a */
|
||||
|
||||
static void register_main_symbols(int module_number)
|
||||
{
|
||||
@ -97,4 +97,6 @@ static void register_main_symbols(int module_number)
|
||||
#if defined(ZEND_VERIFY_TYPE_INFERENCE)
|
||||
REGISTER_BOOL_CONSTANT("ZEND_VERIFY_TYPE_INFERENCE", ZEND_VERIFY_TYPE_INFERENCE, CONST_PERSISTENT);
|
||||
#endif
|
||||
REGISTER_STRING_CONSTANT("PHP_SAPI", sapi_module.name, CONST_PERSISTENT | CONST_NO_FILE_CACHE);
|
||||
REGISTER_STRING_CONSTANT("PHP_BINARY", PG(php_binary) ? PG(php_binary) : "", CONST_PERSISTENT | CONST_NO_FILE_CACHE);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user