SF.net SVN: phpwiki:[11055] trunk/lib/DbSession

vargenau--- via phpwiki-checkins <[email protected]> Fri, 14 Jul 2023 11:23:15 +0000
Newsgroups gmane.comp.web.wiki.phpwiki.checkins
Message-ID <[email protected]>
Revision: 11055
          http://sourceforge.net/p/phpwiki/code/11055
Author:   vargenau
Date:     2023-07-14 11:23:14 +0000 (Fri, 14 Jul 2023)
Log Message:
-----------
lib/DbSession: PHP 7: add types for function arguments and return

Modified Paths:
--------------
    trunk/lib/DbSession/PDO.php
    trunk/lib/DbSession/SQL.php
    trunk/lib/DbSession/dba.php

Modified: trunk/lib/DbSession/PDO.php
===================================================================
--- trunk/lib/DbSession/PDO.php	2023-07-14 11:16:48 UTC (rev 11054)
+++ trunk/lib/DbSession/PDO.php	2023-07-14 11:23:14 UTC (rev 11055)
@@ -30,7 +30,7 @@
 
 class DbSession_PDO extends DbSession
 {
-    public $_backend_type = "PDO";
+    public string $_backend_type = "PDO";
 
     public function __construct($dbh, $table)
     {
@@ -84,7 +84,7 @@
      * @return boolean true just a variable to notify PHP that everything
      * is good.
      */
-    public function open($save_path, $session_name)
+    public function open(string $save_path, string $session_name): bool
     {
         //$this->log("_open($save_path, $session_name)");
         return true;
@@ -98,7 +98,7 @@
      * @return boolean true just a variable to notify PHP that everything
      * is good.
      */
-    public function close()
+    public function close(): bool
     {
         //$this->log("_close()");
         return true;
@@ -110,7 +110,7 @@
      * @param  string $id an id of current session
      * @return string
      */
-    public function read($id)
+    public function read(string $id): string
     {
         $dbh = $this->_connect();
         $table = $this->_table;
@@ -148,7 +148,7 @@
      * @return boolean true if data saved successfully  and false
      * otherwise.
      */
-    public function write($id, $sess_data)
+    public function write(string $id, string $sess_data): bool
     {
         /**
          * @var WikiRequest $request
@@ -192,7 +192,7 @@
      * @param  string  $id
      * @return boolean true
      */
-    public function destroy($id)
+    public function destroy(string $id): bool
     {
         $table = $this->_table;
         $dbh = $this->_connect();
@@ -209,7 +209,7 @@
      * @param  int     $maxlifetime session's time to live.
      * @return boolean true
      */
-    public function gc($maxlifetime)
+    public function gc(int $maxlifetime): bool
     {
         $table = $this->_table;
         $threshold = time() - $maxlifetime;
@@ -223,7 +223,7 @@
 
     // WhoIsOnline support
     // TODO: ip-accesstime dynamic blocking API
-    public function currentSessions()
+    public function currentSessions(): array
     {
         $sessions = array();
         $table = $this->_table;

Modified: trunk/lib/DbSession/SQL.php
===================================================================
--- trunk/lib/DbSession/SQL.php	2023-07-14 11:16:48 UTC (rev 11054)
+++ trunk/lib/DbSession/SQL.php	2023-07-14 11:23:14 UTC (rev 11055)
@@ -34,7 +34,7 @@
 
 class DbSession_SQL extends DbSession
 {
-    public $_backend_type = "SQL";
+    public string $_backend_type = "SQL";
 
     public function __construct($dbh, $table)
     {
@@ -91,7 +91,7 @@
      * @return boolean true just a variable to notify PHP that everything
      * is good.
      */
-    public function open($save_path, $session_name)
+    public function open(string $save_path, string $session_name): bool
     {
         //$this->log("_open($save_path, $session_name)");
         return true;
@@ -105,7 +105,7 @@
      * @return boolean true just a variable to notify PHP that everything
      * is good.
      */
-    public function close()
+    public function close(): bool
     {
         //$this->log("_close()");
         return true;
@@ -117,7 +117,7 @@
      * @param  string $id an id of current session
      * @return string
      */
-    public function read($id)
+    public function read(string $id): string
     {
         //$this->log("_read($id)");
         $dbh = $this->_connect();
@@ -159,7 +159,7 @@
      * @return boolean true if data saved successfully  and false
      * otherwise.
      */
-    public function write($id, $sess_data)
+    public function write(string $id, string $sess_data): bool
     {
         /**
          * @var WikiRequest $request
@@ -200,7 +200,7 @@
      * @param  string  $id
      * @return boolean true
      */
-    public function destroy($id)
+    public function destroy(string $id): bool
     {
         $dbh = $this->_connect();
         $table = $this->_table;
@@ -218,7 +218,7 @@
      * @param  int     $maxlifetime session's time to live.
      * @return boolean true
      */
-    public function gc($maxlifetime)
+    public function gc(int $maxlifetime): bool
     {
         $dbh = $this->_connect();
         $table = $this->_table;
@@ -232,7 +232,7 @@
 
     // WhoIsOnline support
     // TODO: ip-accesstime dynamic blocking API
-    public function currentSessions()
+    public function currentSessions(): array
     {
         $sessions = array();
         $dbh = $this->_connect();

Modified: trunk/lib/DbSession/dba.php
===================================================================
--- trunk/lib/DbSession/dba.php	2023-07-14 11:16:48 UTC (rev 11054)
+++ trunk/lib/DbSession/dba.php	2023-07-14 11:23:14 UTC (rev 11055)
@@ -26,7 +26,7 @@
  *  session:
  *     Index: session_id
  *     Values: date : IP : data
- *  Already open sessions, e.g. interim xmlrpc requests are
+ *  Already open sessions, e.g. interim xmlrpc requests
  *  are treated specially. see write().
  *  To avoid deadlocks in the session.db3 access,
  *  the db is opened and closed for each access.
@@ -35,7 +35,7 @@
 
 class DbSession_dba extends DbSession
 {
-    public $_backend_type = "dba";
+    public string $_backend_type = "dba";
 
     public function __construct($dbh, $table)
     {
@@ -55,7 +55,7 @@
         return $string;
     }
 
-    public function query($sql)
+    public function query($sql): bool
     {
         return false;
     }
@@ -94,7 +94,7 @@
      * @return boolean true just a variable to notify PHP that everything
      * is good.
      */
-    public function open($save_path, $session_name)
+    public function open(string $save_path, string $session_name): bool
     {
         $dbh = $this->_connect();
         $dbh->open();
@@ -109,7 +109,7 @@
      * @return boolean true just a variable to notify PHP that everything
      * is good.
      */
-    public function close()
+    public function close(): bool
     {
         $this->_disconnect();
         return true;
@@ -121,7 +121,7 @@
      * @param  string $id an id of current session
      * @return string
      */
-    public function read($id)
+    public function read(string $id): string
     {
         $dbh = $this->_connect();
         $result = $dbh->get($id);
@@ -153,7 +153,7 @@
      * @return boolean true if data saved successfully  and false
      * otherwise.
      */
-    public function write($id, $sess_data)
+    public function write(string $id, string $sess_data): bool
     {
         /**
          * @var WikiRequest $request
@@ -176,7 +176,7 @@
         return true;
     }
 
-    public function destroy($id)
+    public function destroy($id): bool
     {
         $dbh = $this->_connect();
         $dbh->delete($id);
@@ -190,7 +190,7 @@
      * @param  int     $maxlifetime session's time to live.
      * @return boolean true
      */
-    public function gc($maxlifetime)
+    public function gc(int $maxlifetime): bool
     {
         $dbh = $this->_connect();
         $threshold = time() - $maxlifetime;
@@ -209,7 +209,7 @@
 
     // WhoIsOnline support
     // TODO: ip-accesstime dynamic blocking API
-    public function currentSessions()
+    public function currentSessions(): array
     {
         $sessions = array();
         $dbh = $this->_connect();

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.