From b519583431ef4276cc32d07e6fa7f4836d6305b1 Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Mon, 12 Aug 2019 17:43:02 +0200 Subject: [PATCH] [CLEANUP] Fix code inspection warnings (#57) --- CHANGELOG.md | 1 + Classes/Domain/Model/Product/Tea.php | 7 ++----- .../Traits/StoragePageAgnosticTrait.php | 3 +++ .../Acceptance/_support/Helper/Acceptance.php | 1 + .../Repository/Fixtures/Product/Tea.xml | 1 - Tests/Unit/Controller/TeaControllerTest.php | 19 +++++-------------- .../Repository/Product/TeaRepositoryTest.php | 3 +-- 7 files changed, 13 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13dcf06..68f8c09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). - Drop the dependency of roave/security-advisories (#41) ### Fixed +- Fix code inspection warnings (#55) - Use the new annotations for lazy loading (#54) - Update and pin the dev dependencies (#45) - Drop an obsolete "replace" entry from composer.json (#42) diff --git a/Classes/Domain/Model/Product/Tea.php b/Classes/Domain/Model/Product/Tea.php index 1542f7c..81f5627 100644 --- a/Classes/Domain/Model/Product/Tea.php +++ b/Classes/Domain/Model/Product/Tea.php @@ -3,10 +3,10 @@ declare(strict_types=1); namespace OliverKlee\Tea\Domain\Model\Product; +use TYPO3\CMS\Extbase\Annotation\ORM\Lazy; use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy; -use TYPO3\CMS\Extbase\Annotation\ORM\Lazy; /** * This class represents a tea (flavor), e.g., "Earl Grey". @@ -51,10 +51,7 @@ class Tea extends AbstractEntity $this->description = $description; } - /** - * @return FileReference|null - */ - public function getImage() + public function getImage(): ?FileReference { if ($this->image instanceof LazyLoadingProxy) { $this->image = $this->image->_loadRealInstance(); diff --git a/Classes/Domain/Repository/Traits/StoragePageAgnosticTrait.php b/Classes/Domain/Repository/Traits/StoragePageAgnosticTrait.php index 2f03fd3..19e56fb 100644 --- a/Classes/Domain/Repository/Traits/StoragePageAgnosticTrait.php +++ b/Classes/Domain/Repository/Traits/StoragePageAgnosticTrait.php @@ -3,11 +3,14 @@ declare(strict_types=1); namespace OliverKlee\Tea\Domain\Repository\Traits; +use TYPO3\CMS\Extbase\Object\ObjectManagerInterface; use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface; /** * This trait for repositories makes the repository ignore the storage page setting when fetching models. * + * @property ObjectManagerInterface $objectManager + * * @author Oliver Klee 3 tx_tea_domain_model_product_tea image - diff --git a/Tests/Unit/Controller/TeaControllerTest.php b/Tests/Unit/Controller/TeaControllerTest.php index 70d82dc..bc69085 100644 --- a/Tests/Unit/Controller/TeaControllerTest.php +++ b/Tests/Unit/Controller/TeaControllerTest.php @@ -30,32 +30,23 @@ class TeaControllerTest extends UnitTestCase */ private $viewProphecy = null; - /** - * @var TemplateView|ProphecySubjectInterface - */ - private $view = null; - /** * @var TeaRepository|ObjectProphecy */ private $teaRepositoryProphecy = null; - /** - * @var TeaRepository|ProphecySubjectInterface - */ - private $teaRepository = null; - protected function setUp(): void { $this->subject = new TeaController(); $this->viewProphecy = $this->prophesize(TemplateView::class); - $this->view = $this->viewProphecy->reveal(); - $this->inject($this->subject, 'view', $this->view); + $view = $this->viewProphecy->reveal(); + $this->inject($this->subject, 'view', $view); $this->teaRepositoryProphecy = $this->prophesize(TeaRepository::class); - $this->teaRepository = $this->teaRepositoryProphecy->reveal(); - $this->subject->injectTeaRepository($this->teaRepository); + /** @var TeaRepository|ProphecySubjectInterface $teaRepository */ + $teaRepository = $this->teaRepositoryProphecy->reveal(); + $this->subject->injectTeaRepository($teaRepository); } /** diff --git a/Tests/Unit/Domain/Repository/Product/TeaRepositoryTest.php b/Tests/Unit/Domain/Repository/Product/TeaRepositoryTest.php index 3c99fd5..a987865 100644 --- a/Tests/Unit/Domain/Repository/Product/TeaRepositoryTest.php +++ b/Tests/Unit/Domain/Repository/Product/TeaRepositoryTest.php @@ -28,8 +28,7 @@ class TeaRepositoryTest extends UnitTestCase protected function setUp(): void { - $objectManagerProphecy = $this->prophesize(ObjectManagerInterface::class); - $this->objectManager = $objectManagerProphecy->reveal(); + $this->objectManager = $this->prophesize(ObjectManagerInterface::class)->reveal(); $this->subject = new TeaRepository($this->objectManager); }