]> git.andy128k.dev Git - ipf-legacy-orm.git/commitdiff
Fix warnings
authorAndrey Kutejko <andy128k@gmail.com>
Thu, 18 Aug 2022 21:40:47 +0000 (23:40 +0200)
committerAndrey Kutejko <andy128k@gmail.com>
Thu, 18 Aug 2022 23:43:28 +0000 (01:43 +0200)
src/orm/access.php
src/orm/collection.php
src/orm/connection.php
src/orm/connection/statement.php
src/orm/query.php
src/orm/record.php
src/orm/relation.php
src/orm/table.php
src/orm/table/repository.php

index d0a87d2fe26c716fd007b476acd7ffb1cbb2dd02..e96100645d042ea6039d62f13aa7427541e70059 100644 (file)
@@ -31,17 +31,17 @@ abstract class IPF_ORM_Access implements ArrayAccess
         return $this->remove($name);
     }
 
-    public function offsetExists($offset)
+    public function offsetExists($offset): bool
     {
         return $this->contains($offset);
     }
 
-    public function offsetGet($offset)
+    public function offsetGet($offset): mixed
     {
         return $this->get($offset);
     }
 
-    public function offsetSet($offset, $value)
+    public function offsetSet($offset, $value): void
     {
         if ( ! isset($offset)) {
             $this->add($value);
@@ -50,9 +50,9 @@ abstract class IPF_ORM_Access implements ArrayAccess
         }
     }
 
-    public function offsetUnset($offset)
+    public function offsetUnset($offset): void
     {
-        return $this->remove($offset);
+        $this->remove($offset);
     }
 
     public function remove($offset)
index 9bf5e52f812ef8bef0113341f3ca302d49595f98..2d06559bc180e3c1e3c5cab6e8cb98fe24ba4023 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-class IPF_ORM_Collection extends IPF_ORM_Access implements Countable, IteratorAggregate, Serializable
+class IPF_ORM_Collection extends IPF_ORM_Access implements Countable, IteratorAggregate
 {
     protected $data = array();
     protected $_table;
@@ -41,7 +41,7 @@ class IPF_ORM_Collection extends IPF_ORM_Access implements Countable, IteratorAg
         $this->data = $data;
     }
 
-    public function serialize()
+    public function __serialize(): array
     {
         $vars = get_object_vars($this);
 
@@ -54,22 +54,20 @@ class IPF_ORM_Collection extends IPF_ORM_Access implements Countable, IteratorAg
 
         $vars['_table'] = $vars['_table']->getComponentName();
 
-        return serialize($vars);
+        return $vars;
     }
 
-    public function unserialize($serialized)
+    public function __unserialize(array $serialized): void
     {
         $connection = IPF_ORM_Manager::connection();
 
-        $array = unserialize($serialized);
-
-        foreach ($array as $name => $values) {
+        foreach ($serialized as $name => $values) {
             $this->$name = $values;
         }
 
         $this->_table = $connection->getTable($this->_table);
 
-        $keyColumn = isset($array['keyColumn']) ? $array['keyColumn'] : null;
+        $keyColumn = isset($serialized['keyColumn']) ? $serialized['keyColumn'] : null;
         if ($keyColumn === null) {
             $keyColumn = $this->_table->getBoundQueryPart('indexBy');
         }
@@ -213,7 +211,7 @@ class IPF_ORM_Collection extends IPF_ORM_Access implements Countable, IteratorAg
         return array_keys($this->data);
     }
 
-    public function count()
+    public function count(): int
     {
         return count($this->data);
     }
@@ -529,7 +527,7 @@ class IPF_ORM_Collection extends IPF_ORM_Access implements Countable, IteratorAg
         }
     }
 
-    public function getIterator()
+    public function getIterator(): Traversable
     {
         $data = $this->data;
         return new ArrayIterator($data);
index 7fddf02bd7a0d98c1baf9f389756c1ee70249532..4fb10273241ef410ed898eb3c004f1f268a63806 100644 (file)
@@ -505,12 +505,12 @@ abstract class IPF_ORM_Connection extends IPF_ORM_Configurable implements Counta
         return $this->tables;
     }
 
-    public function getIterator()
+    public function getIterator(): Traversable
     {
         return new ArrayIterator($this->tables);
     }
 
-    public function count()
+    public function count(): int
     {
         return $this->_count;
     }
index cfea7cc749bdfa189a0498cc69cb63da5ffad465..d0c9f54b6bd6e3de75078c9b05772e0a9d1c0edd 100644 (file)
@@ -100,7 +100,7 @@ class IPF_ORM_Connection_Statement
 
     public function fetch($fetchMode = IPF_ORM::FETCH_BOTH,
                           $cursorOrientation = IPF_ORM::FETCH_ORI_NEXT,
-                          $cursorOffset = null)
+                          $cursorOffset = 0)
     {
         $event = new IPF_ORM_Event($this, IPF_ORM_Event::STMT_FETCH, $this->getQuery());
 
index 1830c334ef53a39cb232fa8866c6021aab9c560e..d269bbfa87f14b56895e8b2507c21fd891b41d89 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-class IPF_ORM_Query extends IPF_ORM_Query_Abstract implements Countable, Serializable
+class IPF_ORM_Query extends IPF_ORM_Query_Abstract implements Countable
 {
     protected static $_keywords  = array('ALL',
                                          'AND',
@@ -1190,7 +1190,7 @@ class IPF_ORM_Query extends IPF_ORM_Query_Abstract implements Countable, Seriali
         return $q;
     }
 
-    public function count($params = array())
+    public function count($params = array()): int
     {
         $q = $this->getCountQuery();
 
@@ -1247,13 +1247,4 @@ class IPF_ORM_Query extends IPF_ORM_Query_Abstract implements Countable, Seriali
         $this->_dqlParts = array();
         $this->_enumParams = array();
     }
-
-    public function serialize()
-    {
-        $vars = get_object_vars($this);
-    }
-
-    public function unserialize($serialized)
-    {
-    }
 }
index 8be51ab10276b87a4643bf63bc09c2af047ed134..47904f27d6a016df271840751522b4cf402af59a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countable, IteratorAggregate, Serializable
+abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countable, IteratorAggregate
 {
     const STATE_DIRTY       = 1;
     const STATE_TDIRTY      = 2;
@@ -227,7 +227,7 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab
         }
     }
 
-    public function serialize()
+    public function __serialize(): array
     {
         $event = new IPF_ORM_Event($this, IPF_ORM_Event::RECORD_SERIALIZE);
 
@@ -264,14 +264,12 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab
             }
         }
 
-        $str = serialize($vars);
-
         $this->postSerialize($event);
 
-        return $str;
+        return $vars;
     }
 
-    public function unserialize($serialized)
+    public function __unserialize(array $serialized): void
     {
         $event = new IPF_ORM_Event($this, IPF_ORM_Event::RECORD_UNSERIALIZE);
 
@@ -284,9 +282,7 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab
 
         $this->_table = $connection->getTable(get_class($this));
 
-        $array = unserialize($serialized);
-
-        foreach($array as $k => $v) {
+        foreach($serialized as $k => $v) {
             $this->$k = $v;
         }
 
@@ -722,7 +718,7 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab
         return $a;
     }
 
-    public function count()
+    public function count(): int
     {
         return count($this->_data);
     }
@@ -862,7 +858,7 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab
         return $this->_table->hasRelation($fieldName);
     }
 
-    public function getIterator()
+    public function getIterator(): Traversable
     {
         return new IPF_ORM_Record_Iterator($this);
     }
index 3d0c550e96e6b58c83ef3ff8197bfce492c0d20b..8254b450646744bbd4df312d3b51d97fee3189a3 100644 (file)
@@ -67,12 +67,12 @@ abstract class IPF_ORM_Relation implements ArrayAccess
         return $this->definition['equal'];
     }
 
-    public function offsetExists($offset)
+    public function offsetExists($offset): bool
     {
         return isset($this->definition[$offset]);
     }
 
-    public function offsetGet($offset)
+    public function offsetGet($offset): mixed
     {
         if (isset($this->definition[$offset])) {
             return $this->definition[$offset];
@@ -81,14 +81,14 @@ abstract class IPF_ORM_Relation implements ArrayAccess
         return null;
     }
 
-    public function offsetSet($offset, $value)
+    public function offsetSet($offset, $value): void
     {
         if (isset($this->definition[$offset])) {
             $this->definition[$offset] = $value;
         }
     }
 
-    public function offsetUnset($offset)
+    public function offsetUnset($offset): void
     {
         $this->definition[$offset] = false;
     }
index 62081036bea91c6a9c690126f29d9dd3a4063aed..e4da51aa8fe876172d83dee48a21b6cd6c1393d3 100644 (file)
@@ -664,7 +664,7 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable
         return $where;
     }
 
-    public function count()
+    public function count(): int
     {
         $a = $this->_conn->execute('SELECT COUNT(1) FROM ' . $this->_options['tableName'])->fetch(IPF_ORM::FETCH_NUM);
         return current($a);
index 1fd15574f6872da6ae2d7404a343e38d19a2e6dd..cb5eedae74ca5068756892c4382a75193a4686e4 100644 (file)
@@ -35,7 +35,7 @@ class IPF_ORM_Table_Repository implements Countable, IteratorAggregate
         return $this->registry[$oid];
     }
 
-    public function count()
+    public function count(): int
     {
         return count($this->registry);
     }
@@ -60,7 +60,7 @@ class IPF_ORM_Table_Repository implements Countable, IteratorAggregate
         return $evicted;
     }
 
-    public function getIterator()
+    public function getIterator(): Traversable
     {
         return new ArrayIterator($this->registry);
     }