Skip to content
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
2 changes: 1 addition & 1 deletion resources/functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10421,7 +10421,7 @@
'SessionHandlerInterface::destroy' => ['bool', 'session_id'=>'string'],
'SessionHandlerInterface::gc' => ['int|false', 'maxlifetime'=>'int'],
'SessionHandlerInterface::open' => ['bool', 'save_path'=>'string', 'name'=>'string'],
'SessionHandlerInterface::read' => ['string', 'session_id'=>'string'],
'SessionHandlerInterface::read' => ['string|false', 'session_id'=>'string'],
'SessionHandlerInterface::write' => ['bool', 'session_id'=>'string', 'session_data'=>'string'],
'SessionIdInterface::create_sid' => ['string'],
'SessionUpdateTimestampHandler::updateTimestamp' => ['bool', 'id'=>'string', 'data'=>'string'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1006,4 +1006,9 @@ public function testBug12772(): void
$this->analyse([__DIR__ . '/data/bug-12772.php'], []);
}

public function testBug12748(): void
{
$this->analyse([__DIR__ . '/data/bug-12748.php'], []);
}

}
54 changes: 54 additions & 0 deletions tests/PHPStan/Rules/Comparison/data/bug-12748.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php declare(strict_types = 1); // lint >= 8.0

namespace Bug12748;

use SessionHandlerInterface;

class HelloWorld
{
public function getHandler(): SessionHandlerInterface
{
return new SessHandler;
}
}

class SessHandler implements SessionHandlerInterface
{

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

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

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

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

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

public function write(string $id, string $data): bool
{
return true;
}
}

$sessionHandler = (new HelloWorld)->getHandler();
$session = $sessionHandler->read('123');

if ($session === false) {
return null;
}
Loading