1--TEST-- 2Test session_set_save_handler() : incorrect arguments for existing handler close 3--INI-- 4session.save_handler=files 5session.name=PHPSESSID 6--EXTENSIONS-- 7session 8--SKIPIF-- 9<?php include('skipif.inc'); ?> 10--FILE-- 11<?php 12 13ob_start(); 14 15echo "*** Testing session_set_save_handler() : incorrect arguments for existing handler close ***\n"; 16 17class MySession extends SessionHandler { 18 public $i = 0; 19 public function open($path, $name): bool { 20 ++$this->i; 21 echo 'Open ', session_id(), "\n"; 22 return parent::open($path, $name); 23 } 24 public function read($key): string|false { 25 ++$this->i; 26 echo 'Read ', session_id(), "\n"; 27 return parent::read($key); 28 } 29 public function close(): bool { 30 return parent::close(false); 31 } 32} 33 34$oldHandler = ini_get('session.save_handler'); 35$handler = new MySession; 36session_set_save_handler($handler); 37session_start(); 38 39var_dump(session_id(), $oldHandler, ini_get('session.save_handler'), $handler->i, $_SESSION); 40?> 41--EXPECTF-- 42*** Testing session_set_save_handler() : incorrect arguments for existing handler close *** 43Open 44Read %s 45string(%d) "%s" 46string(5) "files" 47string(4) "user" 48int(2) 49array(0) { 50} 51 52Fatal error: Uncaught ArgumentCountError: SessionHandler::close() expects exactly 0 arguments, 1 given in %s:%d 53Stack trace: 54#0 %s(%d): SessionHandler->close(false) 55#1 [internal function]: MySession->close() 56#2 [internal function]: session_write_close() 57#3 {main} 58 thrown in %s on line %d 59