Skip to content
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

Add more specific return type of session_status #10861

Open
wants to merge 2 commits into
base: 5.x
Choose a base branch
from

Conversation

jorgsowa
Copy link
Contributor

Return value of this function may be only one of 3 session status constants.

@weirdan
Copy link
Collaborator

weirdan commented Mar 25, 2024

I don't think constants are supported in callmaps.

@jorgsowa
Copy link
Contributor Author

@weirdan could they be supported? I can look into this if this would be helpful

@weirdan
Copy link
Collaborator

weirdan commented Mar 26, 2024

You can put constant values there.

@@ -11121,7 +11121,7 @@
'session_set_save_handler' => ['bool', 'open'=>'callable(string,string):bool', 'close'=>'callable():bool', 'read'=>'callable(string):string', 'write'=>'callable(string,string):bool', 'destroy'=>'callable(string):bool', 'gc'=>'callable(string):bool', 'create_sid='=>'callable():string', 'validate_sid='=>'callable(string):bool', 'update_timestamp='=>'callable(string):bool'],
'session_set_save_handler\'1' => ['bool', 'open'=>'SessionHandlerInterface', 'close='=>'bool'],
'session_start' => ['bool', 'options='=>'array'],
'session_status' => ['int'],
'session_status' => ['PHP_SESSION_ACTIVE|PHP_SESSION_NONE|PHP_SESSION_ACTIVE'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
'session_status' => ['PHP_SESSION_ACTIVE|PHP_SESSION_NONE|PHP_SESSION_ACTIVE'],
'session_status' => ['1|2'],

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also you had a duplicate there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took a different approach. Hope it works.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's clever, but I would prefer values though. Many of the constants in PHP are not really constants - e.g. PHP_BINARY, PHP_INT_SIZE, PASSWORD_DEFAULT, etc. Using constants in the callmap the way you did establishes an unsafe example for future contributors / maintainers who may not be necessarily aware of those details.

@@ -13860,7 +13860,7 @@
'session_set_save_handler' => ['bool', 'open'=>'callable(string,string):bool', 'close'=>'callable():bool', 'read'=>'callable(string):string', 'write'=>'callable(string,string):bool', 'destroy'=>'callable(string):bool', 'gc'=>'callable(string):bool', 'create_sid='=>'callable():string', 'validate_sid='=>'callable(string):bool', 'update_timestamp='=>'callable(string):bool'],
'session_set_save_handler\'1' => ['bool', 'open'=>'SessionHandlerInterface', 'close='=>'bool'],
'session_start' => ['bool', 'options='=>'array'],
'session_status' => ['int'],
'session_status' => ['PHP_SESSION_ACTIVE|PHP_SESSION_NONE|PHP_SESSION_ACTIVE'],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
'session_status' => ['PHP_SESSION_ACTIVE|PHP_SESSION_NONE|PHP_SESSION_ACTIVE'],
'session_status' => ['1|2'],

@jorgsowa jorgsowa requested a review from weirdan March 26, 2024 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants