Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Declare tentative return types for ext/session #7005

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

Merged
merged 1 commit into from
May 28, 2021
Merged
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
64 changes: 32 additions & 32 deletions 64 ext/session/session.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,60 +65,60 @@ function session_start(array $options = []): bool {}

interface SessionHandlerInterface
{
/** @return bool */
public function open(string $path, string $name);
/** @tentative-return-type */
public function open(string $path, string $name): bool;

/** @return bool */
public function close();
/** @tentative-return-type */
public function close(): bool;

/** @return string|false */
public function read(string $id);
/** @tentative-return-type */
public function read(string $id): string|false;

/** @return bool */
public function write(string $id, string $data);
/** @tentative-return-type */
public function write(string $id, string $data): bool;

/** @return bool */
public function destroy(string $id);
/** @tentative-return-type */
public function destroy(string $id): bool;

/** @return int|false */
public function gc(int $max_lifetime);
/** @tentative-return-type */
public function gc(int $max_lifetime): int|false;
}

interface SessionIdInterface
{
/** @return string */
public function create_sid();
/** @tentative-return-type */
public function create_sid(): string;
}

interface SessionUpdateTimestampHandlerInterface
{
/** @return bool */
public function validateId(string $id);
/** @tentative-return-type */
public function validateId(string $id): bool;

/** @return bool */
public function updateTimestamp(string $id, string $data);
/** @tentative-return-type */
public function updateTimestamp(string $id, string $data): bool;
}

class SessionHandler implements SessionHandlerInterface, SessionIdInterface
{
/** @return bool */
public function open(string $path, string $name) {}
/** @tentative-return-type */
public function open(string $path, string $name): bool {}

/** @return bool */
public function close() {}
/** @tentative-return-type */
public function close(): bool {}

/** @return string|false */
public function read(string $id) {}
/** @tentative-return-type */
public function read(string $id): string|false {}

/** @return bool */
public function write(string $id, string $data) {}
/** @tentative-return-type */
public function write(string $id, string $data): bool {}

/** @return bool */
public function destroy(string $id) {}
/** @tentative-return-type */
public function destroy(string $id): bool {}

/** @return int|false */
public function gc(int $max_lifetime) {}
/** @tentative-return-type */
public function gc(int $max_lifetime): int|false {}

/** @return string */
public function create_sid() {}
/** @tentative-return-type */
public function create_sid(): string {}
}
25 changes: 14 additions & 11 deletions 25 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: f7f6a3d0357da86516b42fcd5cc2e618aa0049b8 */
* Stub hash: 6838259167ac6edd5a4f6adec9fddf838f301337 */

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 @@ -89,32 +89,35 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_session_start, 0, 0, _IS_BOOL, 0
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SessionHandlerInterface_open, 0, 0, 2)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SessionHandlerInterface_open, 0, 2, _IS_BOOL, 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_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SessionHandlerInterface_close, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SessionHandlerInterface_read, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_SessionHandlerInterface_read, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
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_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SessionHandlerInterface_write, 0, 2, _IS_BOOL, 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_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SessionHandlerInterface_destroy, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, id, IS_STRING, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SessionHandlerInterface_gc, 0, 0, 1)
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_MASK_EX(arginfo_class_SessionHandlerInterface_gc, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, max_lifetime, IS_LONG, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_SessionIdInterface_create_sid arginfo_class_SessionHandlerInterface_close
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_SessionIdInterface_create_sid, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_SessionUpdateTimestampHandlerInterface_validateId arginfo_class_SessionHandlerInterface_read
#define arginfo_class_SessionUpdateTimestampHandlerInterface_validateId arginfo_class_SessionHandlerInterface_destroy

#define arginfo_class_SessionUpdateTimestampHandlerInterface_updateTimestamp arginfo_class_SessionHandlerInterface_write

Expand All @@ -126,11 +129,11 @@ ZEND_END_ARG_INFO()

#define arginfo_class_SessionHandler_write arginfo_class_SessionHandlerInterface_write

#define arginfo_class_SessionHandler_destroy arginfo_class_SessionHandlerInterface_read
#define arginfo_class_SessionHandler_destroy arginfo_class_SessionHandlerInterface_destroy

#define arginfo_class_SessionHandler_gc arginfo_class_SessionHandlerInterface_gc

#define arginfo_class_SessionHandler_create_sid arginfo_class_SessionHandlerInterface_close
#define arginfo_class_SessionHandler_create_sid arginfo_class_SessionIdInterface_create_sid


ZEND_FUNCTION(session_name);
Expand Down
10 changes: 5 additions & 5 deletions 10 ext/session/tests/004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,29 @@ ob_start();

class handler {
public $data = 'baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}';
function open($save_path, $session_name)
function open($save_path, $session_name): bool
{
print "OPEN: $session_name\n";
return true;
}
function close()
function close(): bool
{
return true;
}
function read($key)
function read($key): string|false
{
print "READ: $key\n";
return $GLOBALS["hnd"]->data;
}

function write($key, $val)
function write($key, $val): bool
{
print "WRITE: $key, $val\n";
$GLOBALS["hnd"]->data = $val;
return true;
}

function destroy($key)
function destroy($key): bool
{
print "DESTROY: $key\n";
return true;
Expand Down
10 changes: 5 additions & 5 deletions 10 ext/session/tests/005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@ ob_start();

class handler {
public $data = 'baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}';
function open($save_path, $session_name)
function open($save_path, $session_name): bool
{
print "OPEN: $session_name\n";
return true;
}
function close()
function close(): bool
{
print "CLOSE\n";
return true;
}
function read($key)
function read($key): string|false
{
print "READ: $key\n";
return $GLOBALS["hnd"]->data;
}

function write($key, $val)
function write($key, $val): bool
{
print "WRITE: $key, $val\n";
$GLOBALS["hnd"]->data = $val;
return true;
}

function destroy($key)
function destroy($key): bool
{
print "DESTROY: $key\n";
return true;
Expand Down
10 changes: 5 additions & 5 deletions 10 ext/session/tests/024.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ ob_start();
class handler {
public $data = 'baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}';

function open($save_path, $session_name)
function open($save_path, $session_name): bool
{
print "OPEN: $session_name\n";
return true;
}
function close()
function close(): bool
{
return true;
}
function read($key)
function read($key): string|false
{
print "READ: $key\n";
return $GLOBALS["hnd"]->data;
}

function write($key, $val)
function write($key, $val): bool
{
print "WRITE: $key, $val\n";
$GLOBALS["hnd"]->data = $val;
return true;
}

function destroy($key)
function destroy($key): bool
{
print "DESTROY: $key\n";
return true;
Expand Down
10 changes: 5 additions & 5 deletions 10 ext/session/tests/025.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@ ob_start();
class handler {
public $data = 'baz|O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}arr|a:1:{i:3;O:3:"foo":2:{s:3:"bar";s:2:"ok";s:3:"yes";i:1;}}';

function open($save_path, $session_name)
function open($save_path, $session_name): bool
{
print "OPEN: $session_name\n";
return true;
}
function close()
function close(): bool
{
print "CLOSE\n";
return true;
}
function read($key)
function read($key): string|false
{
print "READ: $key\n";
return $GLOBALS["hnd"]->data;
}

function write($key, $val)
function write($key, $val): bool
{
print "WRITE: $key, $val\n";
$GLOBALS["hnd"]->data = $val;
return true;
}

function destroy($key)
function destroy($key): bool
{
print "DESTROY: $key\n";
return true;
Expand Down
2 changes: 1 addition & 1 deletion 2 ext/session/tests/bug60634_error_3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function write($id, $session_data) {
undefined_function();
}

function destroy($id) {
function destroy($id): bool {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion 2 ext/session/tests/bug70133.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ session.use_strict_mode=0

class CustomReadHandler extends \SessionHandler {

public function read($session_id) {
public function read($session_id): string|false {
return parent::read('mycustomsession');
}
}
Expand Down
18 changes: 9 additions & 9 deletions 18 ext/session/tests/bug71162.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,40 @@ Current session module is designed to write empty session always. In addition, c
<?php
class MySessionHandler extends SessionHandler implements SessionUpdateTimestampHandlerInterface
{
public function open($path, $sessname) {
public function open($path, $sessname): bool {
return TRUE;
}

public function close() {
public function close(): bool {
return TRUE;
}

public function read($sessid) {
public function read($sessid): string|false {
return '';
}

public function write($sessid, $sessdata) {
public function write($sessid, $sessdata): bool {
echo __FUNCTION__, PHP_EOL;
return TRUE;
}

public function destroy($sessid) {
public function destroy($sessid): bool {
return TRUE;
}

public function gc($maxlifetime) {
public function gc($maxlifetime): int|false {
return TRUE;
}

public function create_sid() {
public function create_sid(): string {
return sha1(random_bytes(32));
}

public function validateId($sid) {
public function validateId($sid): bool {
return TRUE;
}

public function updateTimestamp($sessid, $sessdata) {
public function updateTimestamp($sessid, $sessdata): bool {
echo __FUNCTION__, PHP_EOL;
return TRUE;
}
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.