diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-11-07 13:59:48 +0100 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2023-01-20 11:22:09 +0100 |
commit | e91457d9cd68182591038636155d415b5dee0ec4 (patch) | |
tree | 70e370adb128e4aace6cabb6b39fd5cd1f3f9700 /lib | |
parent | 87ebf28eb40e511341552135a01ba66956463cf3 (diff) | |
download | nextcloud-server-e91457d9cd68182591038636155d415b5dee0ec4.tar.gz nextcloud-server-e91457d9cd68182591038636155d415b5dee0ec4.zip |
Improve typing in Entity.php
Removing @method in Entity brings even more errors.
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/AppFramework/Db/Entity.php | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/public/AppFramework/Db/Entity.php b/lib/public/AppFramework/Db/Entity.php index dcd1c77c042..34cd297e57e 100644 --- a/lib/public/AppFramework/Db/Entity.php +++ b/lib/public/AppFramework/Db/Entity.php @@ -29,25 +29,27 @@ use function lcfirst; use function substr; /** - * @method integer getId() - * @method void setId(integer $id) + * @method int getId() + * @method void setId(int $id) * @since 7.0.0 + * @psalm-consistent-constructor */ abstract class Entity { + /** + * @var int + */ public $id; - private $_updatedFields = []; - private $_fieldTypes = ['id' => 'integer']; - + private array $_updatedFields = []; + private array $_fieldTypes = ['id' => 'integer']; /** * Simple alternative constructor for building entities from a request * @param array $params the array which was obtained via $this->params('key') * in the controller - * @return Entity * @since 7.0.0 */ - public static function fromParams(array $params) { + public static function fromParams(array $params): static { $instance = new static(); foreach ($params as $key => $value) { @@ -64,7 +66,7 @@ abstract class Entity { * @param array $row the row to map onto the entity * @since 7.0.0 */ - public static function fromRow(array $row) { + public static function fromRow(array $row): static { $instance = new static(); foreach ($row as $key => $value) { @@ -100,7 +102,7 @@ abstract class Entity { * Generic setter for properties * @since 7.0.0 */ - protected function setter($name, $args) { + protected function setter(string $name, array $args): void { // setters should only work for existing attributes if (property_exists($this, $name)) { if ($this->$name === $args[0]) { @@ -142,7 +144,7 @@ abstract class Entity { * Generic getter for properties * @since 7.0.0 */ - protected function getter($name) { + protected function getter(string $name): mixed { // getters should only work for existing attributes if (property_exists($this, $name)) { return $this->$name; @@ -160,7 +162,7 @@ abstract class Entity { * getter method * @since 7.0.0 */ - public function __call($methodName, $args) { + public function __call(string $methodName, array $args) { if (strpos($methodName, 'set') === 0) { $this->setter(lcfirst(substr($methodName, 3)), $args); } elseif (strpos($methodName, 'get') === 0) { @@ -191,7 +193,7 @@ abstract class Entity { * @param string $attribute the name of the attribute * @since 7.0.0 */ - protected function markFieldUpdated($attribute) { + protected function markFieldUpdated(string $attribute): void { $this->_updatedFields[$attribute] = true; } |