Support passing a single array to Context::gets()

This commit is contained in:
Kijin Sung 2025-06-03 15:27:21 +09:00
parent 202c0172b3
commit 0e5797882f

View file

@ -2024,17 +2024,20 @@ class Context
/** /**
* Get one more vars in object vars with given arguments(key1, key2, key3,...) * Get one more vars in object vars with given arguments(key1, key2, key3,...)
* *
* @return object * @return ?object
*/ */
public static function gets() public static function gets()
{ {
$num_args = func_num_args(); $args_list = func_get_args();
if($num_args < 1) if (count($args_list) < 1)
{ {
return; return;
} }
if (count($args_list) === 1 && is_array($args_list[0]))
{
$args_list = $args_list[0];
}
$args_list = func_get_args();
$output = new stdClass; $output = new stdClass;
self::$_user_vars = self::$_user_vars !== null ? self::$_user_vars : new stdClass; self::$_user_vars = self::$_user_vars !== null ? self::$_user_vars : new stdClass;
foreach($args_list as $key) foreach($args_list as $key)