From 7c60f2f55e4f52718c2db9ddd787d20629a1d944 Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Tue, 20 Apr 2021 01:18:17 +0200 Subject: [PATCH] TASK: Adding PHP 7.4 type hints everywhere --- Classes/Command/SequenceCommandController.php | 2 ++ Classes/Domain/Model/Insert.php | 16 +++++++++------- Classes/Service/Exception.php | 2 ++ Classes/Service/SequenceGenerator.php | 14 ++++++++------ composer.json | 5 +++-- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Classes/Command/SequenceCommandController.php b/Classes/Command/SequenceCommandController.php index 076cd53..da8a129 100644 --- a/Classes/Command/SequenceCommandController.php +++ b/Classes/Command/SequenceCommandController.php @@ -1,5 +1,7 @@ setNumber($number); $this->setType($type); @@ -42,7 +44,7 @@ class Insert /** * @return int */ - public function getNumber() + public function getNumber(): int { return $this->number; } @@ -50,7 +52,7 @@ class Insert /** * @param int $number */ - public function setNumber($number) + public function setNumber(int $number): void { $this->number = $number; } @@ -58,7 +60,7 @@ class Insert /** * @return string */ - public function getType() + public function getType(): string { return $this->type; } @@ -66,7 +68,7 @@ class Insert /** * @param string|object $type */ - public function setType($type) + public function setType($type): void { if (is_object($type)) { $type = get_class($type); diff --git a/Classes/Service/Exception.php b/Classes/Service/Exception.php index 37b66ed..96a3ad7 100644 --- a/Classes/Service/Exception.php +++ b/Classes/Service/Exception.php @@ -1,5 +1,7 @@ inferTypeFromSource($type); $count = $this->getLastNumberFor($type); @@ -55,7 +57,7 @@ class SequenceGenerator * @param string|object $type * @return bool */ - protected function validateFreeNumber($count, $type) + protected function validateFreeNumber(int $count, $type) { /* @var EntityManager $em */ $em = $this->entityManager; @@ -83,7 +85,7 @@ class SequenceGenerator * @param string|object $type * @return bool */ - public function advanceTo($to, $type) + public function advanceTo(int $to, $type): bool { $type = $this->inferTypeFromSource($type); @@ -94,12 +96,12 @@ class SequenceGenerator * @param string|object $type * @return int */ - public function getLastNumberFor($type) + public function getLastNumberFor($type): int { /* @var EntityManager $em */ $em = $this->entityManager; - return $em->getConnection()->executeQuery( + return (int) $em->getConnection()->executeQuery( 'SELECT MAX(number) FROM ' . $em->getClassMetadata(Insert::class)->getTableName() . ' WHERE type = :type', ['type' => $this->inferTypeFromSource($type)] )->fetchAll(\PDO::FETCH_COLUMN)[0]; @@ -110,7 +112,7 @@ class SequenceGenerator * @return string * @throws Exception */ - protected function inferTypeFromSource($stringOrObject) + protected function inferTypeFromSource($stringOrObject): string { if (is_object($stringOrObject)) { $stringOrObject = TypeHandling::getTypeForValue($stringOrObject); diff --git a/composer.json b/composer.json index 8f5d667..6e5e1c3 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "license": "MIT", "homepage": "https://github.com/digicomp/DigiComp.Sequence", "require": { - "neos/flow": "~4.1|~5.3|~6.3" + "neos/flow": "~5.3 | ^6.3.5", + "php": "^7.4" }, "require-dev": { "phpunit/phpunit": "3.7.*", @@ -33,7 +34,7 @@ "extra": { "branch-alias": { "dev-version/1.x-dev": "1.1.x-dev", - "dev-develop": "2.0.x-dev" + "dev-develop": "3.0.x-dev" }, "applied-flow-migrations": [ "Inwebs.Basket-201409170938",