From 563f4befbf73fd15ad02b38fe65bd8b8fe1ea560 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Fri, 8 Sep 2017 18:04:28 +0200 Subject: [PATCH] [CLEANUP] Use strict types, scalar type hinting and return types --- Classes/Domain/Model/Addition.php | 6 ++-- Classes/Domain/Model/TeaBeverage.php | 30 +++++++++++-------- Classes/Domain/Model/TeaType.php | 16 +++++----- Classes/Domain/Model/Testimonial.php | 16 +++++----- .../Repository/TeaBeverageRepository.php | 2 ++ .../Repository/TestimonialRepository.php | 2 ++ Classes/Utility/FileUtility.php | 4 ++- .../Repository/TeaBeverageRepositoryTest.php | 2 ++ .../Repository/TestimonialRepositoryTest.php | 2 ++ Tests/Functional/Utility/FileUtilityTest.php | 2 ++ .../Controller/TestimonialControllerTest.php | 2 ++ Tests/Unit/Domain/Model/AdditionTest.php | 2 ++ Tests/Unit/Domain/Model/TeaBeverageTest.php | 2 ++ Tests/Unit/Domain/Model/TeaTypeTest.php | 2 ++ Tests/Unit/Domain/Model/TestimonialTest.php | 2 ++ .../Repository/TeaBeverageRepositoryTest.php | 2 ++ .../Repository/TestimonialRepositoryTest.php | 2 ++ 17 files changed, 66 insertions(+), 30 deletions(-) diff --git a/Classes/Domain/Model/Addition.php b/Classes/Domain/Model/Addition.php index 83f8727..03712c4 100644 --- a/Classes/Domain/Model/Addition.php +++ b/Classes/Domain/Model/Addition.php @@ -1,4 +1,6 @@ title; } @@ -40,7 +42,7 @@ class Addition extends \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject * * @return void */ - public function setTitle($title) + public function setTitle(string $title) { $this->title = $title; } diff --git a/Classes/Domain/Model/TeaBeverage.php b/Classes/Domain/Model/TeaBeverage.php index 9d1d3d9..805add7 100644 --- a/Classes/Domain/Model/TeaBeverage.php +++ b/Classes/Domain/Model/TeaBeverage.php @@ -1,4 +1,6 @@ size; } @@ -78,13 +82,13 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity * * @return void */ - public function setSize($size) + public function setSize(float $size) { $this->size = $size; } /** - * @return \OliverKlee\Tea\Domain\Model\TeaType $type + * @return TeaType|null $type */ public function getType() { @@ -92,11 +96,11 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity } /** - * @param \OliverKlee\Tea\Domain\Model\TeaType $type + * @param TeaType $type * * @return void */ - public function setType(\OliverKlee\Tea\Domain\Model\TeaType $type) + public function setType(TeaType $type) { $this->type = $type; } @@ -104,7 +108,7 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity /** * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\OliverKlee\Tea\Domain\Model\Addition> $additions */ - public function getAdditions() + public function getAdditions(): ObjectStorage { return $this->additions; } @@ -114,7 +118,7 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity * * @return void */ - public function setAdditions(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $additions) + public function setAdditions(ObjectStorage $additions) { $this->additions = $additions; } @@ -126,7 +130,7 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity * * @return void */ - public function addAddition(\OliverKlee\Tea\Domain\Model\Addition $addition) + public function addAddition(Addition $addition) { $this->additions->attach($addition); } @@ -138,7 +142,7 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity * * @return void */ - public function removeAddition(\OliverKlee\Tea\Domain\Model\Addition $additionToRemove) + public function removeAddition(Addition $additionToRemove) { $this->additions->detach($additionToRemove); } @@ -146,7 +150,7 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity /** * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\OliverKlee\Tea\Domain\Model\Testimonial> $testimonials */ - public function getTestimonials() + public function getTestimonials(): ObjectStorage { return $this->testimonials; } @@ -156,7 +160,7 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity * * @return void */ - public function setTestimonials(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $testimonials) + public function setTestimonials(ObjectStorage $testimonials) { $this->testimonials = $testimonials; } @@ -168,7 +172,7 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity * * @return void */ - public function addTestimonial(\OliverKlee\Tea\Domain\Model\Testimonial $testimonial) + public function addTestimonial(Testimonial $testimonial) { $this->testimonials->attach($testimonial); } @@ -180,7 +184,7 @@ class TeaBeverage extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity * * @return void */ - public function removeTestimonial(\OliverKlee\Tea\Domain\Model\Testimonial $testimonialToRemove) + public function removeTestimonial(Testimonial $testimonialToRemove) { $this->testimonials->detach($testimonialToRemove); } diff --git a/Classes/Domain/Model/TeaType.php b/Classes/Domain/Model/TeaType.php index 7fa041f..b682d86 100644 --- a/Classes/Domain/Model/TeaType.php +++ b/Classes/Domain/Model/TeaType.php @@ -1,4 +1,6 @@ title; } @@ -45,15 +47,15 @@ class TeaType extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity * * @return void */ - public function setTitle($title) + public function setTitle(string $title) { $this->title = $title; } /** - * @return bool $caffeinated + * @return bool */ - public function getCaffeinated() + public function getCaffeinated(): bool { return $this->caffeinated; } @@ -63,7 +65,7 @@ class TeaType extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity * * @return void */ - public function setCaffeinated($caffeinated) + public function setCaffeinated(bool $caffeinated) { $this->caffeinated = $caffeinated; } @@ -71,7 +73,7 @@ class TeaType extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity /** * @return bool */ - public function isCaffeinated() + public function isCaffeinated(): bool { return $this->getCaffeinated(); } diff --git a/Classes/Domain/Model/Testimonial.php b/Classes/Domain/Model/Testimonial.php index abf622c..17d9f34 100644 --- a/Classes/Domain/Model/Testimonial.php +++ b/Classes/Domain/Model/Testimonial.php @@ -1,4 +1,6 @@ dateOfPosting = $dateOfPosting; } @@ -57,7 +59,7 @@ class Testimonial extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity /** * @return int $numberOfConsumedCups */ - public function getNumberOfConsumedCups() + public function getNumberOfConsumedCups(): int { return $this->numberOfConsumedCups; } @@ -67,15 +69,15 @@ class Testimonial extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity * * @return void */ - public function setNumberOfConsumedCups($numberOfConsumedCups) + public function setNumberOfConsumedCups(int $numberOfConsumedCups) { $this->numberOfConsumedCups = $numberOfConsumedCups; } /** - * @return string $text + * @return string */ - public function getText() + public function getText(): string { return $this->text; } @@ -85,7 +87,7 @@ class Testimonial extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity * * @return void */ - public function setText($text) + public function setText(string $text) { $this->text = $text; } diff --git a/Classes/Domain/Repository/TeaBeverageRepository.php b/Classes/Domain/Repository/TeaBeverageRepository.php index d4d7002..0d2a2b6 100644 --- a/Classes/Domain/Repository/TeaBeverageRepository.php +++ b/Classes/Domain/Repository/TeaBeverageRepository.php @@ -1,4 +1,6 @@