diff --git a/ext/standard/basic_functions.stub.php b/ext/standard/basic_functions.stub.php index 540d88722c15c..5b74437dcff5a 100755 --- a/ext/standard/basic_functions.stub.php +++ b/ext/standard/basic_functions.stub.php @@ -2055,6 +2055,8 @@ function memory_get_peak_usage(bool $real_usage = false): int {} function memory_reset_peak_usage(): void {} +function memory_get_limit(): int {} + /* versioning.c */ /** @compile-time-eval */ diff --git a/ext/standard/basic_functions_arginfo.h b/ext/standard/basic_functions_arginfo.h index 8b573cbe2dff3..e4ec194781dc6 100644 --- a/ext/standard/basic_functions_arginfo.h +++ b/ext/standard/basic_functions_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: b1c51fabe59bba6706500365f3eb7d9676d625f6 */ + * Stub hash: 25a11b60d96565e1419d249fec98c041300ecece */ 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) @@ -2177,6 +2177,8 @@ ZEND_END_ARG_INFO() #define arginfo_memory_reset_peak_usage arginfo_flush +#define arginfo_memory_get_limit arginfo_ob_get_level + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_version_compare, 0, 2, MAY_BE_LONG|MAY_BE_BOOL) ZEND_ARG_TYPE_INFO(0, version1, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, version2, IS_STRING, 0) @@ -2827,6 +2829,7 @@ ZEND_FUNCTION(unserialize); ZEND_FUNCTION(memory_get_usage); ZEND_FUNCTION(memory_get_peak_usage); ZEND_FUNCTION(memory_reset_peak_usage); +ZEND_FUNCTION(memory_get_limit); ZEND_FUNCTION(version_compare); #if defined(PHP_WIN32) ZEND_FUNCTION(sapi_windows_cp_set); @@ -3483,6 +3486,7 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(memory_get_usage, arginfo_memory_get_usage) ZEND_FE(memory_get_peak_usage, arginfo_memory_get_peak_usage) ZEND_FE(memory_reset_peak_usage, arginfo_memory_reset_peak_usage) + ZEND_FE(memory_get_limit, arginfo_memory_get_limit) ZEND_SUPPORTS_COMPILE_TIME_EVAL_FE(version_compare, arginfo_version_compare) #if defined(PHP_WIN32) ZEND_FE(sapi_windows_cp_set, arginfo_sapi_windows_cp_set) diff --git a/ext/standard/tests/memory_get_limit.phpt b/ext/standard/tests/memory_get_limit.phpt new file mode 100644 index 0000000000000..205825576e436 --- /dev/null +++ b/ext/standard/tests/memory_get_limit.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test memory_get_limit +--INI-- +memory_limit=10M +--FILE-- + +--EXPECTF-- +int(10485760) +int(20971520) +int(1073741824) +int(-1) + +Warning: Failed to set memory limit to 0 bytes (Current memory usage is %d bytes) in %s on line %d +int(-1) diff --git a/ext/standard/var.c b/ext/standard/var.c index dc9f8639b146f..2b55864fe0846 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -1486,6 +1486,12 @@ PHP_FUNCTION(memory_reset_peak_usage) { } /* }}} */ +PHP_FUNCTION(memory_get_limit) { + ZEND_PARSE_PARAMETERS_NONE(); + + RETURN_LONG(PG(memory_limit)); +} + PHP_INI_BEGIN() STD_PHP_INI_ENTRY("unserialize_max_depth", "4096", PHP_INI_ALL, OnUpdateLong, unserialize_max_depth, php_basic_globals, basic_globals) PHP_INI_END()