From d8c2ecd7a2f21c9d104f8f21d71ae3c4ffc69c74 Mon Sep 17 00:00:00 2001 From: Nikola Ivanovski Date: Tue, 19 Dec 2023 11:42:33 +0200 Subject: [PATCH] OXDEV-7644 Add deptrac to static analyzer --- composer.json | 3 ++- deptrac.yaml | 2 -- .../Controller/ModuleSettingController.php | 11 +---------- src/Module/Service/ModuleSettingService.php | 17 ++++------------- .../Infrastructure/ShopSettingRepository.php | 15 +++------------ 5 files changed, 10 insertions(+), 38 deletions(-) diff --git a/composer.json b/composer.json index bf5e6c3..17c4b36 100644 --- a/composer.json +++ b/composer.json @@ -52,7 +52,8 @@ "static": [ "@phpcs", "@phpstan", - "@phpmd" + "@phpmd", + "@deptrac" ], "phpunit": "vendor/bin/phpunit --bootstrap=/var/www/source/bootstrap.php --config=tests/", diff --git a/deptrac.yaml b/deptrac.yaml index 9692053..f15f2df 100644 --- a/deptrac.yaml +++ b/deptrac.yaml @@ -1,8 +1,6 @@ deptrac: paths: - ./src/ -# - ./vendor/oxid-esales/oxideshop-ce/source/ -# - ./vendor/oxid-esales/oxideshop-unified-namespace-generator/ layers: - name: Controller collectors: diff --git a/src/Module/Controller/ModuleSettingController.php b/src/Module/Controller/ModuleSettingController.php index ad69c5a..1729af9 100644 --- a/src/Module/Controller/ModuleSettingController.php +++ b/src/Module/Controller/ModuleSettingController.php @@ -9,15 +9,12 @@ namespace OxidEsales\GraphQL\ConfigurationAccess\Module\Controller; -use OxidEsales\Eshop\Application\Model\Basket; -use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContextInterface; use OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleSettingServiceInterface; use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\BooleanSetting; use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\FloatSetting; use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\IntegerSetting; use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\SettingType; use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\StringSetting; -use OxidEsales\GraphQL\ConfigurationAccess\Shop\Infrastructure\ShopSettingRepository; use TheCodingMachine\GraphQLite\Annotations\HideIfUnauthorized; use TheCodingMachine\GraphQLite\Annotations\Logged; use TheCodingMachine\GraphQLite\Annotations\Mutation; @@ -27,13 +24,7 @@ final class ModuleSettingController { public function __construct( - private ModuleSettingServiceInterface $moduleSettingService, //must be ok - // @phpstan-ignore-next-line - private ShopSettingRepository $settingRepository, //must fail - // @phpstan-ignore-next-line - private Basket $basket, //must fail - // @phpstan-ignore-next-line - private BasicContextInterface $basicContext //must fail + private ModuleSettingServiceInterface $moduleSettingService ) { } diff --git a/src/Module/Service/ModuleSettingService.php b/src/Module/Service/ModuleSettingService.php index ace011f..537c938 100644 --- a/src/Module/Service/ModuleSettingService.php +++ b/src/Module/Service/ModuleSettingService.php @@ -9,14 +9,11 @@ namespace OxidEsales\GraphQL\ConfigurationAccess\Module\Service; -use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController; -use OxidEsales\Eshop\Application\Model\Basket; use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Dao\ModuleConfigurationDaoInterface; use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\{ ModuleSettingServiceInterface as ShopModuleSettingServiceInterface}; use OxidEsales\EshopCommunity\Internal\Framework\Module\Setting\Setting; use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContextInterface; -use OxidEsales\GraphQL\ConfigurationAccess\Module\Controller\ModuleSettingController; use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\BooleanSetting; use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\FloatSetting; use OxidEsales\GraphQL\ConfigurationAccess\Shared\DataType\IntegerSetting; @@ -27,16 +24,10 @@ final class ModuleSettingService implements ModuleSettingServiceInterface { public function __construct( - private CollectionEncodingServiceInterface $jsonService, //must be ok - private ShopModuleSettingServiceInterface $moduleSettingService, //must be ok - private ModuleConfigurationDaoInterface $moduleConfigurationDao, //must be ok - private BasicContextInterface $basicContext, //must be ok - // @phpstan-ignore-next-line - private Basket $basket, //must fail - // @phpstan-ignore-next-line - private AdminDetailsController $adminDetailsController, //must fail - // @phpstan-ignore-next-line - private ModuleSettingController $moduleSettingController //must fail + private CollectionEncodingServiceInterface $jsonService, + private ShopModuleSettingServiceInterface $moduleSettingService, + private ModuleConfigurationDaoInterface $moduleConfigurationDao, + private BasicContextInterface $basicContext ) { } diff --git a/src/Shop/Infrastructure/ShopSettingRepository.php b/src/Shop/Infrastructure/ShopSettingRepository.php index 06ec7e1..5a34819 100644 --- a/src/Shop/Infrastructure/ShopSettingRepository.php +++ b/src/Shop/Infrastructure/ShopSettingRepository.php @@ -10,13 +10,10 @@ namespace OxidEsales\GraphQL\ConfigurationAccess\Shop\Infrastructure; use Doctrine\DBAL\Result; -use OxidEsales\Eshop\Application\Model\Basket; use OxidEsales\EshopCommunity\Internal\Framework\Config\Dao\ShopConfigurationSettingDaoInterface; use OxidEsales\EshopCommunity\Internal\Framework\Config\DataObject\ShopConfigurationSetting; use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface; use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContextInterface; -use OxidEsales\GraphQL\ConfigurationAccess\Module\Controller\ModuleSettingController; -use OxidEsales\GraphQL\ConfigurationAccess\Module\Service\ModuleSettingService; use OxidEsales\GraphQL\ConfigurationAccess\Shared\Enum\FieldType; use OxidEsales\GraphQL\ConfigurationAccess\Shop\Exception\NoSettingsFoundForShopException; use OxidEsales\GraphQL\ConfigurationAccess\Shop\Exception\WrongSettingTypeException; @@ -25,15 +22,9 @@ final class ShopSettingRepository implements ShopSettingRepositoryInterface { public function __construct( - private BasicContextInterface $basicContext, //must be ok - private QueryBuilderFactoryInterface $queryBuilderFactory, //must be ok - private ShopConfigurationSettingDaoInterface $configurationSettingDao, //must be ok - // @phpstan-ignore-next-line - private Basket $basket, //must be ok - // @phpstan-ignore-next-line - private ModuleSettingController $moduleSettingController, //must fail - // @phpstan-ignore-next-line - private ModuleSettingService $moduleSettingService, //must fail + private BasicContextInterface $basicContext, + private QueryBuilderFactoryInterface $queryBuilderFactory, + private ShopConfigurationSettingDaoInterface $configurationSettingDao ) { }