mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
gen_stub: Infer constants' types from values (#19568)
Don't require `@var` with a type when the type can be inferred from a literal value in the stub file.
This commit is contained in:
@@ -130,17 +130,14 @@ const ZEND_VM_KIND = UNKNOWN;
|
||||
/* Special constants true/false/null. */
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* @undocumentable
|
||||
*/
|
||||
const TRUE = true;
|
||||
/**
|
||||
* @var bool
|
||||
* @undocumentable
|
||||
*/
|
||||
const FALSE = false;
|
||||
/**
|
||||
* @var null
|
||||
* @undocumentable
|
||||
*/
|
||||
const NULL = null;
|
||||
|
||||
2
Zend/zend_constants_arginfo.h
generated
2
Zend/zend_constants_arginfo.h
generated
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: bf2f959978bd6cbd7353ca7bfbb95718cdd51cff */
|
||||
* Stub hash: 569ccba4e0a93a9ce49c81c76955413188df390e */
|
||||
|
||||
static void register_zend_constants_symbols(int module_number)
|
||||
{
|
||||
|
||||
@@ -4874,7 +4874,32 @@ function parseConstLike(
|
||||
}
|
||||
|
||||
if ($type === null && $phpDocType === null) {
|
||||
throw new Exception("Missing type for constant " . $name->__toString());
|
||||
if ($const->value instanceof Node\Scalar\Float_) {
|
||||
$phpDocType = 'float';
|
||||
} elseif ($const->value instanceof Node\Scalar\Int_
|
||||
|| ($const->value instanceof Expr\UnaryMinus
|
||||
&& $const->value->expr instanceof Node\Scalar\Int_
|
||||
)
|
||||
) {
|
||||
$phpDocType = 'int';
|
||||
} elseif ($const->value instanceof Node\Scalar\String_) {
|
||||
$phpDocType = 'string';
|
||||
} elseif ($const->value instanceof Expr\ConstFetch
|
||||
&& $const->value->name instanceof Node\Name\FullyQualified
|
||||
&& (
|
||||
$const->value->name->name === 'false'
|
||||
|| $const->value->name->name === 'true'
|
||||
)
|
||||
) {
|
||||
$phpDocType = 'bool';
|
||||
} elseif ($const->value instanceof Expr\ConstFetch
|
||||
&& $const->value->name instanceof Node\Name\FullyQualified
|
||||
&& $const->value->name->name === 'null'
|
||||
) {
|
||||
$phpDocType = 'null';
|
||||
} else {
|
||||
throw new Exception("Missing type for constant " . $name->__toString());
|
||||
}
|
||||
}
|
||||
|
||||
$constType = $type ? Type::fromNode($type) : null;
|
||||
|
||||
@@ -3,74 +3,62 @@
|
||||
/** @generate-class-entries */
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue DATE_FORMAT_RFC3339
|
||||
*/
|
||||
const DATE_ATOM = "Y-m-d\\TH:i:sP";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue DATE_FORMAT_COOKIE
|
||||
*/
|
||||
const DATE_COOKIE = "l, d-M-Y H:i:s T";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue DATE_FORMAT_ISO8601
|
||||
*/
|
||||
const DATE_ISO8601 = "Y-m-d\\TH:i:sO";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue DATE_FORMAT_ISO8601_EXPANDED
|
||||
*/
|
||||
const DATE_ISO8601_EXPANDED = "X-m-d\\TH:i:sP";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue DATE_FORMAT_RFC822
|
||||
*/
|
||||
const DATE_RFC822 = "D, d M y H:i:s O";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue DATE_FORMAT_RFC850
|
||||
*/
|
||||
const DATE_RFC850 = "l, d-M-y H:i:s T";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue DATE_FORMAT_RFC1036
|
||||
*/
|
||||
const DATE_RFC1036 = "D, d M y H:i:s O";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue DATE_FORMAT_RFC1123
|
||||
*/
|
||||
const DATE_RFC1123 = "D, d M Y H:i:s O";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue DATE_FORMAT_RFC7231
|
||||
*/
|
||||
#[\Deprecated(since: '8.5', message: "as this format ignores the associated timezone and always uses GMT")]
|
||||
const DATE_RFC7231 = "D, d M Y H:i:s \\G\\M\\T";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue DATE_FORMAT_RFC2822
|
||||
*/
|
||||
const DATE_RFC2822 = "D, d M Y H:i:s O";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue DATE_FORMAT_RFC3339
|
||||
*/
|
||||
const DATE_RFC3339 = "Y-m-d\\TH:i:sP";
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @cvalue DATE_FORMAT_RFC3339_EXTENDED
|
||||
*/
|
||||
const DATE_RFC3339_EXTENDED = "Y-m-d\\TH:i:s.vP";
|
||||
|
||||
2
ext/date/php_date_arginfo.h
generated
2
ext/date/php_date_arginfo.h
generated
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: db70e6a06d177d2cb6e4a47379c0b761b248f380 */
|
||||
* Stub hash: 16d118b58a713bbea5174c170129aa9f6206de68 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strtotime, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
|
||||
ZEND_ARG_TYPE_INFO(0, datetime, IS_STRING, 0)
|
||||
|
||||
@@ -14,7 +14,6 @@ namespace Dba {
|
||||
|
||||
namespace {
|
||||
#ifdef DBA_LMDB
|
||||
/** @var int */
|
||||
const DBA_LMDB_USE_SUB_DIR = 0;
|
||||
/**
|
||||
* @var int
|
||||
|
||||
2
ext/dba/dba_arginfo.h
generated
2
ext/dba/dba_arginfo.h
generated
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: da00cabc7b6930f1b834af8978b38945df96212f */
|
||||
* Stub hash: d7ff53b73d3921c41ffd8279ea724bcd3a6d8542 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_dba_popen, 0, 2, Dba\\Connection, MAY_BE_FALSE)
|
||||
ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0)
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
* @undocumentable
|
||||
*/
|
||||
|
||||
/** @var int */
|
||||
const DL_TEST_CONST = 42;
|
||||
|
||||
function dl_test_test1(): void {}
|
||||
|
||||
2
ext/dl_test/dl_test_arginfo.h
generated
2
ext/dl_test/dl_test_arginfo.h
generated
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 75bdb57a45060b123fe48003fef43d2af07726e1 */
|
||||
* Stub hash: 3c47a0da41b4548eb68c4124bd54cbac22f60c01 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_dl_test_test1, 0, 0, IS_VOID, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
@@ -449,17 +449,11 @@ const GD_EXTRA_VERSION = UNKNOWN;
|
||||
* /usr/include/pngconf.h:310:2: error: #error png.h already includes setjmp.h with some additional fixup.
|
||||
* as error, use the values for now...
|
||||
*/
|
||||
/** @var int */
|
||||
const PNG_NO_FILTER = 0x00;
|
||||
/** @var int */
|
||||
const PNG_FILTER_NONE = 0x08;
|
||||
/** @var int */
|
||||
const PNG_FILTER_SUB = 0x10;
|
||||
/** @var int */
|
||||
const PNG_FILTER_UP = 0x20;
|
||||
/** @var int */
|
||||
const PNG_FILTER_AVG = 0x40;
|
||||
/** @var int */
|
||||
const PNG_FILTER_PAETH = 0x80;
|
||||
/** @var int */
|
||||
const PNG_ALL_FILTERS = 0x08 | 0x10 | 0x20 | 0x40 | 0x80;
|
||||
|
||||
2
ext/gd/gd_arginfo.h
generated
2
ext/gd/gd_arginfo.h
generated
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: bbf4c8d4a3ee5712120bd89f4a2ecc516ea65ff1 */
|
||||
* Stub hash: 2cdc0b485d9b62bb9021973d3c8cce0169b21ac0 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gd_info, 0, 0, IS_ARRAY, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
@@ -589,9 +589,6 @@ const MYSQLI_TRANS_COR_RELEASE = UNKNOWN;
|
||||
*/
|
||||
const MYSQLI_TRANS_COR_NO_RELEASE = UNKNOWN;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
#[\Deprecated(since: '8.2', message: 'as it is always false')]
|
||||
const MYSQLI_IS_MARIADB = false;
|
||||
|
||||
|
||||
2
ext/mysqli/mysqli_arginfo.h
generated
2
ext/mysqli/mysqli_arginfo.h
generated
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: ce02f0eeb9191e7c92cb8a5e5fcae20fceb0b47c */
|
||||
* Stub hash: fecde55745fb219cb15fd35a54a71371ef2b8b7d */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mysqli_affected_rows, 0, 1, MAY_BE_LONG|MAY_BE_STRING)
|
||||
ZEND_ARG_OBJ_INFO(0, mysql, mysqli, 0)
|
||||
|
||||
@@ -388,7 +388,6 @@ const OPENSSL_ZERO_PADDING = UNKNOWN;
|
||||
const OPENSSL_DONT_ZERO_PAD_KEY = UNKNOWN;
|
||||
|
||||
#ifndef OPENSSL_NO_TLSEXT
|
||||
/** @var int */
|
||||
const OPENSSL_TLSEXT_SERVER_NAME = 1;
|
||||
#endif
|
||||
|
||||
|
||||
2
ext/openssl/openssl_arginfo.h
generated
2
ext/openssl/openssl_arginfo.h
generated
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 0e6a5f1a5f23602bafd5b7fdb10525c19a9476fc */
|
||||
* Stub hash: 8233a8abc8ab7145d905d0fa51478edfe1e55a06 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_openssl_x509_export_to_file, 0, 2, _IS_BOOL, 0)
|
||||
ZEND_ARG_OBJ_TYPE_MASK(0, certificate, OpenSSLCertificate, MAY_BE_STRING, NULL)
|
||||
|
||||
@@ -3,13 +3,7 @@
|
||||
/** @generate-class-entries */
|
||||
|
||||
#if defined(HAVE_OPENSSL_ARGON2)
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const PASSWORD_ARGON2I = "argon2i";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const PASSWORD_ARGON2ID = "argon2id";
|
||||
/**
|
||||
* @var int
|
||||
@@ -26,9 +20,6 @@ const PASSWORD_ARGON2_DEFAULT_TIME_COST = UNKNOWN;
|
||||
* @cvalue PHP_OPENSSL_PWHASH_THREADS
|
||||
*/
|
||||
const PASSWORD_ARGON2_DEFAULT_THREADS = UNKNOWN;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const PASSWORD_ARGON2_PROVIDER = "openssl";
|
||||
#endif
|
||||
|
||||
|
||||
2
ext/openssl/openssl_pwhash_arginfo.h
generated
2
ext/openssl/openssl_pwhash_arginfo.h
generated
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: b6056170a5c8f1a9582c5eef9261a0bd02f7a7e1 */
|
||||
* Stub hash: 23ee957ba4945be3a21db58051e548729c3ff44e */
|
||||
|
||||
static void register_openssl_pwhash_symbols(int module_number)
|
||||
{
|
||||
|
||||
@@ -3,13 +3,7 @@
|
||||
/** @generate-class-entries */
|
||||
|
||||
#if SODIUM_LIBRARY_VERSION_MAJOR > 9 || (SODIUM_LIBRARY_VERSION_MAJOR == 9 && SODIUM_LIBRARY_VERSION_MINOR >= 6)
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const PASSWORD_ARGON2I = "argon2i";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const PASSWORD_ARGON2ID = "argon2id";
|
||||
/**
|
||||
* @var int
|
||||
@@ -26,8 +20,5 @@ const PASSWORD_ARGON2_DEFAULT_TIME_COST = UNKNOWN;
|
||||
* @cvalue PHP_SODIUM_PWHASH_THREADS
|
||||
*/
|
||||
const PASSWORD_ARGON2_DEFAULT_THREADS = UNKNOWN;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const PASSWORD_ARGON2_PROVIDER = "sodium";
|
||||
#endif
|
||||
|
||||
2
ext/sodium/sodium_pwhash_arginfo.h
generated
2
ext/sodium/sodium_pwhash_arginfo.h
generated
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: dd94e709f115ce05df0e25a8cb48c62438bb6d01 */
|
||||
* Stub hash: d1e804ceea5e18fc5a4eca50b318d98387b2a470 */
|
||||
|
||||
static void register_sodium_pwhash_symbols(int module_number)
|
||||
{
|
||||
|
||||
@@ -260,87 +260,70 @@ const PHP_QUERY_RFC1738 = UNKNOWN;
|
||||
const PHP_QUERY_RFC3986 = UNKNOWN;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_E
|
||||
*/
|
||||
const M_E = 2.718281828459045;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_LOG2E
|
||||
*/
|
||||
const M_LOG2E = 1.4426950408889634074;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_LOG10E
|
||||
*/
|
||||
const M_LOG10E = 0.43429448190325182765;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_LN2
|
||||
*/
|
||||
const M_LN2 = 0.69314718055994530942;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_LN10
|
||||
*/
|
||||
const M_LN10 = 2.30258509299404568402;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_PI
|
||||
*/
|
||||
const M_PI = 3.14159265358979323846;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_PI_2
|
||||
*/
|
||||
const M_PI_2 = 1.57079632679489661923;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_PI_4
|
||||
*/
|
||||
const M_PI_4 = 0.78539816339744830962;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_1_PI
|
||||
*/
|
||||
const M_1_PI = 0.31830988618379067154;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_2_PI
|
||||
*/
|
||||
const M_2_PI = 0.63661977236758134308;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_SQRTPI
|
||||
*/
|
||||
const M_SQRTPI = 1.77245385090551602729;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_2_SQRTPI
|
||||
*/
|
||||
const M_2_SQRTPI = 1.12837916709551257390;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_LNPI
|
||||
*/
|
||||
const M_LNPI = 1.14472988584940017414;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_EULER
|
||||
*/
|
||||
const M_EULER = 0.57721566490153286061;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_SQRT2
|
||||
*/
|
||||
const M_SQRT2 = 1.41421356237309504880;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_SQRT1_2
|
||||
*/
|
||||
const M_SQRT1_2 = 0.70710678118654752440;
|
||||
/**
|
||||
* @var float
|
||||
* @cvalue M_SQRT3
|
||||
*/
|
||||
const M_SQRT3 = 1.73205080756887729352;
|
||||
@@ -383,17 +366,11 @@ const PHP_ROUND_HALF_ODD = UNKNOWN;
|
||||
* @cvalue PHP_MAX_SALT_LEN
|
||||
*/
|
||||
const CRYPT_SALT_LENGTH = UNKNOWN;
|
||||
/** @var int */
|
||||
const CRYPT_STD_DES = 1;
|
||||
/** @var int */
|
||||
const CRYPT_EXT_DES = 1;
|
||||
/** @var int */
|
||||
const CRYPT_MD5 = 1;
|
||||
/** @var int */
|
||||
const CRYPT_BLOWFISH = 1;
|
||||
/** @var int */
|
||||
const CRYPT_SHA256 = 1;
|
||||
/** @var int */
|
||||
const CRYPT_SHA512 = 1;
|
||||
|
||||
/* dns.c */
|
||||
|
||||
2
ext/standard/basic_functions_arginfo.h
generated
2
ext/standard/basic_functions_arginfo.h
generated
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 01fc9901c45992450d60ceedbb82d3a6fb8500de */
|
||||
* Stub hash: f6bf6cdd07080c01d3a0cb08d71409d05b1084f9 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_set_time_limit, 0, 1, _IS_BOOL, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, seconds, IS_LONG, 0)
|
||||
|
||||
@@ -444,14 +444,9 @@ const FILE_APPEND = UNKNOWN;
|
||||
*/
|
||||
const FILE_NO_DEFAULT_CONTEXT = UNKNOWN;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
#[\Deprecated(since: '8.1', message: 'as the constant has no effect')]
|
||||
const FILE_TEXT = 0;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
||||
#[\Deprecated(since: '8.1', message: 'as the constant has no effect')]
|
||||
const FILE_BINARY = 0;
|
||||
|
||||
|
||||
2
ext/standard/file_arginfo.h
generated
2
ext/standard/file_arginfo.h
generated
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: dde0b40909dbadb565d898338834de7fa689c5e9 */
|
||||
* Stub hash: c394e14cd32587ce9ad0503e21c6c4cf5b301697 */
|
||||
|
||||
static void register_file_symbols(int module_number)
|
||||
{
|
||||
|
||||
@@ -2,13 +2,7 @@
|
||||
|
||||
/** @generate-class-entries */
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const PASSWORD_DEFAULT = "2y";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const PASSWORD_BCRYPT = "2y";
|
||||
/**
|
||||
* @var int
|
||||
@@ -17,17 +11,8 @@ const PASSWORD_BCRYPT = "2y";
|
||||
const PASSWORD_BCRYPT_DEFAULT_COST = UNKNOWN;
|
||||
|
||||
#ifdef HAVE_ARGON2LIB
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const PASSWORD_ARGON2I = "argon2i";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const PASSWORD_ARGON2ID = "argon2id";
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const PASSWORD_ARGON2_PROVIDER = "standard";
|
||||
/**
|
||||
* @var int
|
||||
|
||||
2
ext/standard/password_arginfo.h
generated
2
ext/standard/password_arginfo.h
generated
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: aab38646ace967e985c348b78251474693da95a7 */
|
||||
* Stub hash: f61df8d477588718e0eb1b055e5a3e138e6bcad3 */
|
||||
|
||||
static void register_password_symbols(int module_number)
|
||||
{
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
|
||||
/** @generate-class-entries */
|
||||
|
||||
/** @var int */
|
||||
const XSL_CLONE_AUTO = 0;
|
||||
/** @var int */
|
||||
const XSL_CLONE_NEVER = -1;
|
||||
/** @var int */
|
||||
const XSL_CLONE_ALWAYS = 1;
|
||||
|
||||
/**
|
||||
|
||||
2
ext/xsl/php_xsl_arginfo.h
generated
2
ext/xsl/php_xsl_arginfo.h
generated
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 5b4ce3f5f7dee60bde803b3c2eb3994777f56914 */
|
||||
* Stub hash: cb1005b601e72e8d36d0f6aa5d08872f5c7ea2e6 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_XSLTProcessor_importStylesheet, 0, 1, _IS_BOOL, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, stylesheet, IS_OBJECT, 0)
|
||||
|
||||
Reference in New Issue
Block a user