From: Andrey Kutejko Date: Thu, 18 Aug 2022 21:40:47 +0000 (+0200) Subject: Fix warnings X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=ed4cbe38e809cd2a488df74cf41874bb0e162788;p=ipf-legacy-orm.git Fix warnings --- diff --git a/src/orm/access.php b/src/orm/access.php index d0a87d2..e961006 100644 --- a/src/orm/access.php +++ b/src/orm/access.php @@ -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) diff --git a/src/orm/collection.php b/src/orm/collection.php index 9bf5e52..2d06559 100644 --- a/src/orm/collection.php +++ b/src/orm/collection.php @@ -1,6 +1,6 @@ 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); diff --git a/src/orm/connection.php b/src/orm/connection.php index 7fddf02..4fb1027 100644 --- a/src/orm/connection.php +++ b/src/orm/connection.php @@ -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; } diff --git a/src/orm/connection/statement.php b/src/orm/connection/statement.php index cfea7cc..d0c9f54 100644 --- a/src/orm/connection/statement.php +++ b/src/orm/connection/statement.php @@ -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()); diff --git a/src/orm/query.php b/src/orm/query.php index 1830c33..d269bbf 100644 --- a/src/orm/query.php +++ b/src/orm/query.php @@ -1,6 +1,6 @@ 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) - { - } } diff --git a/src/orm/record.php b/src/orm/record.php index 8be51ab..47904f2 100644 --- a/src/orm/record.php +++ b/src/orm/record.php @@ -1,6 +1,6 @@ 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); } diff --git a/src/orm/relation.php b/src/orm/relation.php index 3d0c550..8254b45 100644 --- a/src/orm/relation.php +++ b/src/orm/relation.php @@ -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; } diff --git a/src/orm/table.php b/src/orm/table.php index 6208103..e4da51a 100644 --- a/src/orm/table.php +++ b/src/orm/table.php @@ -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); diff --git a/src/orm/table/repository.php b/src/orm/table/repository.php index 1fd1557..cb5eeda 100644 --- a/src/orm/table/repository.php +++ b/src/orm/table/repository.php @@ -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); }