Req #72285 [NEW]: SessionHandlerInterface Function Signatures

From: Date: Mon, 30 May 2016 00:24:37 +0000
Subject: Req #72285 [NEW]: SessionHandlerInterface Function Signatures
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201327@lists.php.net to get a copy of this message
From:             hpdl at oscommerce dot com
Operating system: WIN10
PHP version:      7.0.7
Package:          Session related
Bug Type:         Feature/Change Request
Bug description:SessionHandlerInterface Function Signatures

Description:
------------
The documentation for the following functions include parameter type
declarations:

SessionHandler::open(string $save_path, string $session_name)
SessionHandler::read(string $session_id)
SessionHandler::write(string $session_id, string $session_data)
SessionHandler::destroy(string $session_id)
SessionHandler::gc(int $maxlifetime)

http://php.net/manual/en/class.sessionhandler.php

however using the same type declarations in the session handler class
returns a PHP fatal error.

Also tested with PHP 7.1.0-dev rc3495d5 with the same result.

Test script:
---------------
<?php
class SessionTest implements \SessionHandlerInterface
{
    public function __construct()
    {
        session_set_save_handler($this, true);
    }

    public function open(string $save_path, string $name): bool
    {
        return true;
    }

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

    public function read(string $session_id): string
    {
        return '';
    }

    public function write(string $session_id, string $session_data):
bool
    {
        return true;
    }

    public function destroy(string $session_id): bool
    {
        return true;
    }

    public function gc(int $maxlifetime): bool
    {
        return true;
    }
}

$SessionTest = new SessionTest();


Expected result:
----------------
No error should be expected.

Actual result:
--------------
Fatal error: Declaration of SessionTest::open(string $save_path, string
$name): bool must be compatible with
SessionHandlerInterface::open($save_path, $session_name) in
C:\SessionTest.php on line 2

Fatal error: Declaration of SessionTest::read(string $session_id):
string must be compatible with SessionHandlerInterface::read($key) in
C:\SessionTest.php on line 2

Fatal error: Declaration of SessionTest::write(string $session_id,
string $session_data): bool must be compatible with
SessionHandlerInterface::write($key, $val) in C:\SessionTest.php on line
2

Fatal error: Declaration of SessionTest::destroy(string $session_id):
bool must be compatible with SessionHandlerInterface::destroy($key) in
C:\SessionTest.php on line 2

Fatal error: Declaration of SessionTest::gc(int $maxlifetime): bool must
be compatible with SessionHandlerInterface::gc($maxlifetime) in
C:\SessionTest.php on line 2

-- 
Edit bug report at https://bugs.php.net/bug.php?id=72285&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=72285&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=72285&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=72285&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=72285&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=72285&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=72285&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=72285&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=72285&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=72285&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=72285&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=72285&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=72285&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=72285&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72285&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=72285&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=72285&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=72285&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72285&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=72285&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=72285&r=mysqlcfg



Thread (6 messages)

« previous php.bugs (#201327) next »