From 7a7984f248c0df59e4bd0d2abae9ff9067c1b23e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Tue, 29 Sep 2020 22:21:06 +0200 Subject: [PATCH 1/3] Review parameter names in ext/session --- ext/session/session.stub.php | 38 ++++++++++++++++++++++------------- ext/session/session_arginfo.h | 18 ++++++++--------- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/ext/session/session.stub.php b/ext/session/session.stub.php index 36a0b983b9f1c..c411d222d84dd 100644 --- a/ext/session/session.stub.php +++ b/ext/session/session.stub.php @@ -43,35 +43,45 @@ function session_commit(): bool {} * @param callable|object $open * @param callable|bool $close */ -function session_set_save_handler($open, $close = UNKNOWN, callable $read = UNKNOWN, callable $write = UNKNOWN, callable $destroy = UNKNOWN, callable $gc = UNKNOWN, callable $create_sid = UNKNOWN, callable $validate_sid = UNKNOWN, callable $update_timestamp = UNKNOWN): bool {} +function session_set_save_handler( + $open, + $close = UNKNOWN, + callable $read = UNKNOWN, + callable $write = UNKNOWN, + callable $destroy = UNKNOWN, + callable $gc = UNKNOWN, + callable $create_session_id = UNKNOWN, + callable $validate_session_id = UNKNOWN, + callable $update_timestamp = UNKNOWN +): bool {} function session_cache_limiter(?string $cache_limiter = null): string|false {} function session_cache_expire(?int $new_cache_expire = null): int|false {} -function session_set_cookie_params(array|int $lifetime_or_options, ?string $path = null, ?string $domain = null, ?bool $secure = null, ?bool $httponly = null): bool {} +function session_set_cookie_params(array|int $lifetime_or_options, ?string $path = null, ?string $domain = null, ?bool $secure = null, ?bool $httponly = null): bool {} function session_start(array $options = []): bool {} interface SessionHandlerInterface { /** @return bool */ - public function open(string $save_path, string $session_name); + public function open(string $path, string $name); /** @return bool */ public function close(); /** @return string */ - public function read(string $key); + public function read(string $id); /** @return bool */ - public function write(string $key, string $val); + public function write(string $id, string $value); /** @return bool */ - public function destroy(string $key); + public function destroy(string $id); /** @return int|bool */ - public function gc(int $maxlifetime); + public function gc(int $lifetime); } interface SessionIdInterface @@ -83,31 +93,31 @@ public function create_sid(); interface SessionUpdateTimestampHandlerInterface { /** @return bool */ - public function validateId(string $key); + public function validateId(string $id); /** @return bool */ - public function updateTimestamp(string $key, string $val); + public function updateTimestamp(string $id, string $value); } class SessionHandler implements SessionHandlerInterface, SessionIdInterface { /** @return bool */ - public function open(string $save_path, string $session_name) {} + public function open(string $path, string $name) {} /** @return bool */ public function close() {} /** @return string */ - public function read(string $key) {} + public function read(string $id) {} /** @return bool */ - public function write(string $key, string $val) {} + public function write(string $id, string $value) {} /** @return bool */ - public function destroy(string $key) {} + public function destroy(string $id) {} /** @return int|bool */ - public function gc(int $maxlifetime) {} + public function gc(int $lifetime) {} /** @return string */ public function create_sid() {} diff --git a/ext/session/session_arginfo.h b/ext/session/session_arginfo.h index f29a0df86b8e2..1fcaaa2e6de11 100644 --- a/ext/session/session_arginfo.h +++ b/ext/session/session_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 9bdf602c14822b13553a5214a415e312c21cd30c */ + * Stub hash: 4ae16a4aef8d9c89a7888b44ef300d6f658add78 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_name, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 1, "null") @@ -64,8 +64,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_session_set_save_handler, 0, 1, ZEND_ARG_TYPE_INFO(0, write, IS_CALLABLE, 0) ZEND_ARG_TYPE_INFO(0, destroy, IS_CALLABLE, 0) ZEND_ARG_TYPE_INFO(0, gc, IS_CALLABLE, 0) - ZEND_ARG_TYPE_INFO(0, create_sid, IS_CALLABLE, 0) - ZEND_ARG_TYPE_INFO(0, validate_sid, IS_CALLABLE, 0) + ZEND_ARG_TYPE_INFO(0, create_session_id, IS_CALLABLE, 0) + ZEND_ARG_TYPE_INFO(0, validate_session_id, IS_CALLABLE, 0) ZEND_ARG_TYPE_INFO(0, update_timestamp, IS_CALLABLE, 0) ZEND_END_ARG_INFO() @@ -90,26 +90,26 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_session_start, 0, 0, _IS_BOOL, 0 ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SessionHandlerInterface_open, 0, 0, 2) - ZEND_ARG_TYPE_INFO(0, save_path, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, session_name, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SessionHandlerInterface_close, 0, 0, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SessionHandlerInterface_read, 0, 0, 1) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, id, IS_STRING, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SessionHandlerInterface_write, 0, 0, 2) - ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, val, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, id, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) ZEND_END_ARG_INFO() #define arginfo_class_SessionHandlerInterface_destroy arginfo_class_SessionHandlerInterface_read ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SessionHandlerInterface_gc, 0, 0, 1) - ZEND_ARG_TYPE_INFO(0, maxlifetime, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, lifetime, IS_LONG, 0) ZEND_END_ARG_INFO() #define arginfo_class_SessionIdInterface_create_sid arginfo_class_SessionHandlerInterface_close From 79c1e922ae4864d851d128d853244e1459bd04eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 30 Sep 2020 10:26:32 +0200 Subject: [PATCH 2/3] Address a few review comments --- ext/session/session.stub.php | 12 ++++++------ ext/session/session_arginfo.h | 17 ++++++++++------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/ext/session/session.stub.php b/ext/session/session.stub.php index c411d222d84dd..0c6b215bda9cb 100644 --- a/ext/session/session.stub.php +++ b/ext/session/session.stub.php @@ -50,14 +50,14 @@ function session_set_save_handler( callable $write = UNKNOWN, callable $destroy = UNKNOWN, callable $gc = UNKNOWN, - callable $create_session_id = UNKNOWN, - callable $validate_session_id = UNKNOWN, + callable $create_sid = UNKNOWN, + callable $validate_sid = UNKNOWN, callable $update_timestamp = UNKNOWN ): bool {} -function session_cache_limiter(?string $cache_limiter = null): string|false {} +function session_cache_limiter(?string $value = null): string|false {} -function session_cache_expire(?int $new_cache_expire = null): int|false {} +function session_cache_expire(?int $value = null): int|false {} function session_set_cookie_params(array|int $lifetime_or_options, ?string $path = null, ?string $domain = null, ?bool $secure = null, ?bool $httponly = null): bool {} @@ -75,7 +75,7 @@ public function close(); public function read(string $id); /** @return bool */ - public function write(string $id, string $value); + public function write(string $id, string $data); /** @return bool */ public function destroy(string $id); @@ -111,7 +111,7 @@ public function close() {} public function read(string $id) {} /** @return bool */ - public function write(string $id, string $value) {} + public function write(string $id, string $data) {} /** @return bool */ public function destroy(string $id) {} diff --git a/ext/session/session_arginfo.h b/ext/session/session_arginfo.h index 1fcaaa2e6de11..b30d2a2f95e17 100644 --- a/ext/session/session_arginfo.h +++ b/ext/session/session_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 4ae16a4aef8d9c89a7888b44ef300d6f658add78 */ + * Stub hash: 8ac6478ae176b62a1d6d5bd25b6b6e50a85c657e */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_name, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 1, "null") @@ -64,17 +64,17 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_session_set_save_handler, 0, 1, ZEND_ARG_TYPE_INFO(0, write, IS_CALLABLE, 0) ZEND_ARG_TYPE_INFO(0, destroy, IS_CALLABLE, 0) ZEND_ARG_TYPE_INFO(0, gc, IS_CALLABLE, 0) - ZEND_ARG_TYPE_INFO(0, create_session_id, IS_CALLABLE, 0) - ZEND_ARG_TYPE_INFO(0, validate_session_id, IS_CALLABLE, 0) + ZEND_ARG_TYPE_INFO(0, create_sid, IS_CALLABLE, 0) + ZEND_ARG_TYPE_INFO(0, validate_sid, IS_CALLABLE, 0) ZEND_ARG_TYPE_INFO(0, update_timestamp, IS_CALLABLE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_cache_limiter, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, cache_limiter, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, value, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_cache_expire, 0, 0, MAY_BE_LONG|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, new_cache_expire, IS_LONG, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, value, IS_LONG, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_session_set_cookie_params, 0, 1, _IS_BOOL, 0) @@ -103,7 +103,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SessionHandlerInterface_write, 0, 0, 2) ZEND_ARG_TYPE_INFO(0, id, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_END_ARG_INFO() #define arginfo_class_SessionHandlerInterface_destroy arginfo_class_SessionHandlerInterface_read @@ -116,7 +116,10 @@ ZEND_END_ARG_INFO() #define arginfo_class_SessionUpdateTimestampHandlerInterface_validateId arginfo_class_SessionHandlerInterface_read -#define arginfo_class_SessionUpdateTimestampHandlerInterface_updateTimestamp arginfo_class_SessionHandlerInterface_write +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SessionUpdateTimestampHandlerInterface_updateTimestamp, 0, 0, 2) + ZEND_ARG_TYPE_INFO(0, id, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) +ZEND_END_ARG_INFO() #define arginfo_class_SessionHandler_open arginfo_class_SessionHandlerInterface_open From 2628d1ee8b3b0c50962915a8da8d1c6ec227b6ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1t=C3=A9=20Kocsis?= Date: Wed, 30 Sep 2020 12:12:23 +0200 Subject: [PATCH 3/3] Address comments --- ext/session/session.stub.php | 6 +++--- ext/session/session_arginfo.h | 9 +++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ext/session/session.stub.php b/ext/session/session.stub.php index 0c6b215bda9cb..d8c9b67e50a9e 100644 --- a/ext/session/session.stub.php +++ b/ext/session/session.stub.php @@ -81,7 +81,7 @@ public function write(string $id, string $data); public function destroy(string $id); /** @return int|bool */ - public function gc(int $lifetime); + public function gc(int $max_lifetime); } interface SessionIdInterface @@ -96,7 +96,7 @@ interface SessionUpdateTimestampHandlerInterface public function validateId(string $id); /** @return bool */ - public function updateTimestamp(string $id, string $value); + public function updateTimestamp(string $id, string $data); } class SessionHandler implements SessionHandlerInterface, SessionIdInterface @@ -117,7 +117,7 @@ public function write(string $id, string $data) {} public function destroy(string $id) {} /** @return int|bool */ - public function gc(int $lifetime) {} + public function gc(int $max_lifetime) {} /** @return string */ public function create_sid() {} diff --git a/ext/session/session_arginfo.h b/ext/session/session_arginfo.h index b30d2a2f95e17..0c82feabb2033 100644 --- a/ext/session/session_arginfo.h +++ b/ext/session/session_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 8ac6478ae176b62a1d6d5bd25b6b6e50a85c657e */ + * Stub hash: 8175feea632f2832e43d830e70dc9332377b9f22 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_session_name, 0, 0, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, name, IS_STRING, 1, "null") @@ -109,17 +109,14 @@ ZEND_END_ARG_INFO() #define arginfo_class_SessionHandlerInterface_destroy arginfo_class_SessionHandlerInterface_read ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SessionHandlerInterface_gc, 0, 0, 1) - ZEND_ARG_TYPE_INFO(0, lifetime, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, max_lifetime, IS_LONG, 0) ZEND_END_ARG_INFO() #define arginfo_class_SessionIdInterface_create_sid arginfo_class_SessionHandlerInterface_close #define arginfo_class_SessionUpdateTimestampHandlerInterface_validateId arginfo_class_SessionHandlerInterface_read -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SessionUpdateTimestampHandlerInterface_updateTimestamp, 0, 0, 2) - ZEND_ARG_TYPE_INFO(0, id, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) -ZEND_END_ARG_INFO() +#define arginfo_class_SessionUpdateTimestampHandlerInterface_updateTimestamp arginfo_class_SessionHandlerInterface_write #define arginfo_class_SessionHandler_open arginfo_class_SessionHandlerInterface_open