From 30a916c229d04ce12f515226d8cbbae98345e3c0 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Fri, 7 Apr 2023 06:38:11 +0000 Subject: [PATCH] improve SORM docblocks, fixes #2514 Closes #2514 Merge request studip/studip!1703 --- lib/models/SimpleORMap.class.php | 11 +++++------ lib/models/SimpleORMapCollection.class.php | 16 +++++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/models/SimpleORMap.class.php b/lib/models/SimpleORMap.class.php index f36f65d3ffd..2187979190e 100644 --- a/lib/models/SimpleORMap.class.php +++ b/lib/models/SimpleORMap.class.php @@ -473,7 +473,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate /** * Returns true if given key exists in the database. * - * @param string $id primary key + * @param string|array $id primary key * @return boolean */ public static function exists($id) @@ -621,7 +621,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate * returns array of instances of given class filtered by given sql * @param string $sql sql clause to use on the right side of WHERE * @param ?array $params parameters for query - * @return array array of "self" objects + * @return static[] array of "self" objects */ public static function findBySQL($sql, $params = []) { @@ -672,7 +672,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate * * @param string $foreign_key_value value of foreign key to find related records * @param array $options relation options from other side of relation - * @return array of "self" objects + * @return static[] array of "self" objects */ public static function findThru($foreign_key_value, $options) { @@ -754,7 +754,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate * @param ?array $pks array of primary keys * @param ?string $order order by clause * @param ?array $order_params - * @return array + * @return static[] */ public static function findMany($pks = [], $order = '', $order_params = []) { @@ -888,7 +888,7 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate * @param string $name * @param array $arguments * @throws BadMethodCallException - * @return mixed + * @return int|static|static[] */ public static function __callStatic($name, $arguments) { @@ -1243,7 +1243,6 @@ class SimpleORMap implements ArrayAccess, Countable, IteratorAggregate } return true; } - return false; } /** diff --git a/lib/models/SimpleORMapCollection.class.php b/lib/models/SimpleORMapCollection.class.php index 11d8a5ffdd1..f06ee178e46 100644 --- a/lib/models/SimpleORMapCollection.class.php +++ b/lib/models/SimpleORMapCollection.class.php @@ -14,6 +14,8 @@ * @category Stud.IP * * @extends SimpleCollection<SimpleORMap> + * + * @template T of SimpleORMap */ class SimpleORMapCollection extends SimpleCollection { @@ -45,9 +47,9 @@ class SimpleORMapCollection extends SimpleCollection * all objects should be of the same type * * @throws InvalidArgumentException if first entry is not SimpleOrMap - * @param array<?SimpleORMap> $data array with SimpleORMap objects + * @param T[] $data array with SimpleORMap objects * @param bool $strict check every element for correct type and unique pk - * @return SimpleORMapCollection + * @return SimpleORMapCollection<T> */ public static function createFromArray(array $data, $strict = true) { @@ -73,9 +75,9 @@ class SimpleORMapCollection extends SimpleCollection /** * Constructor * - * @param ?Closure $finder callable to fill collection - * @param ?array $options relationship options - * @param ?SimpleORMap $record related record + * @param ?Closure $finder callable to fill collection + * @param ?array $options relationship options + * @param SimpleORMap|null $record related record */ public function __construct(Closure $finder = null, array $options = null, SimpleORMap $record = null) { @@ -175,7 +177,7 @@ class SimpleORMapCollection extends SimpleCollection * returns element with given primary key value * * @param string $value primary key value to search for - * @return ?SimpleORMap + * @return ?T */ public function find($value) { @@ -217,7 +219,7 @@ class SimpleORMapCollection extends SimpleCollection * internal deleted collection * * @param string $id primary key of element - * @return number of unsetted elements + * @return int number of unsetted elements */ public function unsetByPk($id) { -- GitLab