Skip to content

Review parameter names in ext/session #6239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions ext/session/session.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_sid = UNKNOWN,
callable $validate_sid = UNKNOWN,
callable $update_timestamp = UNKNOWN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are called create_sid(), validateId() and updateTimestamp() in the SessionHandler interface -- yes, complete with inconsistent name casing. I was going to suggest that we should match those names here, but given the casing issue I'm not sure.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea here either. I can revert to using the original names here until we decide it.

): 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 {}
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 $data);

/** @return bool */
public function destroy(string $key);
public function destroy(string $id);

/** @return int|bool */
public function gc(int $maxlifetime);
public function gc(int $max_lifetime);
}

interface SessionIdInterface
Expand All @@ -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 $data);
}

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 $data) {}

/** @return bool */
public function destroy(string $key) {}
public function destroy(string $id) {}

/** @return int|bool */
public function gc(int $maxlifetime) {}
public function gc(int $max_lifetime) {}

/** @return string */
public function create_sid() {}
Expand Down
18 changes: 9 additions & 9 deletions ext/session/session_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 9bdf602c14822b13553a5214a415e312c21cd30c */
* 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")
Expand Down Expand Up @@ -70,11 +70,11 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_session_set_save_handler, 0, 1,
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)
Expand All @@ -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, data, 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, max_lifetime, IS_LONG, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_SessionIdInterface_create_sid arginfo_class_SessionHandlerInterface_close
Expand Down