diff --git a/.github/workflows/grumphp.yml b/.github/workflows/grumphp.yml index 98b287d..ce0d24b 100644 --- a/.github/workflows/grumphp.yml +++ b/.github/workflows/grumphp.yml @@ -23,7 +23,6 @@ jobs: - "8.3" steps: - uses: actions/checkout@v4 - - name: Setup PHP, with composer and extensions uses: shivammathur/setup-php@v2 with: @@ -46,25 +45,53 @@ jobs: - name: Info run: composer info - name: Run Tests - run: php vendor/bin/grumphp run -vvv + run: php vendor/bin/grumphp run # -vvv - name: Install Composer dependencies without dev run: rm -fR vendor && composer install --no-progress --prefer-dist --optimize-autoloader --no-dev if: matrix.php-versions == '8.1' - - name: Install Box - run: wget https://github.com/box-project/box/releases/download/4.5.1/box.phar - if: matrix.php-versions == '8.1' - name: Compile phar - run: php box.phar compile - if: matrix.php-versions == '8.1' - - name: Compile Result - run: ls -lah + run: wget https://github.com/box-project/box/releases/download/4.5.1/box.phar && php box.phar compile if: matrix.php-versions == '8.1' + # - name: Compile Result + # run: ls -lah + # if: matrix.php-versions == '8.1' - name: Compile Result Upload if: matrix.php-versions == '8.1' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: jeeves_new.phar path: jeeves.phar + test: + runs-on: ubuntu-latest + needs: ["build"] + strategy: + fail-fast: false + matrix: + php-versions: + - "8.1" + - "8.2" + - "8.3" + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + name: jeeves_new.phar + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, xml, ctype, iconv, intl, mysql + - name: Prepare test + run: mv .jeeves.phpunit_v1.yaml .jeeves.yaml + - name: Test phar + run: php jeeves.phar generate + release: + runs-on: ubuntu-latest + needs: ["test"] + steps: + - uses: actions/download-artifact@v4 + with: + name: jeeves_new.phar - name: Upload to Releases uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') && matrix.php-versions == '8.1' diff --git a/.jeeves.phpunit_v1.yaml b/.jeeves.phpunit_v1.yaml index 7f03517..aa2f713 100644 --- a/.jeeves.phpunit_v1.yaml +++ b/.jeeves.phpunit_v1.yaml @@ -100,17 +100,6 @@ Mygento: columns: ["city"] IX_ACTIVE: columns: ["is_active"] - Obsolete: - settings: - php_version: "7.3" - columns: - id: - type: int - pk: true - unsigned: true - comment: "Banner ID" - name: - type: varchar Card: api: true cacheable: true diff --git a/src/Jeeves/Generators/Common.php b/src/Jeeves/Generators/Common.php index 5c99690..4a1b99b 100644 --- a/src/Jeeves/Generators/Common.php +++ b/src/Jeeves/Generators/Common.php @@ -11,11 +11,6 @@ class Common protected const N = 'name'; protected const V = 'value'; - protected function hasTypes(string $version): bool - { - return version_compare($version, '7.4.0', '>='); - } - protected function hasConstructorProp(string $version): bool { return version_compare($version, '8.0.0', '>='); @@ -31,6 +26,11 @@ protected function hasReadOnlyClass(string $version): bool return version_compare($version, '8.2.0', '>='); } + protected function hasTypedConst(string $version): bool + { + return version_compare($version, '8.3.0', '>='); + } + protected function getService(): Service { $service = new Service(); diff --git a/src/Jeeves/Generators/Crud/Controllers/Create.php b/src/Jeeves/Generators/Crud/Controllers/Create.php index 03b42db..fc2fa09 100644 --- a/src/Jeeves/Generators/Crud/Controllers/Create.php +++ b/src/Jeeves/Generators/Crud/Controllers/Create.php @@ -14,7 +14,6 @@ public function genAdminNewController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $constructorProp = $this->hasConstructorProp($phpVersion); $readonlyProp = $this->hasReadOnlyProp($phpVersion); @@ -27,11 +26,7 @@ public function genAdminNewController( if (!$constructorProp) { $forward = $class->addProperty('resultForwardFactory')->setVisibility('private'); - if ($typehint) { - $forward->setType('\Magento\Backend\Model\View\Result\ForwardFactory'); - } else { - $forward->addComment('@var \Magento\Backend\Model\View\Result\ForwardFactory'); - } + $forward->setType('\Magento\Backend\Model\View\Result\ForwardFactory'); } $body = 'parent::__construct($repository, $coreRegistry, $context);'; @@ -41,19 +36,11 @@ public function genAdminNewController( $construct = $class->addMethod('__construct') ->setBody($body); - if ($typehint) { - $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); - $namespace->addUse($repository); - $namespace->addUse('\Magento\Framework\Registry'); - $namespace->addUse('\Magento\Backend\App\Action\Context'); - $namespace->addUse('\Magento\Backend\Model\View\Result\ForwardFactory'); - } else { - $construct - ->addComment('@param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory') - ->addComment('@param ' . $repository . ' $repository') - ->addComment('@param \Magento\Framework\Registry $coreRegistry') - ->addComment('@param \Magento\Backend\App\Action\Context $context'); - } + $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); + $namespace->addUse($repository); + $namespace->addUse('\Magento\Framework\Registry'); + $namespace->addUse('\Magento\Backend\App\Action\Context'); + $namespace->addUse('\Magento\Backend\Model\View\Result\ForwardFactory'); if ($constructorProp) { $construct @@ -76,12 +63,8 @@ public function genAdminNewController( . '$resultForward = $this->resultForwardFactory->create();' . PHP_EOL . 'return $resultForward->forward(\'edit\');'); - if ($typehint) { - $execute->setReturnType('\Magento\Framework\Controller\ResultInterface'); - $namespace->addUse('\Magento\Framework\Controller\ResultInterface'); - } else { - $execute->addComment('@return \Magento\Framework\Controller\ResultInterface'); - } + $execute->setReturnType('\Magento\Framework\Controller\ResultInterface'); + $namespace->addUse('\Magento\Framework\Controller\ResultInterface'); return $namespace; } diff --git a/src/Jeeves/Generators/Crud/Controllers/Delete.php b/src/Jeeves/Generators/Crud/Controllers/Delete.php index b339155..4a57931 100644 --- a/src/Jeeves/Generators/Crud/Controllers/Delete.php +++ b/src/Jeeves/Generators/Crud/Controllers/Delete.php @@ -12,16 +12,13 @@ public function genAdminDeleteController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Controller\Adminhtml\\' . $entity); $class = $namespace->addClass('Delete') ->setExtends($rootNamespace . '\Controller\Adminhtml\\' . $entity); $entityName = $this->getEntityPrintName($entity); - if ($typehint) { - $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); - } + $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); $execute = $class->addMethod('execute') ->addComment('Delete ' . $entityName . ' action') @@ -46,12 +43,8 @@ public function genAdminDeleteController( . '}' . PHP_EOL . PHP_EOL . 'return $resultRedirect->setPath(\'*/*/edit\', [\'id\' => $entityId]);'); - if ($typehint) { - $execute->setReturnType('\Magento\Framework\Controller\ResultInterface'); - $namespace->addUse('\Magento\Framework\Controller\ResultInterface'); - } else { - $execute->addComment('@return \Magento\Framework\Controller\ResultInterface'); - } + $execute->setReturnType('\Magento\Framework\Controller\ResultInterface'); + $namespace->addUse('\Magento\Framework\Controller\ResultInterface'); return $namespace; } diff --git a/src/Jeeves/Generators/Crud/Controllers/Edit.php b/src/Jeeves/Generators/Crud/Controllers/Edit.php index c91f89f..3ba225a 100644 --- a/src/Jeeves/Generators/Crud/Controllers/Edit.php +++ b/src/Jeeves/Generators/Crud/Controllers/Edit.php @@ -16,7 +16,6 @@ public function genAdminEditController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $constructorProp = $this->hasConstructorProp($phpVersion); $readonlyProp = $this->hasReadOnlyProp($phpVersion); @@ -26,11 +25,9 @@ public function genAdminEditController( $class = $namespace->addClass('Edit') ->setExtends($rootNamespace . '\Controller\Adminhtml\\' . $entity); - if ($typehint) { - $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); - $namespace->addUse('\Magento\Framework\View\Result\PageFactory'); - $namespace->addUse($entityClass . 'Factory'); - } + $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); + $namespace->addUse('\Magento\Framework\View\Result\PageFactory'); + $namespace->addUse($entityClass . 'Factory'); if (!$constructorProp) { $factory = $class->addProperty('entityFactory') @@ -39,13 +36,8 @@ public function genAdminEditController( $result = $class->addProperty('resultPageFactory') ->setVisibility('private'); - if ($typehint) { - $factory->setType($entityClass . 'Factory'); - $result->setType('\Magento\Framework\View\Result\PageFactory'); - } else { - $factory->addComment('@var ' . $entityClass . 'Factory'); - $result->addComment('@var \Magento\Framework\View\Result\PageFactory'); - } + $factory->setType($entityClass . 'Factory'); + $result->setType('\Magento\Framework\View\Result\PageFactory'); } $body = 'parent::__construct($repository, $coreRegistry, $context);'; @@ -56,19 +48,10 @@ public function genAdminEditController( } $construct = $class->addMethod('__construct')->setBody($body); - if ($typehint) { - $namespace - ->addUse($repository) - ->addUse('\Magento\Framework\Registry') - ->addUse('\Magento\Backend\App\Action\Context'); - } else { - $construct - ->addComment('@param ' . $entityClass . 'Factory $entityFactory') - ->addComment('@param \Magento\Framework\View\Result\PageFactory $resultPageFactory') - ->addComment('@param ' . $repository . ' $repository') - ->addComment('@param \Magento\Framework\Registry $coreRegistry') - ->addComment('@param \Magento\Backend\App\Action\Context $context'); - } + $namespace + ->addUse($repository) + ->addUse('\Magento\Framework\Registry') + ->addUse('\Magento\Backend\App\Action\Context'); if ($constructorProp) { $construct @@ -126,12 +109,8 @@ public function genAdminEditController( . 'return $resultPage;'); $namespace->addUse('\Magento\Framework\Exception\NoSuchEntityException'); - if ($typehint) { - $execute->setReturnType('\Magento\Framework\Controller\ResultInterface'); - $namespace->addUse('\Magento\Framework\Controller\ResultInterface'); - } else { - $execute->addComment('@return \Magento\Framework\Controller\ResultInterface'); - } + $execute->setReturnType('\Magento\Framework\Controller\ResultInterface'); + $namespace->addUse('\Magento\Framework\Controller\ResultInterface'); return $namespace; } diff --git a/src/Jeeves/Generators/Crud/Controllers/Inline.php b/src/Jeeves/Generators/Crud/Controllers/Inline.php index 436c84e..9528dc0 100644 --- a/src/Jeeves/Generators/Crud/Controllers/Inline.php +++ b/src/Jeeves/Generators/Crud/Controllers/Inline.php @@ -14,7 +14,6 @@ public function genAdminInlineController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $constructorProp = $this->hasConstructorProp($phpVersion); $readonlyProp = $this->hasReadOnlyProp($phpVersion); @@ -25,11 +24,8 @@ public function genAdminInlineController( if (!$constructorProp) { $json = $class->addProperty('jsonFactory')->setVisibility('private'); - if ($typehint) { - $json->setType('\Magento\Framework\Controller\Result\JsonFactory'); - } else { - $json->addComment('@var \Magento\Framework\Controller\Result\JsonFactory'); - } + + $json->setType('\Magento\Framework\Controller\Result\JsonFactory'); } $namespace->addUse('\Magento\Framework\Exception\NoSuchEntityException'); @@ -56,19 +52,11 @@ public function genAdminInlineController( $construct->addParameter('coreRegistry')->setType('\Magento\Framework\Registry'); $construct->addParameter('context')->setType('\Magento\Backend\App\Action\Context'); - if ($typehint) { - $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); - $namespace->addUse('\Magento\Framework\Controller\Result\JsonFactory'); - $namespace->addUse($repository); - $namespace->addUse('\Magento\Framework\Registry'); - $namespace->addUse('\Magento\Backend\App\Action\Context'); - } else { - $construct - ->addComment('@param \Magento\Framework\Controller\Result\JsonFactory $jsonFactory') - ->addComment('@param ' . $repository . ' $repository') - ->addComment('@param \Magento\Framework\Registry $coreRegistry') - ->addComment('@param \Magento\Backend\App\Action\Context $context'); - } + $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); + $namespace->addUse('\Magento\Framework\Controller\Result\JsonFactory'); + $namespace->addUse($repository); + $namespace->addUse('\Magento\Framework\Registry'); + $namespace->addUse('\Magento\Backend\App\Action\Context'); $execute = $class->addMethod('execute') ->addComment('Execute action') @@ -105,12 +93,8 @@ public function genAdminInlineController( . self::TAB . '\'error\' => $error' . PHP_EOL . ']);' . PHP_EOL); - if ($typehint) { - $execute->setReturnType('\Magento\Framework\Controller\ResultInterface'); - $namespace->addUse('\Magento\Framework\Controller\ResultInterface'); - } else { - $execute->addComment('@return \Magento\Framework\Controller\ResultInterface'); - } + $execute->setReturnType('\Magento\Framework\Controller\ResultInterface'); + $namespace->addUse('\Magento\Framework\Controller\ResultInterface'); return $namespace; } diff --git a/src/Jeeves/Generators/Crud/Controllers/Mass.php b/src/Jeeves/Generators/Crud/Controllers/Mass.php index af40639..2066975 100644 --- a/src/Jeeves/Generators/Crud/Controllers/Mass.php +++ b/src/Jeeves/Generators/Crud/Controllers/Mass.php @@ -15,7 +15,6 @@ public function genAdminMassController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $constructorProp = $this->hasConstructorProp($phpVersion); $readonlyProp = $this->hasReadOnlyProp($phpVersion); @@ -25,11 +24,9 @@ public function genAdminMassController( $class = $namespace->addClass($className) ->setExtends($rootNamespace . '\Controller\Adminhtml\\' . $entity); - if ($typehint) { - $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); - $namespace->addUse('\Magento\Ui\Component\MassAction\Filter'); - $namespace->addUse($collection); - } + $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); + $namespace->addUse('\Magento\Ui\Component\MassAction\Filter'); + $namespace->addUse($collection); if (!$constructorProp) { $filter = $class->addProperty('filter') @@ -38,13 +35,8 @@ public function genAdminMassController( $collect = $class->addProperty('collectionFactory') ->setVisibility('private'); - if ($typehint) { - $filter->setType('\Magento\Ui\Component\MassAction\Filter'); - $collect->setType($collection); - } else { - $filter->addComment('@var \Magento\Ui\Component\MassAction\Filter'); - $collect->addComment('@var ' . $collection); - } + $filter->setType('\Magento\Ui\Component\MassAction\Filter'); + $collect->setType($collection); } $body = ''; @@ -55,18 +47,9 @@ public function genAdminMassController( $body .= 'parent::__construct($repository, $coreRegistry, $context);'; $construct = $class->addMethod('__construct')->setBody($body); - if ($typehint) { - $namespace->addUse($repository); - $namespace->addUse('\Magento\Framework\Registry'); - $namespace->addUse('\Magento\Backend\App\Action\Context'); - } else { - $construct - ->addComment('@param ' . $collection . ' $collectionFactory') - ->addComment('@param \Magento\Ui\Component\MassAction\Filter $filter') - ->addComment('@param ' . $repository . ' $repository') - ->addComment('@param \Magento\Framework\Registry $coreRegistry') - ->addComment('@param \Magento\Backend\App\Action\Context $context'); - } + $namespace->addUse($repository); + $namespace->addUse('\Magento\Framework\Registry'); + $namespace->addUse('\Magento\Backend\App\Action\Context'); if ($constructorProp) { $construct @@ -109,12 +92,8 @@ public function genAdminMassController( . '$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);' . PHP_EOL . 'return $resultRedirect->setPath(\'*/*/\');' . PHP_EOL); - if ($typehint) { - $execute->setReturnType('\Magento\Framework\Controller\ResultInterface'); - $namespace->addUse('\Magento\Framework\Controller\ResultInterface'); - } else { - $execute->addComment('@return \Magento\Framework\Controller\ResultInterface'); - } + $execute->setReturnType('\Magento\Framework\Controller\ResultInterface'); + $namespace->addUse('\Magento\Framework\Controller\ResultInterface'); return $namespace; } diff --git a/src/Jeeves/Generators/Crud/Controllers/Save.php b/src/Jeeves/Generators/Crud/Controllers/Save.php index 9a8a4e4..e678071 100644 --- a/src/Jeeves/Generators/Crud/Controllers/Save.php +++ b/src/Jeeves/Generators/Crud/Controllers/Save.php @@ -16,7 +16,6 @@ public function genAdminSaveController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $constructorProp = $this->hasConstructorProp($phpVersion); $readonlyProp = $this->hasReadOnlyProp($phpVersion); @@ -34,13 +33,8 @@ public function genAdminSaveController( $factory = $class->addProperty('entityFactory') ->setVisibility('private'); - if ($typehint) { - $factory->setType($entityClass . 'Factory'); - $persistor->setType('\Magento\Framework\App\Request\DataPersistorInterface'); - } else { - $persistor->addComment('@var \Magento\Framework\App\Request\DataPersistorInterface'); - $factory->addComment('@var ' . $entityClass . 'Factory'); - } + $factory->setType($entityClass . 'Factory'); + $persistor->setType('\Magento\Framework\App\Request\DataPersistorInterface'); } $body = 'parent::__construct($repository, $coreRegistry, $context);'; @@ -51,23 +45,14 @@ public function genAdminSaveController( } $construct = $class->addMethod('__construct')->setBody($body); - if ($typehint) { - $namespace - ->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity) - ->addUse('\Magento\Framework\App\Request\DataPersistorInterface') - ->addUse($entityClass . 'Factory') - ->addUse($repository) - ->addUse('\Magento\Framework\Registry') - ->addUse('\Magento\Backend\App\Action\Context') - ->addUse('\Magento\Framework\Exception\NoSuchEntityException'); - } else { - $construct - ->addComment('@param \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor') - ->addComment('@param ' . $entityClass . 'Factory $entityFactory') - ->addComment('@param ' . $repository . ' $repository') - ->addComment('@param \Magento\Framework\Registry $coreRegistry') - ->addComment('@param \Magento\Backend\App\Action\Context $context'); - } + $namespace + ->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity) + ->addUse('\Magento\Framework\App\Request\DataPersistorInterface') + ->addUse($entityClass . 'Factory') + ->addUse($repository) + ->addUse('\Magento\Framework\Registry') + ->addUse('\Magento\Backend\App\Action\Context') + ->addUse('\Magento\Framework\Exception\NoSuchEntityException'); if ($constructorProp) { $construct @@ -142,13 +127,8 @@ public function genAdminSaveController( . '$this->dataPersistor->set(\'' . $this->camelCaseToSnakeCase($shortName) . '\', $data);' . PHP_EOL . PHP_EOL . 'return $resultRedirect->setPath(\'*/*/edit\', [\'id\' => $this->getRequest()->getParam(\'id\')]);'); - if ($typehint) { - $execute->setReturnType('\Magento\Framework\Controller\ResultInterface'); - $namespace->addUse('\Magento\Framework\Controller\ResultInterface'); - } else { - $execute->addComment(''); - $execute->addComment('@return \Magento\Framework\Controller\ResultInterface'); - } + $execute->setReturnType('\Magento\Framework\Controller\ResultInterface'); + $namespace->addUse('\Magento\Framework\Controller\ResultInterface'); return $namespace; } diff --git a/src/Jeeves/Generators/Crud/Controllers/Shared.php b/src/Jeeves/Generators/Crud/Controllers/Shared.php index fe21968..8360d3e 100644 --- a/src/Jeeves/Generators/Crud/Controllers/Shared.php +++ b/src/Jeeves/Generators/Crud/Controllers/Shared.php @@ -14,15 +14,12 @@ public function genAdminAbstractController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $constructorProp = $this->hasConstructorProp($phpVersion); $readonlyProp = $this->hasReadOnlyProp($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Controller\Adminhtml'); - if ($typehint) { - $namespace->addUse('\Magento\Backend\App\Action'); - } + $namespace->addUse('\Magento\Backend\App\Action'); $class = $namespace->addClass($className) ->setAbstract() @@ -32,33 +29,19 @@ public function genAdminAbstractController( ->addComment('') ->addComment('@see _isAllowed()'); - if ($typehint) { - $namespace->addUse('\Magento\Framework\Registry'); - $namespace->addUse($repository); - } + $namespace->addUse('\Magento\Framework\Registry'); + $namespace->addUse($repository); if (!$constructorProp) { $reg = $class->addProperty('coreRegistry') ->setVisibility('protected'); - if ($typehint) { - $reg->setType('\Magento\Framework\Registry'); - } else { - $reg->addComment('Core registry'); - $reg->addComment(''); - $reg->addComment('@var \Magento\Framework\Registry'); - } + $reg->setType('\Magento\Framework\Registry'); $repo = $class->addProperty('repository') ->setVisibility('protected'); - if ($typehint) { - $repo->setType($repository); - } else { - $repo->addComment($className . ' repository') - ->addComment('') - ->addComment('@var ' . $repository); - } + $repo->setType($repository); } $body = 'parent::__construct($context);'; @@ -88,13 +71,6 @@ public function genAdminAbstractController( } $construct->addParameter('context')->setType('\Magento\Backend\App\Action\Context'); - if (!$typehint) { - $construct - ->addComment('@param ' . $repository . ' $repository') - ->addComment('@param \Magento\Framework\Registry $coreRegistry') - ->addComment('@param \Magento\Backend\App\Action\Context $context'); - } - return $namespace; } } diff --git a/src/Jeeves/Generators/Crud/Controllers/View.php b/src/Jeeves/Generators/Crud/Controllers/View.php index af751b3..c8ec882 100644 --- a/src/Jeeves/Generators/Crud/Controllers/View.php +++ b/src/Jeeves/Generators/Crud/Controllers/View.php @@ -15,7 +15,6 @@ public function genAdminViewController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $constructorProp = $this->hasConstructorProp($phpVersion); $readonlyProp = $this->hasReadOnlyProp($phpVersion); @@ -24,11 +23,9 @@ public function genAdminViewController( $class = $namespace->addClass('Index') ->setExtends($rootNamespace . '\Controller\Adminhtml\\' . $entity); - if ($typehint) { - $namespace->addUse('\Magento\Framework\View\Result\PageFactory'); - $namespace->addUse('\Magento\Framework\App\Request\DataPersistorInterface'); - $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); - } + $namespace->addUse('\Magento\Framework\View\Result\PageFactory'); + $namespace->addUse('\Magento\Framework\App\Request\DataPersistorInterface'); + $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); if (!$constructorProp) { $result = $class->addProperty('resultPageFactory') @@ -36,13 +33,8 @@ public function genAdminViewController( $pers = $class->addProperty('dataPersistor') ->setVisibility('private'); - if ($typehint) { - $result->setType('\Magento\Framework\View\Result\PageFactory'); - $pers->setType('\Magento\Framework\App\Request\DataPersistorInterface'); - } else { - $pers->addComment('@var \Magento\Framework\App\Request\DataPersistorInterface'); - $result->addComment('@var \Magento\Framework\View\Result\PageFactory'); - } + $result->setType('\Magento\Framework\View\Result\PageFactory'); + $pers->setType('\Magento\Framework\App\Request\DataPersistorInterface'); } $body = 'parent::__construct($repository, $coreRegistry, $context);'; @@ -78,18 +70,9 @@ public function genAdminViewController( $construct->addParameter('coreRegistry')->setType('\Magento\Framework\Registry'); $construct->addParameter('context')->setType('\Magento\Backend\App\Action\Context'); - if ($typehint) { - $namespace->addUse($repository); - $namespace->addUse('\Magento\Framework\Registry'); - $namespace->addUse('\Magento\Backend\App\Action\Context'); - } else { - $construct - ->addComment('@param \Magento\Framework\View\Result\PageFactory $resultPageFactory') - ->addComment('@param \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor') - ->addComment('@param ' . $repository . ' $repository') - ->addComment('@param \Magento\Framework\Registry $coreRegistry') - ->addComment('@param \Magento\Backend\App\Action\Context $context'); - } + $namespace->addUse($repository); + $namespace->addUse('\Magento\Framework\Registry'); + $namespace->addUse('\Magento\Backend\App\Action\Context'); $execute = $class->addMethod('execute') ->addComment('Index action') @@ -103,12 +86,8 @@ public function genAdminViewController( . '$this->dataPersistor->clear(\'' . $this->camelCaseToSnakeCase($shortName) . '\');' . PHP_EOL . 'return $resultPage;'); - if ($typehint) { - $execute->setReturnType('\Magento\Framework\Controller\ResultInterface'); - $namespace->addUse('\Magento\Framework\Controller\ResultInterface'); - } else { - $execute->addComment('@return \Magento\Framework\Controller\ResultInterface'); - } + $execute->setReturnType('\Magento\Framework\Controller\ResultInterface'); + $namespace->addUse('\Magento\Framework\Controller\ResultInterface'); return $namespace; } diff --git a/src/Jeeves/Generators/Crud/Interfaces/Model.php b/src/Jeeves/Generators/Crud/Interfaces/Model.php index a9d52b5..2e0b118 100644 --- a/src/Jeeves/Generators/Crud/Interfaces/Model.php +++ b/src/Jeeves/Generators/Crud/Interfaces/Model.php @@ -17,7 +17,6 @@ public function genModelInterface( bool $withStore = false, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Api\Data'); $interface = $namespace->addInterface($className); @@ -60,17 +59,13 @@ public function genModelInterface( ->setVisibility('public'); $param = $set->addParameter($this->snakeCaseToCamelCase($name)); - if ($typehint) { - $get->setReturnType($this->convertType($value['type'])); - $get->setReturnNullable($generated ? true : !$notNullable); - $param->setNullable(!$notNullable); - $param->setType($this->convertType($value['type'])); - $set->setReturnType('self'); - } else { - $set->addComment('@param ' . $this->convertType($value['type']) . ' $' . $this->snakeCaseToCamelCase($name)); - } + $get->setReturnType($this->convertType($value['type'])); + $get->setReturnNullable($generated ? true : !$notNullable); + $param->setNullable(!$notNullable); + $param->setType($this->convertType($value['type'])); + $set->setReturnType('self'); - if ($hasApi || !$typehint) { + if ($hasApi) { $get->addComment('@return ' . $this->convertType($value['type']) . ($notNullable ? '' : '|null')); $set->addComment('@return $this'); } @@ -79,9 +74,7 @@ public function genModelInterface( $param->setNullable(false); $param->setType(null); - if ($typehint) { - $set->addComment('@param ' . $this->convertType($value['type']) . ' $' . $this->snakeCaseToCamelCase($name)); - } + $set->addComment('@param ' . $this->convertType($value['type']) . ' $' . $this->snakeCaseToCamelCase($name)); } } @@ -98,14 +91,12 @@ public function genModelInterface( ->addComment('Get ID') ->setVisibility('public'); - if ($hasApi || !$typehint) { + if ($hasApi) { $getId->addComment('@return ' . $this->convertType($item['type']) . ($item['nullable'] ? '|null' : '')); } - if ($typehint) { - $getId->setReturnType($this->convertType($item['type'])); - $getId->setReturnNullable($generated ? true : $item['nullable']); - } + $getId->setReturnType($this->convertType($item['type'])); + $getId->setReturnNullable($generated ? true : $item['nullable']); $setId = $interface ->addMethod('setId') @@ -115,15 +106,13 @@ public function genModelInterface( $setId->addParameter(self::DEFAULT_KEY); $setId->addComment('@param ' . $this->convertType($item['type']) . ' $id'); - if ($hasApi || !$typehint) { + if ($hasApi) { $setId->addComment('@return $this'); } - if ($typehint) { - $setId->setReturnType('self'); - // $setIdParam->setType($this->convertType($item['type'])); - // $setIdParam->setNullable($item['nullable']); - } + $setId->setReturnType('self'); + // $setIdParam->setType($this->convertType($item['type'])); + // $setIdParam->setNullable($item['nullable']); } return $namespace; diff --git a/src/Jeeves/Generators/Crud/Interfaces/Repository.php b/src/Jeeves/Generators/Crud/Interfaces/Repository.php index 557c33d..d2e243d 100644 --- a/src/Jeeves/Generators/Crud/Interfaces/Repository.php +++ b/src/Jeeves/Generators/Crud/Interfaces/Repository.php @@ -16,7 +16,6 @@ public function genModelRepositoryInterface( bool $hasApi = false, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Api'); $interface = $namespace->addInterface($className); @@ -24,26 +23,20 @@ public function genModelRepositoryInterface( $interface->addComment('@api'); } - if ($typehint) { - $namespace->addUse('\Magento\Framework\Api\SearchCriteriaInterface'); - } + $namespace->addUse('\Magento\Framework\Api\SearchCriteriaInterface'); $save = $interface->addMethod('save'); $save->addComment('Save ' . $print) ->setVisibility('public') ->addComment('@throws \Magento\Framework\Exception\LocalizedException'); - if ($hasApi || !$typehint) { + if ($hasApi) { $save->addComment('@return ' . $entInterface); } $save->addParameter('entity')->setType($entInterface); - if ($typehint) { - $save->setReturnType($entInterface); - } else { - $save->addComment('@param ' . $entInterface . ' $entity'); - } + $save->setReturnType($entInterface); $get = $interface->addMethod('getById'); $get->addComment('Retrieve ' . $print) @@ -52,16 +45,12 @@ public function genModelRepositoryInterface( $getParam = $get->addParameter('entityId'); - if ($hasApi || !$typehint) { + if ($hasApi) { $get->addComment('@return ' . $entInterface); } - if ($typehint) { - $get->setReturnType($entInterface); - $getParam->setType('int'); - } else { - $get->addComment('@param int $entityId'); - } + $get->setReturnType($entInterface); + $getParam->setType('int'); $getList = $interface->addMethod('getList'); $getList->addComment('Retrieve ' . $print . ' entities matching the specified criteria'); @@ -70,19 +59,14 @@ public function genModelRepositoryInterface( ->setVisibility('public') ->addComment('@throws \Magento\Framework\Exception\LocalizedException'); - if ($hasApi || !$typehint) { + if ($hasApi) { $getList->addComment('@return ' . $resultInterface); } $getList->addParameter('searchCriteria') ->setType('\Magento\Framework\Api\SearchCriteriaInterface'); - if ($typehint) { - $getList->setReturnType($resultInterface); - } else { - $getList - ->addComment('@param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria'); - } + $getList->setReturnType($resultInterface); $del = $interface->addMethod('delete'); $del @@ -90,18 +74,14 @@ public function genModelRepositoryInterface( ->setVisibility('public') ->addComment('@throws \Magento\Framework\Exception\LocalizedException'); - if ($hasApi || !$typehint) { + if ($hasApi) { $del->addComment('@return bool true on success'); } $del->addParameter('entity') ->setType($entInterface); - if ($typehint) { - $del->setReturnType('bool'); - } else { - $del->addComment('@param ' . $entInterface . ' $entity'); - } + $del->setReturnType('bool'); $delId = $interface->addMethod('deleteById'); $delId->addComment('Delete ' . $print) @@ -109,18 +89,14 @@ public function genModelRepositoryInterface( ->addComment('@throws \Magento\Framework\Exception\NoSuchEntityException') ->addComment('@throws \Magento\Framework\Exception\LocalizedException'); - if ($hasApi || !$typehint) { + if ($hasApi) { $delId->addComment('@return bool true on success'); } $delParam = $delId->addParameter('entityId'); - if ($typehint) { - $delId->setReturnType('bool'); - $delParam->setType('int'); - } else { - $delId->addComment('@param int $entityId'); - } + $delId->setReturnType('bool'); + $delParam->setType('int'); return $namespace; } diff --git a/src/Jeeves/Generators/Crud/Interfaces/Search.php b/src/Jeeves/Generators/Crud/Interfaces/Search.php index 0726aa4..8ab8ee8 100644 --- a/src/Jeeves/Generators/Crud/Interfaces/Search.php +++ b/src/Jeeves/Generators/Crud/Interfaces/Search.php @@ -15,7 +15,6 @@ public function genModelSearchInterface( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Api\Data'); $namespace->addUse('\Magento\Framework\Api\SearchResultsInterface'); @@ -25,9 +24,7 @@ public function genModelSearchInterface( $get = $interface->addMethod('getItems') ->setVisibility('public') ->addComment('Get list of ' . $print); - if ($typehint) { - // $get->setReturnType('array'); - } + $get->addComment('@return ' . $entInterface . '[]'); $set = $interface->addMethod('setItems') @@ -36,10 +33,6 @@ public function genModelSearchInterface( ->addComment('@param ' . $entInterface . '[] $items'); $set->addParameter('items')->setType('array'); - if ($typehint) { - // $set->setReturnType('self'); - } - return $namespace; } } diff --git a/src/Jeeves/Generators/Crud/Models/Collection.php b/src/Jeeves/Generators/Crud/Models/Collection.php index 0b07afd..9f621ae 100644 --- a/src/Jeeves/Generators/Crud/Models/Collection.php +++ b/src/Jeeves/Generators/Crud/Models/Collection.php @@ -18,82 +18,58 @@ public function genResourceCollection( bool $withStore = false, string $phpVersion = PHP_VERSION ) { - $typehint = $this->hasTypes($phpVersion); $constructorProp = $this->hasConstructorProp($phpVersion); $readonlyProp = $this->hasReadOnlyProp($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Model\ResourceModel\\' . $entity); - if ($typehint) { - $namespace->addUse('\Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection'); - $namespace->addUse($entityClass); - $namespace->addUse($resourceClass, $entity . 'Resource'); - } + + $namespace->addUse('\Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection'); + $namespace->addUse($entityClass); + $namespace->addUse($resourceClass, $entity . 'Resource'); + if ($withStore) { $namespace->addUse($rootNamespace . '\Api\Data\\' . $interface); } $class = $namespace->addClass('Collection'); $class->setExtends('\Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection'); - $construct = $class->addMethod('_construct') + $construct1 = $class->addMethod('_construct') ->addComment('Define resource model') ->setVisibility('protected'); - if ($typehint) { - $construct->setBody('$this->_init(' . PHP_EOL . - self::TAB . $entity . '::class,' . PHP_EOL . - self::TAB . $entity . 'Resource::class' . PHP_EOL . - ');'); - } else { - $construct->setBody('$this->_init(' . PHP_EOL . - self::TAB . $entityClass . '::class,' . PHP_EOL . - self::TAB . $resourceClass . '::class' . PHP_EOL . - ');'); - } + $construct1->setBody('$this->_init(' . PHP_EOL . + self::TAB . $entity . '::class,' . PHP_EOL . + self::TAB . $entity . 'Resource::class' . PHP_EOL . + ');'); + $idField = $class->addProperty('_idFieldName', $key) ->setVisibility('protected'); $idField->addComment('@var string'); - if ($typehint) { - $idField->setValue(new Literal($entity . 'Resource::TABLE_PRIMARY_KEY')); - } + $idField->setValue(new Literal($entity . 'Resource::TABLE_PRIMARY_KEY')); if (!$withStore) { return $namespace; } - if ($typehint) { - $namespace->addUse('\Magento\Framework\EntityManager\MetadataPool'); - $namespace->addUse('\Magento\Framework\Data\Collection\EntityFactoryInterface'); - $namespace->addUse('\Psr\Log\LoggerInterface'); - $namespace->addUse('\Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); - $namespace->addUse('\Magento\Framework\Event\ManagerInterface'); - $namespace->addUse('\Psr\Log\LoggerInterface'); - $namespace->addUse('\Magento\Framework\DB\Adapter\AdapterInterface'); - $namespace->addUse('\Magento\Framework\Model\ResourceModel\Db\AbstractDb'); - } + $namespace->addUse('\Magento\Framework\EntityManager\MetadataPool'); + $namespace->addUse('\Magento\Framework\Data\Collection\EntityFactoryInterface'); + $namespace->addUse('\Psr\Log\LoggerInterface'); + $namespace->addUse('\Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); + $namespace->addUse('\Magento\Framework\Event\ManagerInterface'); + $namespace->addUse('\Psr\Log\LoggerInterface'); + $namespace->addUse('\Magento\Framework\DB\Adapter\AdapterInterface'); + $namespace->addUse('\Magento\Framework\Model\ResourceModel\Db\AbstractDb'); if (!$constructorProp) { $mdPool = $class->addProperty('metadataPool'); $mdPool->setVisibility('private'); - if ($typehint) { - $mdPool->setType('\Magento\Framework\EntityManager\MetadataPool'); - } else { - $mdPool->addComment('@var \Magento\Framework\EntityManager\MetadataPool'); - } + $mdPool->setType('\Magento\Framework\EntityManager\MetadataPool'); } $construct = $class->addMethod('__construct')->setVisibility('public'); - if (!$typehint) { - $construct->addComment('@param \Magento\Framework\EntityManager\MetadataPool $metadataPool') - ->addComment('@param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory') - ->addComment('@param \Psr\Log\LoggerInterface $logger') - ->addComment('@param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy') - ->addComment('@param \Magento\Framework\Event\ManagerInterface $eventManager') - ->addComment('@param \Magento\Framework\DB\Adapter\AdapterInterface|string|null $connection') - ->addComment('@param \Magento\Framework\Model\ResourceModel\Db\AbstractDb|null $resource'); - } $construct->addComment('@SuppressWarnings(PHPMD.ExcessiveParameterList)'); if ($constructorProp) { diff --git a/src/Jeeves/Generators/Crud/Models/Model.php b/src/Jeeves/Generators/Crud/Models/Model.php index b99e435..1ba7337 100644 --- a/src/Jeeves/Generators/Crud/Models/Model.php +++ b/src/Jeeves/Generators/Crud/Models/Model.php @@ -18,7 +18,6 @@ public function genModel( bool $withStore = false, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Model'); $namespace->addUse('Magento\Framework\Model\AbstractModel'); $namespace->addUse($entInterface); @@ -41,11 +40,8 @@ public function genModel( $getCache = $class->addMethod('getIdentities'); $getCache->setVisibility('public') ->setBody('return [self::CACHE_TAG . \'_\' . $this->getId()];'); - if ($typehint) { - $getCache->setReturnType('array'); - } else { - $getCache->addComment('@return string[]'); - } + + $getCache->setReturnType('array'); } if ($withStore) { @@ -78,27 +74,18 @@ public function genModel( $setParam = $setter->addParameter($this->snakeCaseToCamelCase($name)); $setter->setBody('return $this->setData(self::' . strtoupper($name) . ', $' . $this->snakeCaseToCamelCase($name) . ');'); - if ($typehint) { - $getter->setReturnType($this->convertType($value['type'])); - $getter->setReturnNullable($generated ? true : !$notNullable); - - $setter->setReturnType('self'); - $setParam->setType($this->convertType($value['type'])); - $setParam->setNullable(!$notNullable); - } else { - $getter->addComment('@return ' . $this->convertType($value['type']) . ($notNullable ? '' : '|null')); - $setter - ->addComment('@param ' . $this->convertType($value['type']) . ' $' . $this->snakeCaseToCamelCase($name)) - ->addComment('@return $this'); - } + $getter->setReturnType($this->convertType($value['type'])); + $getter->setReturnNullable($generated ? true : !$notNullable); + + $setter->setReturnType('self'); + $setParam->setType($this->convertType($value['type'])); + $setParam->setNullable(!$notNullable); if ($this->snakeCaseToCamelCase($name) == 'id') { $setParam->setNullable(false); $setParam->setType(null); - if ($typehint) { - $setter->addComment('@param ' . $this->convertType($value['type']) . ' $' . $this->snakeCaseToCamelCase($name)); - } + $setter->addComment('@param ' . $this->convertType($value['type']) . ' $' . $this->snakeCaseToCamelCase($name)); } } @@ -116,10 +103,9 @@ public function genModel( ->addComment('Get ID') ->setVisibility('public') ->setBody('return $this->getData(self::' . strtoupper($itemName) . ');'); - if ($typehint) { - $getId->setReturnType($this->convertType($item['type'])); - $getId->setReturnNullable($generated ? true : $item['nullable']); - } + + $getId->setReturnType($this->convertType($item['type'])); + $getId->setReturnNullable($generated ? true : $item['nullable']); $setId = $class ->addMethod('setId') @@ -129,12 +115,10 @@ public function genModel( $setIdParam = $setId->addParameter('id'); $setId->addComment('@param ' . $this->convertType($item['type']) . ' $id'); - if ($typehint) { - $setId->setReturnType('self'); + $setId->setReturnType('self'); - //$setIdParam->setType($this->convertType($item['type'])); - //$setIdParam->setNullable($item['nullable']); - } + //$setIdParam->setType($this->convertType($item['type'])); + //$setIdParam->setNullable($item['nullable']); } return $namespace; diff --git a/src/Jeeves/Generators/Crud/Models/Read.php b/src/Jeeves/Generators/Crud/Models/Read.php index d85de26..8881f01 100644 --- a/src/Jeeves/Generators/Crud/Models/Read.php +++ b/src/Jeeves/Generators/Crud/Models/Read.php @@ -14,7 +14,6 @@ public function genReadHandler( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $constructorProp = $this->hasConstructorProp($phpVersion); $readonlyProp = $this->hasReadOnlyProp($phpVersion); @@ -24,22 +23,15 @@ public function genReadHandler( $class = $namespace->addClass('ReadHandler'); $class->addImplement('\Magento\Framework\EntityManager\Operation\ExtensionInterface'); - if ($typehint) { - $namespace->addUse('\Magento\Framework\EntityManager\Operation\ExtensionInterface'); - $namespace->addUse($resourceClass); - } + $namespace->addUse('\Magento\Framework\EntityManager\Operation\ExtensionInterface'); + $namespace->addUse($resourceClass); if (!$constructorProp) { $res = $class->addProperty('resource')->setVisibility('private'); - if ($typehint) { - $res->setType($resourceClass); - } else { - $res->addComment('@var ' . $resourceClass); - } + $res->setType($resourceClass); } - $construct = $class->addMethod('__construct') - ->setVisibility('public'); + $construct = $class->addMethod('__construct')->setVisibility('public'); if ($constructorProp) { $construct ->addPromotedParameter('resource') diff --git a/src/Jeeves/Generators/Crud/Models/Resource.php b/src/Jeeves/Generators/Crud/Models/Resource.php index b4587f2..90a7af0 100644 --- a/src/Jeeves/Generators/Crud/Models/Resource.php +++ b/src/Jeeves/Generators/Crud/Models/Resource.php @@ -16,15 +16,12 @@ public function genResourceModel( bool $withStore = false, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $constructorProp = $this->hasConstructorProp($phpVersion); $readonlyProp = $this->hasReadOnlyProp($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Model\ResourceModel'); - if ($typehint) { - $namespace->addUse('Magento\Framework\Model\ResourceModel\Db\AbstractDb'); - } + $namespace->addUse('Magento\Framework\Model\ResourceModel\Db\AbstractDb'); if ($withStore) { $namespace->addUse('Magento\Framework\Model\AbstractModel'); @@ -37,15 +34,11 @@ public function genResourceModel( $class->addConstant('TABLE_NAME', $table)->setVisibility('public'); $class->addConstant('TABLE_PRIMARY_KEY', $key)->setVisibility('public'); - $construct = $class->addMethod('_construct') + $class->addMethod('_construct') ->addComment('Initialize resource model') ->setVisibility('protected') ->setBody('$this->_init(self::TABLE_NAME, self::TABLE_PRIMARY_KEY);'); - if (!$typehint) { - $construct->addComment('@return void'); - } - if (!$withStore) { return $namespace; } @@ -57,30 +50,16 @@ public function genResourceModel( $mdPool = $class->addProperty('metadataPool'); $mdPool->setVisibility('private'); - if ($typehint) { - $em->setType('\Magento\Framework\EntityManager\EntityManager'); - $mdPool->setType('\Magento\Framework\EntityManager\MetadataPool'); - } else { - $em->addComment('@var \Magento\Framework\EntityManager\EntityManager'); - $mdPool->addComment('@var \Magento\Framework\EntityManager\MetadataPool'); - } + $em->setType('\Magento\Framework\EntityManager\EntityManager'); + $mdPool->setType('\Magento\Framework\EntityManager\MetadataPool'); } - if ($typehint) { - $namespace->addUse('\Magento\Framework\EntityManager\EntityManager') - ->addUse('\Magento\Framework\EntityManager\MetadataPool') - ->addUse('\Magento\Framework\Model\ResourceModel\Db\Context'); - } + $namespace->addUse('\Magento\Framework\EntityManager\EntityManager') + ->addUse('\Magento\Framework\EntityManager\MetadataPool') + ->addUse('\Magento\Framework\Model\ResourceModel\Db\Context'); $construct = $class->addMethod('__construct'); $construct->setVisibility('public'); - if (!$typehint) { - $construct - ->addComment('@param \Magento\Framework\EntityManager\EntityManager $entityManager') - ->addComment('@param \Magento\Framework\EntityManager\MetadataPool $metadataPool') - ->addComment('@param \Magento\Framework\Model\ResourceModel\Db\Context $context') - ->addComment('@param string $connectionName'); - } if ($constructorProp) { $construct @@ -105,9 +84,7 @@ public function genResourceModel( $construct->addParameter('context')->setType('\Magento\Framework\Model\ResourceModel\Db\Context'); $conParam = $construct->addParameter('connectionName')->setDefaultValue(null); - if ($typehint) { - $conParam->setType('string'); - } + $conParam->setType('string'); $body = 'parent::__construct($context, $connectionName);'; if (!$constructorProp) { @@ -154,14 +131,10 @@ public function genResourceModel( ->setVisibility('public'); $lookIdParam = $lookup->addParameter('id'); - if ($typehint) { - $lookup->setReturnType('array'); - $lookIdParam->setType('int'); - } else { - $lookup - ->addComment('@param int $id') - ->addComment('@return array'); - } + + $lookup->setReturnType('array'); + $lookIdParam->setType('int'); + $lookup->setBody( '$connection = $this->getConnection();' . PHP_EOL . PHP_EOL diff --git a/src/Jeeves/Generators/Crud/Models/Save.php b/src/Jeeves/Generators/Crud/Models/Save.php index 8ef7b15..0834d29 100644 --- a/src/Jeeves/Generators/Crud/Models/Save.php +++ b/src/Jeeves/Generators/Crud/Models/Save.php @@ -14,7 +14,6 @@ public function genSaveHandler( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $constructorProp = $this->hasConstructorProp($phpVersion); $readonlyProp = $this->hasReadOnlyProp($phpVersion); @@ -26,21 +25,14 @@ public function genSaveHandler( $class = $namespace->addClass('SaveHandler'); $class->addImplement('\Magento\Framework\EntityManager\Operation\ExtensionInterface'); - if ($typehint) { - $namespace->addUse('\Magento\Framework\EntityManager\Operation\ExtensionInterface'); - } + $namespace->addUse('\Magento\Framework\EntityManager\Operation\ExtensionInterface'); if (!$constructorProp) { $res = $class->addProperty('resource')->setVisibility('private'); $mtdPool = $class->addProperty('metadataPool')->setVisibility('private'); - if ($typehint) { - $res->setType($resourceClass); - $mtdPool->setType('\Magento\Framework\EntityManager\MetadataPool'); - } else { - $res->addComment('@var ' . $resourceClass); - $mtdPool->addComment('@var \Magento\Framework\EntityManager\MetadataPool'); - } + $res->setType($resourceClass); + $mtdPool->setType('\Magento\Framework\EntityManager\MetadataPool'); } $construct = $class->addMethod('__construct')->setVisibility('public'); diff --git a/src/Jeeves/Generators/Crud/Repositories/Filter.php b/src/Jeeves/Generators/Crud/Repositories/Filter.php index c9c31b3..754ce28 100644 --- a/src/Jeeves/Generators/Crud/Repositories/Filter.php +++ b/src/Jeeves/Generators/Crud/Repositories/Filter.php @@ -13,8 +13,6 @@ public function getRepoFilter( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); - $namespace = new PhpNamespace($rootNamespace . '\Model\SearchCriteria'); $namespace->addUse($interface); $namespace->addUse('Magento\Framework\Api\Filter'); @@ -27,9 +25,7 @@ public function getRepoFilter( $apply->addParameter('filter')->setType('Magento\Framework\Api\Filter'); $apply->addParameter('collection')->setType('Magento\Framework\Data\Collection\AbstractDb'); - if ($typehint) { - $apply->setReturnType('bool'); - } + $apply->setReturnType('bool'); $apply->setBody( '$collection->addFilter(' . PHP_EOL diff --git a/src/Jeeves/Generators/Crud/Repositories/Repository.php b/src/Jeeves/Generators/Crud/Repositories/Repository.php index d59d8e0..800b63f 100644 --- a/src/Jeeves/Generators/Crud/Repositories/Repository.php +++ b/src/Jeeves/Generators/Crud/Repositories/Repository.php @@ -19,7 +19,6 @@ public function genRepository( bool $withStore = false, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $constructorProp = $this->hasConstructorProp($phpVersion); $readonlyProp = $this->hasReadOnlyProp($phpVersion); $readonlyClass = $this->hasReadOnlyClass($phpVersion); @@ -47,39 +46,24 @@ public function genRepository( ->setVisibility('private'); $sr = $class->addProperty('searchResultsFactory') ->setVisibility('private'); - if ($typehint) { - $namespace->addUse($repoInterface); - $namespace->addUse($collection . 'Factory'); - $namespace->addUse($entityInterface . 'Factory'); - $namespace->addUse($results . 'Factory'); - - $rs->setType($resource); - $cf->setType($collection . 'Factory'); - $ef->setType($entityInterface . 'Factory'); - $sr->setType($results . 'Factory'); - } else { - $rs->addComment('@var ' . $resource); - $cf->addComment('@var ' . $collection . 'Factory'); - $ef->addComment('@var ' . $entityInterface . 'Factory'); - $sr->addComment('@var ' . $results . 'Factory'); - } - } - if ($typehint) { $namespace->addUse($repoInterface); $namespace->addUse($collection . 'Factory'); $namespace->addUse($entityInterface . 'Factory'); $namespace->addUse($results . 'Factory'); + + $rs->setType($resource); + $cf->setType($collection . 'Factory'); + $ef->setType($entityInterface . 'Factory'); + $sr->setType($results . 'Factory'); } + $namespace->addUse($repoInterface); + $namespace->addUse($collection . 'Factory'); + $namespace->addUse($entityInterface . 'Factory'); + $namespace->addUse($results . 'Factory'); + $construct = $class->addMethod('__construct')->setVisibility('public'); - if (!$typehint) { - $construct - ->addComment('@param ' . $resource . ' $resource') - ->addComment('@param ' . $collection . 'Factory $collectionFactory') - ->addComment('@param ' . $entityInterface . 'Factory $entityFactory') - ->addComment('@param ' . $results . 'Factory $searchResultsFactory'); - } if ($constructorProp) { $construct @@ -122,11 +106,8 @@ public function genRepository( if (!$constructorProp) { $sm = $class->addProperty('storeManager')->setPrivate(); - if ($typehint) { - $sm->setType('\Magento\Store\Model\StoreManagerInterface'); - } else { - $sm->addComment('@var StoreManagerInterface'); - } + + $sm->setType('\Magento\Store\Model\StoreManagerInterface'); } if ($constructorProp) { @@ -139,20 +120,14 @@ public function genRepository( $construct ->addParameter('storeManager') ->setType('\Magento\Store\Model\StoreManagerInterface'); - if (!$typehint) { - $construct->addComment('@param StoreManagerInterface $storeManager'); - } } } if (!$constructorProp) { $cp = $class->addProperty('collectionProcessor') ->setPrivate(); - if ($typehint) { - $cp->setType('\Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface'); - } else { - $cp->addComment('@var CollectionProcessorInterface'); - } + + $cp->setType('\Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface'); } if ($constructorProp) { @@ -165,10 +140,6 @@ public function genRepository( ->setType('Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface'); } - if (!$typehint) { - $construct->addComment('@param CollectionProcessorInterface $collectionProcessor'); - } - if (!$constructorProp) { $construct->setBody('$this->resource = $resource;' . PHP_EOL . '$this->collectionFactory = $collectionFactory;' . PHP_EOL @@ -181,17 +152,10 @@ public function genRepository( $getById = $class->addMethod('getById')->setVisibility('public'); $getByIdParam = $getById->addParameter('entityId'); - if ($typehint) { - $namespace->addUse($entityInterface); - $getById->addComment('@throws NoSuchEntityException'); - $getById->setReturnType($entityInterface); - $getByIdParam->setType('int'); - } else { - $getById - ->addComment('@throws \Magento\Framework\Exception\NoSuchEntityException') - ->addComment('@param int $entityId') - ->addComment('@return ' . $entityInterface); - } + $namespace->addUse($entityInterface); + $getById->addComment('@throws NoSuchEntityException'); + $getById->setReturnType($entityInterface); + $getByIdParam->setType('int'); $getById->setBody('$entity = $this->entityFactory->create();' . PHP_EOL . '$this->resource->load($entity, $entityId);' . PHP_EOL @@ -206,15 +170,8 @@ public function genRepository( $save->addParameter('entity')->setType($entityInterface); - if ($typehint) { - $save->addComment('@throws CouldNotSaveException'); - $save->setReturnType($entityInterface); - } else { - $save - ->addComment('@throws \Magento\Framework\Exception\CouldNotSaveException') - ->addComment('@param ' . $entityInterface . ' $entity') - ->addComment('@return ' . $entityInterface); - } + $save->addComment('@throws CouldNotSaveException'); + $save->setReturnType($entityInterface); $save->addBody( ($withStore ? 'if (empty($entity->getStoreId())) {' . PHP_EOL @@ -235,15 +192,8 @@ public function genRepository( $delete->addParameter('entity')->setType($entityInterface); - if ($typehint) { - $delete->addComment('@throws CouldNotDeleteException'); - $delete->setReturnType('bool'); - } else { - $delete - ->addComment('@throws \Magento\Framework\Exception\CouldNotDeleteException') - ->addComment('@param ' . $entityInterface . ' $entity') - ->addComment('@return bool'); - } + $delete->addComment('@throws CouldNotDeleteException'); + $delete->setReturnType('bool'); $delete->setBody('try {' . PHP_EOL . self::TAB . '$this->resource->delete($entity);' . PHP_EOL @@ -258,18 +208,10 @@ public function genRepository( $deleteByIdParam = $deleteById->addParameter('entityId'); - if ($typehint) { - $deleteById->addComment('@throws NoSuchEntityException'); - $deleteById->addComment('@throws CouldNotDeleteException'); - $deleteById->setReturnType('bool'); - $deleteByIdParam->setType('int'); - } else { - $deleteById - ->addComment('@throws \Magento\Framework\Exception\NoSuchEntityException') - ->addComment('@throws \Magento\Framework\Exception\CouldNotDeleteException') - ->addComment('@param int $entityId') - ->addComment('@return bool'); - } + $deleteById->addComment('@throws NoSuchEntityException'); + $deleteById->addComment('@throws CouldNotDeleteException'); + $deleteById->setReturnType('bool'); + $deleteByIdParam->setType('int'); $deleteById->setBody('return $this->delete($this->getById($entityId));'); @@ -279,15 +221,9 @@ public function genRepository( $getList->addParameter('criteria')->setType('\Magento\Framework\Api\SearchCriteriaInterface'); - if ($typehint) { - $namespace->addUse('\Magento\Framework\Api\SearchCriteriaInterface'); - $namespace->addUse($results); - $getList->setReturnType($results); - } else { - $getList - ->addComment('@param \Magento\Framework\Api\SearchCriteriaInterface $criteria') - ->addComment('@return ' . $results); - } + $namespace->addUse('\Magento\Framework\Api\SearchCriteriaInterface'); + $namespace->addUse($results); + $getList->setReturnType($results); $getList->setBody('/** @var ' . $collection . ' $collection */' . PHP_EOL . '$collection = $this->collectionFactory->create();' . PHP_EOL . PHP_EOL diff --git a/src/Jeeves/Generators/Crud/Repositories/Search.php b/src/Jeeves/Generators/Crud/Repositories/Search.php index f9b6a20..171b03c 100644 --- a/src/Jeeves/Generators/Crud/Repositories/Search.php +++ b/src/Jeeves/Generators/Crud/Repositories/Search.php @@ -13,8 +13,6 @@ public function genModelSearch( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); - $namespace = new PhpNamespace($rootNamespace . '\Model'); $namespace->addUse($interface); $namespace->addUse('\Magento\Framework\Api\SearchResults'); diff --git a/src/Jeeves/Generators/Crud/Ui/Actions.php b/src/Jeeves/Generators/Crud/Ui/Actions.php index f3cd55e..e5c4ee4 100644 --- a/src/Jeeves/Generators/Crud/Ui/Actions.php +++ b/src/Jeeves/Generators/Crud/Ui/Actions.php @@ -15,7 +15,6 @@ public function getActions( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Ui\Component\Listing'); $class = $namespace->addClass($className); $class->setExtends('\Mygento\Base\Ui\Component\Listing\Actions'); @@ -24,24 +23,15 @@ public function getActions( $cont = $class->addProperty('controller', $controller) ->setVisibility('protected'); - if ($typehint) { - $namespace->addUse('\Mygento\Base\Ui\Component\Listing\Actions'); - $router->setType('string'); - $cont->setType('string'); - } else { - $router->addComment('@var string'); - $cont->addComment('@var string'); - } + $namespace->addUse('\Mygento\Base\Ui\Component\Listing\Actions'); + $router->setType('string'); + $cont->setType('string'); if ($primaryKey !== 'id') { $key = $class->addProperty('key', $primaryKey) ->setVisibility('protected'); - if ($typehint) { - $key->setType('string'); - } else { - $key->addComment('@var string'); - } + $key->setType('string'); } return $namespace; diff --git a/src/Jeeves/Generators/Crud/Ui/DataProvider.php b/src/Jeeves/Generators/Crud/Ui/DataProvider.php index 89e1fd1..af1bb7d 100644 --- a/src/Jeeves/Generators/Crud/Ui/DataProvider.php +++ b/src/Jeeves/Generators/Crud/Ui/DataProvider.php @@ -16,15 +16,12 @@ public function getProvider( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Model\\' . ucfirst($entity)); $namespace->addUse('Magento\Framework\App\Request\DataPersistorInterface'); $namespace->addUse($collectionFactory); - if ($typehint) { - $namespace->addUse('\Magento\Ui\DataProvider\ModifierPoolDataProvider'); - $namespace->addUse($collection); - } + $namespace->addUse('\Magento\Ui\DataProvider\ModifierPoolDataProvider'); + $namespace->addUse($collection); $class = $namespace->addClass($className); $class->setExtends('\Magento\Ui\DataProvider\ModifierPoolDataProvider'); @@ -40,29 +37,12 @@ public function getProvider( $namespace->addUse('\Magento\Ui\DataProvider\Modifier\PoolInterface'); - if ($typehint) { - //$collect->setType($collection); - $persist->setType('\Magento\Framework\App\Request\DataPersistorInterface'); - $loaded->setType('array'); - } else { - $persist->addComment('@var DataPersistorInterface'); - $loaded->addComment('@var array'); - } + //$collect->setType($collection); + $persist->setType('\Magento\Framework\App\Request\DataPersistorInterface'); + $loaded->setType('array'); $construct = $class->addMethod('__construct')->setVisibility('public'); - if (!$typehint) { - $construct - ->addComment('@param \\' . $collectionFactory . ' $collectionFactory') - ->addComment('@param \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor') - ->addComment('@param string $name') - ->addComment('@param string $primaryFieldName') - ->addComment('@param string $requestFieldName') - ->addComment('@param array $meta') - ->addComment('@param array $data') - ->addComment('@param \Magento\Ui\DataProvider\Modifier\PoolInterface|null $pool'); - } - $construct->addParameter('collectionFactory')->setType($collectionFactory); $construct->addParameter('dataPersistor')->setType('\Magento\Framework\App\Request\DataPersistorInterface'); $construct->addParameter('name')->setType('string'); @@ -94,11 +74,7 @@ public function getProvider( . '}' . PHP_EOL . 'return $this->loadedData;'); - if ($typehint) { - $getData->setReturnType('array'); - } else { - $getData->addComment('@return array'); - } + $getData->setReturnType('array'); return $namespace; } diff --git a/src/Jeeves/Generators/Crud/Ui/Grid.php b/src/Jeeves/Generators/Crud/Ui/Grid.php index 8870408..045b22d 100644 --- a/src/Jeeves/Generators/Crud/Ui/Grid.php +++ b/src/Jeeves/Generators/Crud/Ui/Grid.php @@ -16,8 +16,6 @@ public function generateGridCollection( bool $withStore = false, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = $this->hasTypes($phpVersion); - $namespace = new PhpNamespace($rootNamespace . '\Model\\ResourceModel\\' . ucfirst($entity) . '\\Grid'); $namespace->addUse('Magento\Framework\Api\Search\SearchResultInterface'); $namespace->addUse('Magento\Framework\Api\SearchCriteriaInterface'); @@ -29,17 +27,11 @@ public function generateGridCollection( $agg = $class->addProperty('aggregations') ->setVisibility('protected'); //private? - if ($typehint) { - $namespace->addUse('\Magento\Framework\Api\Search\AggregationInterface'); - $agg->setType('\Magento\Framework\Api\Search\AggregationInterface'); - } else { - $agg->addComment('@var \Magento\Framework\Api\Search\AggregationInterface'); - } + $namespace->addUse('\Magento\Framework\Api\Search\AggregationInterface'); + $agg->setType('\Magento\Framework\Api\Search\AggregationInterface'); $construct = $class->addMethod('__construct'); - if ($withStore && !$typehint) { - $construct->addComment('@param \Magento\Framework\EntityManager\MetadataPool $metadataPool'); - } + $construct ->setVisibility('public'); @@ -60,29 +52,14 @@ public function generateGridCollection( $construct->addParameter('connection')->setType('\Magento\Framework\DB\Adapter\AdapterInterface')->setDefaultValue(null); $construct->addParameter('resource')->setType('\Magento\Framework\Model\ResourceModel\Db\AbstractDb')->setDefaultValue(null); - if ($typehint) { - $namespace->addUse('\Magento\Framework\Data\Collection\EntityFactoryInterface'); - $namespace->addUse('\Psr\Log\LoggerInterface'); - $namespace->addUse('\Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); - $namespace->addUse('\Magento\Framework\Event\ManagerInterface'); - $namespace->addUse('\Magento\Framework\DB\Adapter\AdapterInterface'); - $namespace->addUse('\Magento\Framework\Model\ResourceModel\Db\AbstractDb'); - if ($withStore) { - $namespace->addUse('\Magento\Framework\EntityManager\MetadataPool'); - } - } else { - $construct - ->addComment('@param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory') - ->addComment('@param \Psr\Log\LoggerInterface $logger') - ->addComment('@param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy') - ->addComment('@param \Magento\Framework\Event\ManagerInterface $eventManager') - ->addComment('@param string $mainTable') - ->addComment('@param string $eventPrefix') - ->addComment('@param string $eventObject') - ->addComment('@param string $resourceModel') - ->addComment('@param string $model') - ->addComment('@param \Magento\Framework\DB\Adapter\AdapterInterface|string|null $connection') - ->addComment('@param \Magento\Framework\Model\ResourceModel\Db\AbstractDb|null $resource'); + $namespace->addUse('\Magento\Framework\Data\Collection\EntityFactoryInterface'); + $namespace->addUse('\Psr\Log\LoggerInterface'); + $namespace->addUse('\Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); + $namespace->addUse('\Magento\Framework\Event\ManagerInterface'); + $namespace->addUse('\Magento\Framework\DB\Adapter\AdapterInterface'); + $namespace->addUse('\Magento\Framework\Model\ResourceModel\Db\AbstractDb'); + if ($withStore) { + $namespace->addUse('\Magento\Framework\EntityManager\MetadataPool'); } $construct->addComment('@SuppressWarnings(PHPMD.ExcessiveParameterList)'); diff --git a/test/Crud/CrudV1Test.php b/test/Crud/CrudV1Test.php index 78df405..0502ca0 100644 --- a/test/Crud/CrudV1Test.php +++ b/test/Crud/CrudV1Test.php @@ -80,10 +80,6 @@ private function checkInterfaces() $this->checkFile('Api/TicketRepositoryInterface.php'); $this->checkFile('Api/Data/TicketInterface.php'); $this->checkFile('Api/Data/TicketSearchResultsInterface.php'); - - $this->checkFile('Api/ObsoleteRepositoryInterface.php'); - $this->checkFile('Api/Data/ObsoleteInterface.php'); - $this->checkFile('Api/Data/ObsoleteSearchResultsInterface.php'); } private function checkModels() @@ -110,17 +106,12 @@ private function checkModels() $this->checkFile('Model/Ticket.php'); $this->checkFile('Model/ResourceModel/Ticket.php'); $this->checkFile('Model/ResourceModel/Ticket/Collection.php'); - - $this->checkFile('Model/Obsolete.php'); - $this->checkFile('Model/ResourceModel/Obsolete.php'); - $this->checkFile('Model/ResourceModel/Obsolete/Collection.php'); } private function checkRepository() { $this->checkFile('Model/ColumnsRepository.php'); $this->checkFile('Model/CartItemRepository.php'); - $this->checkFile('Model/ObsoleteRepository.php'); $this->checkFile('Model/PosterRepository.php'); $this->checkFile('Model/TicketRepository.php'); $this->checkFile('Model/CardRepository.php'); @@ -132,7 +123,6 @@ private function checkSearchResults() { $this->checkFile('Model/ColumnsSearchResults.php'); $this->checkFile('Model/CartItemSearchResults.php'); - $this->checkFile('Model/ObsoleteSearchResults.php'); $this->checkFile('Model/PosterSearchResults.php'); $this->checkFile('Model/TicketSearchResults.php'); $this->checkFile('Model/CardSearchResults.php'); @@ -195,15 +185,6 @@ private function checkControllers() $this->checkNoFile('Controller/Adminhtml/Ticket/MassDelete.php'); $this->checkNoFile('Controller/Adminhtml/Ticket/NewAction.php'); $this->checkNoFile('Controller/Adminhtml/Ticket/Save.php'); - - $this->checkFile('Controller/Adminhtml/Obsolete.php'); - $this->checkFile('Controller/Adminhtml/Obsolete/Index.php'); - $this->checkFile('Controller/Adminhtml/Obsolete/Delete.php'); - $this->checkFile('Controller/Adminhtml/Obsolete/Edit.php'); - $this->checkFile('Controller/Adminhtml/Obsolete/InlineEdit.php'); - $this->checkFile('Controller/Adminhtml/Obsolete/MassDelete.php'); - $this->checkFile('Controller/Adminhtml/Obsolete/NewAction.php'); - $this->checkFile('Controller/Adminhtml/Obsolete/Save.php'); } private function checkLayout() @@ -220,10 +201,6 @@ private function checkLayout() $this->checkXml('view/adminhtml/layout/sample_module_card_new.xml'); $this->checkXml('view/adminhtml/layout/sample_module_card_edit.xml'); - $this->checkXml('view/adminhtml/layout/sample_module_obsolete_index.xml'); - $this->checkXml('view/adminhtml/layout/sample_module_obsolete_new.xml'); - $this->checkXml('view/adminhtml/layout/sample_module_obsolete_edit.xml'); - $this->checkXml('view/adminhtml/layout/sample_module_poster_index.xml'); $this->checkNoFile('view/adminhtml/layout/sample_module_poster_new.xml'); $this->checkNoFile('view/adminhtml/layout/sample_module_poster_edit.xml'); @@ -269,12 +246,6 @@ private function checkUi() $this->checkNoFile('view/adminhtml/ui_component/sample_module_ticket_listing.xml'); $this->checkNoFile('view/adminhtml/ui_component/sample_module_ticket_edit.xml'); - - $this->checkFile('Ui/Component/Listing/ObsoleteActions.php'); - $this->checkFile('Model/Obsolete/DataProvider.php'); - $this->checkFile('Model/ResourceModel/Obsolete/Grid/Collection.php'); - $this->checkXml('view/adminhtml/ui_component/sample_module_obsolete_listing.xml'); - $this->checkXml('view/adminhtml/ui_component/sample_module_obsolete_edit.xml'); } private function checkFile($file) diff --git a/test/Expectations/Crud/81/v1/etc/acl.xml b/test/Expectations/Crud/81/v1/etc/acl.xml index efe325a..d21b2a9 100644 --- a/test/Expectations/Crud/81/v1/etc/acl.xml +++ b/test/Expectations/Crud/81/v1/etc/acl.xml @@ -6,7 +6,6 @@ - diff --git a/test/Expectations/Crud/81/v1/etc/adminhtml/menu.xml b/test/Expectations/Crud/81/v1/etc/adminhtml/menu.xml index 0be0577..d213ff9 100644 --- a/test/Expectations/Crud/81/v1/etc/adminhtml/menu.xml +++ b/test/Expectations/Crud/81/v1/etc/adminhtml/menu.xml @@ -4,7 +4,6 @@ - diff --git a/test/Expectations/Crud/81/v1/etc/db_schema.xml b/test/Expectations/Crud/81/v1/etc/db_schema.xml index 353f15d..2292dab 100644 --- a/test/Expectations/Crud/81/v1/etc/db_schema.xml +++ b/test/Expectations/Crud/81/v1/etc/db_schema.xml @@ -37,13 +37,6 @@ - - - - - - -
diff --git a/test/Expectations/Crud/81/v1/etc/di.xml b/test/Expectations/Crud/81/v1/etc/di.xml index 8dee3f2..fa041cf 100644 --- a/test/Expectations/Crud/81/v1/etc/di.xml +++ b/test/Expectations/Crud/81/v1/etc/di.xml @@ -2,19 +2,16 @@ - - - @@ -23,7 +20,6 @@ Mygento\SampleModule\Api\ColumnsRepositoryInterface Mygento\SampleModule\Api\CartItemRepositoryInterface - Mygento\SampleModule\Api\ObsoleteRepositoryInterface Mygento\SampleModule\Api\CardRepositoryInterface Mygento\SampleModule\Api\TicketRepositoryInterface Mygento\SampleModule\Api\PosterRepositoryInterface @@ -55,15 +51,6 @@ - - - - Magento\Framework\Api\SearchCriteria\CollectionProcessor\FilterProcessor - Magento\Framework\Api\SearchCriteria\CollectionProcessor\SortingProcessor - Magento\Framework\Api\SearchCriteria\CollectionProcessor\PaginationProcessor - - - @@ -101,11 +88,6 @@ Mygento\SampleModule\Model\SearchCriteria\CartItemCollectionProcessor - - - Mygento\SampleModule\Model\SearchCriteria\ObsoleteCollectionProcessor - - Mygento\SampleModule\Model\SearchCriteria\CardCollectionProcessor @@ -160,7 +142,6 @@ Mygento\SampleModule\Model\ResourceModel\Columns\Grid\Collection Mygento\SampleModule\Model\ResourceModel\CartItem\Grid\Collection - Mygento\SampleModule\Model\ResourceModel\Obsolete\Grid\Collection Mygento\SampleModule\Model\ResourceModel\Card\Grid\Collection Mygento\SampleModule\Model\ResourceModel\Poster\Grid\Collection @@ -182,14 +163,6 @@ Mygento\SampleModule\Model\ResourceModel\CartItem - - - mygento_sample_module_obsolete - sample_module_obsolete_grid_collection - obsolete_grid_collection - Mygento\SampleModule\Model\ResourceModel\Obsolete - - mygento_sample_module_card diff --git a/test/Expectations/Crud/82/v1/etc/acl.xml b/test/Expectations/Crud/82/v1/etc/acl.xml index efe325a..d21b2a9 100644 --- a/test/Expectations/Crud/82/v1/etc/acl.xml +++ b/test/Expectations/Crud/82/v1/etc/acl.xml @@ -6,7 +6,6 @@ - diff --git a/test/Expectations/Crud/82/v1/etc/adminhtml/menu.xml b/test/Expectations/Crud/82/v1/etc/adminhtml/menu.xml index 0be0577..d213ff9 100644 --- a/test/Expectations/Crud/82/v1/etc/adminhtml/menu.xml +++ b/test/Expectations/Crud/82/v1/etc/adminhtml/menu.xml @@ -4,7 +4,6 @@ - diff --git a/test/Expectations/Crud/82/v1/etc/db_schema.xml b/test/Expectations/Crud/82/v1/etc/db_schema.xml index 353f15d..2292dab 100644 --- a/test/Expectations/Crud/82/v1/etc/db_schema.xml +++ b/test/Expectations/Crud/82/v1/etc/db_schema.xml @@ -37,13 +37,6 @@
- - - - - - -
diff --git a/test/Expectations/Crud/82/v1/etc/di.xml b/test/Expectations/Crud/82/v1/etc/di.xml index 8dee3f2..fa041cf 100644 --- a/test/Expectations/Crud/82/v1/etc/di.xml +++ b/test/Expectations/Crud/82/v1/etc/di.xml @@ -2,19 +2,16 @@ - - - @@ -23,7 +20,6 @@ Mygento\SampleModule\Api\ColumnsRepositoryInterface Mygento\SampleModule\Api\CartItemRepositoryInterface - Mygento\SampleModule\Api\ObsoleteRepositoryInterface Mygento\SampleModule\Api\CardRepositoryInterface Mygento\SampleModule\Api\TicketRepositoryInterface Mygento\SampleModule\Api\PosterRepositoryInterface @@ -55,15 +51,6 @@ - - - - Magento\Framework\Api\SearchCriteria\CollectionProcessor\FilterProcessor - Magento\Framework\Api\SearchCriteria\CollectionProcessor\SortingProcessor - Magento\Framework\Api\SearchCriteria\CollectionProcessor\PaginationProcessor - - - @@ -101,11 +88,6 @@ Mygento\SampleModule\Model\SearchCriteria\CartItemCollectionProcessor - - - Mygento\SampleModule\Model\SearchCriteria\ObsoleteCollectionProcessor - - Mygento\SampleModule\Model\SearchCriteria\CardCollectionProcessor @@ -160,7 +142,6 @@ Mygento\SampleModule\Model\ResourceModel\Columns\Grid\Collection Mygento\SampleModule\Model\ResourceModel\CartItem\Grid\Collection - Mygento\SampleModule\Model\ResourceModel\Obsolete\Grid\Collection Mygento\SampleModule\Model\ResourceModel\Card\Grid\Collection Mygento\SampleModule\Model\ResourceModel\Poster\Grid\Collection @@ -182,14 +163,6 @@ Mygento\SampleModule\Model\ResourceModel\CartItem - - - mygento_sample_module_obsolete - sample_module_obsolete_grid_collection - obsolete_grid_collection - Mygento\SampleModule\Model\ResourceModel\Obsolete - - mygento_sample_module_card diff --git a/test/Expectations/Crud/83/v1/Api/Data/ObsoleteInterface.php b/test/Expectations/Crud/83/v1/Api/Data/ObsoleteInterface.php index cf12b8b..b4ab07b 100644 --- a/test/Expectations/Crud/83/v1/Api/Data/ObsoleteInterface.php +++ b/test/Expectations/Crud/83/v1/Api/Data/ObsoleteInterface.php @@ -9,27 +9,22 @@ interface ObsoleteInterface /** * Get id - * @return int|null */ - public function getId(); + public function getId(): ?int; /** * Set id * @param int $id - * @return $this */ - public function setId($id); + public function setId($id): self; /** * Get name - * @return string|null */ - public function getName(); + public function getName(): ?string; /** * Set name - * @param string $name - * @return $this */ - public function setName($name); + public function setName(?string $name): self; } diff --git a/test/Expectations/Crud/83/v1/Api/ObsoleteRepositoryInterface.php b/test/Expectations/Crud/83/v1/Api/ObsoleteRepositoryInterface.php index 775f5a9..09cb6f4 100644 --- a/test/Expectations/Crud/83/v1/Api/ObsoleteRepositoryInterface.php +++ b/test/Expectations/Crud/83/v1/Api/ObsoleteRepositoryInterface.php @@ -2,46 +2,38 @@ namespace Mygento\SampleModule\Api; +use Magento\Framework\Api\SearchCriteriaInterface; + interface ObsoleteRepositoryInterface { /** * Save Obsolete - * @param \Mygento\SampleModule\Api\Data\ObsoleteInterface $entity * @throws \Magento\Framework\Exception\LocalizedException - * @return \Mygento\SampleModule\Api\Data\ObsoleteInterface */ - public function save(Data\ObsoleteInterface $entity); + public function save(Data\ObsoleteInterface $entity): Data\ObsoleteInterface; /** * Retrieve Obsolete - * @param int $entityId * @throws \Magento\Framework\Exception\LocalizedException - * @return \Mygento\SampleModule\Api\Data\ObsoleteInterface */ - public function getById($entityId); + public function getById(int $entityId): Data\ObsoleteInterface; /** * Retrieve Obsolete entities matching the specified criteria - * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria * @throws \Magento\Framework\Exception\LocalizedException - * @return \Mygento\SampleModule\Api\Data\ObsoleteSearchResultsInterface */ - public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria); + public function getList(SearchCriteriaInterface $searchCriteria): Data\ObsoleteSearchResultsInterface; /** * Delete Obsolete - * @param \Mygento\SampleModule\Api\Data\ObsoleteInterface $entity * @throws \Magento\Framework\Exception\LocalizedException - * @return bool true on success */ - public function delete(Data\ObsoleteInterface $entity); + public function delete(Data\ObsoleteInterface $entity): bool; /** * Delete Obsolete - * @param int $entityId * @throws \Magento\Framework\Exception\NoSuchEntityException * @throws \Magento\Framework\Exception\LocalizedException - * @return bool true on success */ - public function deleteById($entityId); + public function deleteById(int $entityId): bool; } diff --git a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete.php b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete.php index 07f8cf7..d3f5bbf 100644 --- a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete.php +++ b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete.php @@ -2,7 +2,11 @@ namespace Mygento\SampleModule\Controller\Adminhtml; -abstract class Obsolete extends \Magento\Backend\App\Action +use Magento\Backend\App\Action; +use Magento\Framework\Registry; +use Mygento\SampleModule\Api\ObsoleteRepositoryInterface; + +abstract class Obsolete extends Action { /** * Authorization level @@ -11,30 +15,11 @@ abstract class Obsolete extends \Magento\Backend\App\Action */ public const ADMIN_RESOURCE = 'Mygento_SampleModule::obsolete'; - /** - * Core registry - * - * @var \Magento\Framework\Registry - */ - protected $coreRegistry; - - /** - * Obsolete repository - * - * @var \Mygento\SampleModule\Api\ObsoleteRepositoryInterface - */ - protected $repository; + protected Registry $coreRegistry; + protected ObsoleteRepositoryInterface $repository; - /** - * @param \Mygento\SampleModule\Api\ObsoleteRepositoryInterface $repository - * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Backend\App\Action\Context $context - */ - public function __construct( - \Mygento\SampleModule\Api\ObsoleteRepositoryInterface $repository, - \Magento\Framework\Registry $coreRegistry, - \Magento\Backend\App\Action\Context $context, - ) { + public function __construct(ObsoleteRepositoryInterface $repository, Registry $coreRegistry, Action\Context $context) + { parent::__construct($context); $this->repository = $repository; diff --git a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Delete.php b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Delete.php index b8cb658..298461a 100644 --- a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Delete.php +++ b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Delete.php @@ -2,14 +2,15 @@ namespace Mygento\SampleModule\Controller\Adminhtml\Obsolete; -class Delete extends \Mygento\SampleModule\Controller\Adminhtml\Obsolete +use Magento\Framework\Controller\ResultInterface; +use Mygento\SampleModule\Controller\Adminhtml\Obsolete; + +class Delete extends Obsolete { /** * Delete Obsolete action - * - * @return \Magento\Framework\Controller\ResultInterface */ - public function execute() + public function execute(): ResultInterface { /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); diff --git a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Edit.php b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Edit.php index d3e66a5..6bfdd90 100644 --- a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Edit.php +++ b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Edit.php @@ -2,29 +2,26 @@ namespace Mygento\SampleModule\Controller\Adminhtml\Obsolete; +use Magento\Backend\App\Action\Context; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Registry; +use Magento\Framework\View\Result\PageFactory; +use Mygento\SampleModule\Api\Data\ObsoleteInterfaceFactory; +use Mygento\SampleModule\Api\ObsoleteRepositoryInterface; +use Mygento\SampleModule\Controller\Adminhtml\Obsolete; -class Edit extends \Mygento\SampleModule\Controller\Adminhtml\Obsolete +class Edit extends Obsolete { - /** @var \Mygento\SampleModule\Api\Data\ObsoleteInterfaceFactory */ - private $entityFactory; + private ObsoleteInterfaceFactory $entityFactory; + private PageFactory $resultPageFactory; - /** @var \Magento\Framework\View\Result\PageFactory */ - private $resultPageFactory; - - /** - * @param \Mygento\SampleModule\Api\Data\ObsoleteInterfaceFactory $entityFactory - * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory - * @param \Mygento\SampleModule\Api\ObsoleteRepositoryInterface $repository - * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Backend\App\Action\Context $context - */ public function __construct( - \Mygento\SampleModule\Api\Data\ObsoleteInterfaceFactory $entityFactory, - \Magento\Framework\View\Result\PageFactory $resultPageFactory, - \Mygento\SampleModule\Api\ObsoleteRepositoryInterface $repository, - \Magento\Framework\Registry $coreRegistry, - \Magento\Backend\App\Action\Context $context, + ObsoleteInterfaceFactory $entityFactory, + PageFactory $resultPageFactory, + ObsoleteRepositoryInterface $repository, + Registry $coreRegistry, + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); @@ -34,10 +31,8 @@ public function __construct( /** * Edit Obsolete action - * - * @return \Magento\Framework\Controller\ResultInterface */ - public function execute() + public function execute(): ResultInterface { $entityId = (int) $this->getRequest()->getParam('id'); $entity = $this->entityFactory->create(); diff --git a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Index.php b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Index.php index fe1fe50..168574b 100644 --- a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Index.php +++ b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Index.php @@ -2,27 +2,25 @@ namespace Mygento\SampleModule\Controller\Adminhtml\Obsolete; -class Index extends \Mygento\SampleModule\Controller\Adminhtml\Obsolete +use Magento\Backend\App\Action\Context; +use Magento\Framework\App\Request\DataPersistorInterface; +use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Registry; +use Magento\Framework\View\Result\PageFactory; +use Mygento\SampleModule\Api\ObsoleteRepositoryInterface; +use Mygento\SampleModule\Controller\Adminhtml\Obsolete; + +class Index extends Obsolete { - /** @var \Magento\Framework\View\Result\PageFactory */ - private $resultPageFactory; + private PageFactory $resultPageFactory; + private DataPersistorInterface $dataPersistor; - /** @var \Magento\Framework\App\Request\DataPersistorInterface */ - private $dataPersistor; - - /** - * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory - * @param \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor - * @param \Mygento\SampleModule\Api\ObsoleteRepositoryInterface $repository - * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Backend\App\Action\Context $context - */ public function __construct( - \Magento\Framework\View\Result\PageFactory $resultPageFactory, - \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor, - \Mygento\SampleModule\Api\ObsoleteRepositoryInterface $repository, - \Magento\Framework\Registry $coreRegistry, - \Magento\Backend\App\Action\Context $context, + PageFactory $resultPageFactory, + DataPersistorInterface $dataPersistor, + ObsoleteRepositoryInterface $repository, + Registry $coreRegistry, + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); @@ -32,10 +30,8 @@ public function __construct( /** * Index action - * - * @return \Magento\Framework\Controller\ResultInterface */ - public function execute() + public function execute(): ResultInterface { /** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); diff --git a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/InlineEdit.php b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/InlineEdit.php index 79e810e..14058d7 100644 --- a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/InlineEdit.php +++ b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/InlineEdit.php @@ -2,24 +2,23 @@ namespace Mygento\SampleModule\Controller\Adminhtml\Obsolete; +use Magento\Backend\App\Action\Context; +use Magento\Framework\Controller\Result\JsonFactory; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Registry; +use Mygento\SampleModule\Api\ObsoleteRepositoryInterface; +use Mygento\SampleModule\Controller\Adminhtml\Obsolete; -class InlineEdit extends \Mygento\SampleModule\Controller\Adminhtml\Obsolete +class InlineEdit extends Obsolete { - /** @var \Magento\Framework\Controller\Result\JsonFactory */ - private $jsonFactory; + private JsonFactory $jsonFactory; - /** - * @param \Magento\Framework\Controller\Result\JsonFactory $jsonFactory - * @param \Mygento\SampleModule\Api\ObsoleteRepositoryInterface $repository - * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Backend\App\Action\Context $context - */ public function __construct( - \Magento\Framework\Controller\Result\JsonFactory $jsonFactory, - \Mygento\SampleModule\Api\ObsoleteRepositoryInterface $repository, - \Magento\Framework\Registry $coreRegistry, - \Magento\Backend\App\Action\Context $context, + JsonFactory $jsonFactory, + ObsoleteRepositoryInterface $repository, + Registry $coreRegistry, + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); @@ -28,10 +27,8 @@ public function __construct( /** * Execute action - * - * @return \Magento\Framework\Controller\ResultInterface */ - public function execute() + public function execute(): ResultInterface { /** @var \Magento\Framework\Controller\Result\Json $resultJson */ $resultJson = $this->jsonFactory->create(); diff --git a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/MassDelete.php b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/MassDelete.php index 106da4e..262ce23 100644 --- a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/MassDelete.php +++ b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/MassDelete.php @@ -2,29 +2,26 @@ namespace Mygento\SampleModule\Controller\Adminhtml\Obsolete; +use Magento\Backend\App\Action\Context; use Magento\Framework\Controller\ResultFactory; - -class MassDelete extends \Mygento\SampleModule\Controller\Adminhtml\Obsolete +use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Registry; +use Magento\Ui\Component\MassAction\Filter; +use Mygento\SampleModule\Api\ObsoleteRepositoryInterface; +use Mygento\SampleModule\Controller\Adminhtml\Obsolete; +use Mygento\SampleModule\Model\ResourceModel\Obsolete\CollectionFactory; + +class MassDelete extends Obsolete { - /** @var \Magento\Ui\Component\MassAction\Filter */ - private $filter; - - /** @var \Mygento\SampleModule\Model\ResourceModel\Obsolete\CollectionFactory */ - private $collectionFactory; + private Filter $filter; + private CollectionFactory $collectionFactory; - /** - * @param \Mygento\SampleModule\Model\ResourceModel\Obsolete\CollectionFactory $collectionFactory - * @param \Magento\Ui\Component\MassAction\Filter $filter - * @param \Mygento\SampleModule\Api\ObsoleteRepositoryInterface $repository - * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Backend\App\Action\Context $context - */ public function __construct( - \Mygento\SampleModule\Model\ResourceModel\Obsolete\CollectionFactory $collectionFactory, - \Magento\Ui\Component\MassAction\Filter $filter, - \Mygento\SampleModule\Api\ObsoleteRepositoryInterface $repository, - \Magento\Framework\Registry $coreRegistry, - \Magento\Backend\App\Action\Context $context, + CollectionFactory $collectionFactory, + Filter $filter, + ObsoleteRepositoryInterface $repository, + Registry $coreRegistry, + Context $context, ) { $this->filter = $filter; $this->collectionFactory = $collectionFactory; @@ -33,10 +30,8 @@ public function __construct( /** * Execute action - * - * @return \Magento\Framework\Controller\ResultInterface */ - public function execute() + public function execute(): ResultInterface { $collection = $this->filter->getCollection($this->collectionFactory->create()); $collectionSize = $collection->getSize(); diff --git a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/NewAction.php b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/NewAction.php index 7ba8415..c10c36d 100644 --- a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/NewAction.php +++ b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/NewAction.php @@ -2,22 +2,22 @@ namespace Mygento\SampleModule\Controller\Adminhtml\Obsolete; -class NewAction extends \Mygento\SampleModule\Controller\Adminhtml\Obsolete +use Magento\Backend\App\Action\Context; +use Magento\Backend\Model\View\Result\ForwardFactory; +use Magento\Framework\Controller\ResultInterface; +use Magento\Framework\Registry; +use Mygento\SampleModule\Api\ObsoleteRepositoryInterface; +use Mygento\SampleModule\Controller\Adminhtml\Obsolete; + +class NewAction extends Obsolete { - /** @var \Magento\Backend\Model\View\Result\ForwardFactory */ - private $resultForwardFactory; + private ForwardFactory $resultForwardFactory; - /** - * @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory - * @param \Mygento\SampleModule\Api\ObsoleteRepositoryInterface $repository - * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Backend\App\Action\Context $context - */ public function __construct( - \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory, - \Mygento\SampleModule\Api\ObsoleteRepositoryInterface $repository, - \Magento\Framework\Registry $coreRegistry, - \Magento\Backend\App\Action\Context $context, + ForwardFactory $resultForwardFactory, + ObsoleteRepositoryInterface $repository, + Registry $coreRegistry, + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); @@ -26,10 +26,8 @@ public function __construct( /** * Create new Obsolete - * - * @return \Magento\Framework\Controller\ResultInterface */ - public function execute() + public function execute(): ResultInterface { /** @var \Magento\Framework\Controller\Result\Forward $resultForward */ $resultForward = $this->resultForwardFactory->create(); diff --git a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Save.php b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Save.php index 58d6951..19f0bb3 100644 --- a/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Save.php +++ b/test/Expectations/Crud/83/v1/Controller/Adminhtml/Obsolete/Save.php @@ -2,30 +2,27 @@ namespace Mygento\SampleModule\Controller\Adminhtml\Obsolete; +use Magento\Backend\App\Action\Context; +use Magento\Framework\App\Request\DataPersistorInterface; +use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Exception\NoSuchEntityException; +use Magento\Framework\Registry; +use Mygento\SampleModule\Api\Data\ObsoleteInterfaceFactory; +use Mygento\SampleModule\Api\ObsoleteRepositoryInterface; +use Mygento\SampleModule\Controller\Adminhtml\Obsolete; -class Save extends \Mygento\SampleModule\Controller\Adminhtml\Obsolete +class Save extends Obsolete { - /** @var \Magento\Framework\App\Request\DataPersistorInterface */ - private $dataPersistor; + private DataPersistorInterface $dataPersistor; + private ObsoleteInterfaceFactory $entityFactory; - /** @var \Mygento\SampleModule\Api\Data\ObsoleteInterfaceFactory */ - private $entityFactory; - - /** - * @param \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor - * @param \Mygento\SampleModule\Api\Data\ObsoleteInterfaceFactory $entityFactory - * @param \Mygento\SampleModule\Api\ObsoleteRepositoryInterface $repository - * @param \Magento\Framework\Registry $coreRegistry - * @param \Magento\Backend\App\Action\Context $context - */ public function __construct( - \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor, - \Mygento\SampleModule\Api\Data\ObsoleteInterfaceFactory $entityFactory, - \Mygento\SampleModule\Api\ObsoleteRepositoryInterface $repository, - \Magento\Framework\Registry $coreRegistry, - \Magento\Backend\App\Action\Context $context, + DataPersistorInterface $dataPersistor, + ObsoleteInterfaceFactory $entityFactory, + ObsoleteRepositoryInterface $repository, + Registry $coreRegistry, + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); @@ -38,10 +35,8 @@ public function __construct( * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.CyclomaticComplexity) - * - * @return \Magento\Framework\Controller\ResultInterface */ - public function execute() + public function execute(): ResultInterface { /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); diff --git a/test/Expectations/Crud/83/v1/Model/Obsolete.php b/test/Expectations/Crud/83/v1/Model/Obsolete.php index a99cccf..205bd16 100644 --- a/test/Expectations/Crud/83/v1/Model/Obsolete.php +++ b/test/Expectations/Crud/83/v1/Model/Obsolete.php @@ -12,9 +12,8 @@ class Obsolete extends AbstractModel implements ObsoleteInterface /** * Get id - * @return int|null */ - public function getId() + public function getId(): ?int { return $this->getData(self::ID); } @@ -22,28 +21,24 @@ public function getId() /** * Set id * @param int $id - * @return $this */ - public function setId($id) + public function setId($id): self { return $this->setData(self::ID, $id); } /** * Get name - * @return string|null */ - public function getName() + public function getName(): ?string { return $this->getData(self::NAME); } /** * Set name - * @param string $name - * @return $this */ - public function setName($name) + public function setName(?string $name): self { return $this->setData(self::NAME, $name); } diff --git a/test/Expectations/Crud/83/v1/Model/Obsolete/DataProvider.php b/test/Expectations/Crud/83/v1/Model/Obsolete/DataProvider.php index e7ebc1f..88e8118 100644 --- a/test/Expectations/Crud/83/v1/Model/Obsolete/DataProvider.php +++ b/test/Expectations/Crud/83/v1/Model/Obsolete/DataProvider.php @@ -4,29 +4,18 @@ use Magento\Framework\App\Request\DataPersistorInterface; use Magento\Ui\DataProvider\Modifier\PoolInterface; +use Magento\Ui\DataProvider\ModifierPoolDataProvider; +use Mygento\SampleModule\Model\ResourceModel\Obsolete\Collection; use Mygento\SampleModule\Model\ResourceModel\Obsolete\CollectionFactory; -class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider +class DataProvider extends ModifierPoolDataProvider { - /** @var \Mygento\SampleModule\Model\ResourceModel\Obsolete\Collection */ + /** @var Collection */ protected $collection; - /** @var DataPersistorInterface */ - private $dataPersistor; + private DataPersistorInterface $dataPersistor; + private array $loadedData = []; - /** @var array */ - private $loadedData = []; - - /** - * @param \Mygento\SampleModule\Model\ResourceModel\Obsolete\CollectionFactory $collectionFactory - * @param \Magento\Framework\App\Request\DataPersistorInterface $dataPersistor - * @param string $name - * @param string $primaryFieldName - * @param string $requestFieldName - * @param array $meta - * @param array $data - * @param \Magento\Ui\DataProvider\Modifier\PoolInterface|null $pool - */ public function __construct( CollectionFactory $collectionFactory, DataPersistorInterface $dataPersistor, @@ -43,10 +32,7 @@ public function __construct( $this->dataPersistor = $dataPersistor; } - /** - * @return array - */ - public function getData() + public function getData(): array { if (!empty($this->loadedData)) { return $this->loadedData; diff --git a/test/Expectations/Crud/83/v1/Model/ObsoleteRepository.php b/test/Expectations/Crud/83/v1/Model/ObsoleteRepository.php index 3a76d9f..adc42b8 100644 --- a/test/Expectations/Crud/83/v1/Model/ObsoleteRepository.php +++ b/test/Expectations/Crud/83/v1/Model/ObsoleteRepository.php @@ -3,42 +3,33 @@ namespace Mygento\SampleModule\Model; use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface; +use Magento\Framework\Api\SearchCriteriaInterface; use Magento\Framework\Exception\CouldNotDeleteException; use Magento\Framework\Exception\CouldNotSaveException; use Magento\Framework\Exception\NoSuchEntityException; +use Mygento\SampleModule\Api\Data\ObsoleteInterface; +use Mygento\SampleModule\Api\Data\ObsoleteInterfaceFactory; +use Mygento\SampleModule\Api\Data\ObsoleteSearchResultsInterface; +use Mygento\SampleModule\Api\Data\ObsoleteSearchResultsInterfaceFactory; +use Mygento\SampleModule\Api\ObsoleteRepositoryInterface; +use Mygento\SampleModule\Model\ResourceModel\Obsolete\CollectionFactory; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ -class ObsoleteRepository implements \Mygento\SampleModule\Api\ObsoleteRepositoryInterface +class ObsoleteRepository implements ObsoleteRepositoryInterface { - /** @var \Mygento\SampleModule\Model\ResourceModel\Obsolete */ - private $resource; + private ResourceModel\Obsolete $resource; + private CollectionFactory $collectionFactory; + private ObsoleteInterfaceFactory $entityFactory; + private ObsoleteSearchResultsInterfaceFactory $searchResultsFactory; + private CollectionProcessorInterface $collectionProcessor; - /** @var \Mygento\SampleModule\Model\ResourceModel\Obsolete\CollectionFactory */ - private $collectionFactory; - - /** @var \Mygento\SampleModule\Api\Data\ObsoleteInterfaceFactory */ - private $entityFactory; - - /** @var \Mygento\SampleModule\Api\Data\ObsoleteSearchResultsInterfaceFactory */ - private $searchResultsFactory; - - /** @var CollectionProcessorInterface */ - private $collectionProcessor; - - /** - * @param \Mygento\SampleModule\Model\ResourceModel\Obsolete $resource - * @param \Mygento\SampleModule\Model\ResourceModel\Obsolete\CollectionFactory $collectionFactory - * @param \Mygento\SampleModule\Api\Data\ObsoleteInterfaceFactory $entityFactory - * @param \Mygento\SampleModule\Api\Data\ObsoleteSearchResultsInterfaceFactory $searchResultsFactory - * @param CollectionProcessorInterface $collectionProcessor - */ public function __construct( ResourceModel\Obsolete $resource, - ResourceModel\Obsolete\CollectionFactory $collectionFactory, - \Mygento\SampleModule\Api\Data\ObsoleteInterfaceFactory $entityFactory, - \Mygento\SampleModule\Api\Data\ObsoleteSearchResultsInterfaceFactory $searchResultsFactory, + CollectionFactory $collectionFactory, + ObsoleteInterfaceFactory $entityFactory, + ObsoleteSearchResultsInterfaceFactory $searchResultsFactory, CollectionProcessorInterface $collectionProcessor, ) { $this->resource = $resource; @@ -49,11 +40,9 @@ public function __construct( } /** - * @param int $entityId - * @throws \Magento\Framework\Exception\NoSuchEntityException - * @return \Mygento\SampleModule\Api\Data\ObsoleteInterface + * @throws NoSuchEntityException */ - public function getById($entityId) + public function getById(int $entityId): ObsoleteInterface { $entity = $this->entityFactory->create(); $this->resource->load($entity, $entityId); @@ -67,11 +56,9 @@ public function getById($entityId) } /** - * @param \Mygento\SampleModule\Api\Data\ObsoleteInterface $entity - * @throws \Magento\Framework\Exception\CouldNotSaveException - * @return \Mygento\SampleModule\Api\Data\ObsoleteInterface + * @throws CouldNotSaveException */ - public function save(\Mygento\SampleModule\Api\Data\ObsoleteInterface $entity) + public function save(ObsoleteInterface $entity): ObsoleteInterface { try { $this->resource->save($entity); @@ -86,11 +73,9 @@ public function save(\Mygento\SampleModule\Api\Data\ObsoleteInterface $entity) } /** - * @param \Mygento\SampleModule\Api\Data\ObsoleteInterface $entity - * @throws \Magento\Framework\Exception\CouldNotDeleteException - * @return bool + * @throws CouldNotDeleteException */ - public function delete(\Mygento\SampleModule\Api\Data\ObsoleteInterface $entity) + public function delete(ObsoleteInterface $entity): bool { try { $this->resource->delete($entity); @@ -104,28 +89,22 @@ public function delete(\Mygento\SampleModule\Api\Data\ObsoleteInterface $entity) } /** - * @param int $entityId - * @throws \Magento\Framework\Exception\NoSuchEntityException - * @throws \Magento\Framework\Exception\CouldNotDeleteException - * @return bool + * @throws NoSuchEntityException + * @throws CouldNotDeleteException */ - public function deleteById($entityId) + public function deleteById(int $entityId): bool { return $this->delete($this->getById($entityId)); } - /** - * @param \Magento\Framework\Api\SearchCriteriaInterface $criteria - * @return \Mygento\SampleModule\Api\Data\ObsoleteSearchResultsInterface - */ - public function getList(\Magento\Framework\Api\SearchCriteriaInterface $criteria) + public function getList(SearchCriteriaInterface $criteria): ObsoleteSearchResultsInterface { /** @var \Mygento\SampleModule\Model\ResourceModel\Obsolete\Collection $collection */ $collection = $this->collectionFactory->create(); $this->collectionProcessor->process($criteria, $collection); - /** @var \Mygento\SampleModule\Api\Data\ObsoleteSearchResultsInterface $searchResults */ + /** @var ObsoleteSearchResultsInterface $searchResults */ $searchResults = $this->searchResultsFactory->create(); $searchResults->setSearchCriteria($criteria); $searchResults->setItems($collection->getItems()); diff --git a/test/Expectations/Crud/83/v1/Model/ResourceModel/Obsolete.php b/test/Expectations/Crud/83/v1/Model/ResourceModel/Obsolete.php index a4af375..09e2f1e 100644 --- a/test/Expectations/Crud/83/v1/Model/ResourceModel/Obsolete.php +++ b/test/Expectations/Crud/83/v1/Model/ResourceModel/Obsolete.php @@ -2,14 +2,15 @@ namespace Mygento\SampleModule\Model\ResourceModel; -class Obsolete extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb +use Magento\Framework\Model\ResourceModel\Db\AbstractDb; + +class Obsolete extends AbstractDb { public const TABLE_NAME = 'mygento_sample_module_obsolete'; public const TABLE_PRIMARY_KEY = 'id'; /** * Initialize resource model - * @return void */ protected function _construct() { diff --git a/test/Expectations/Crud/83/v1/Model/ResourceModel/Obsolete/Collection.php b/test/Expectations/Crud/83/v1/Model/ResourceModel/Obsolete/Collection.php index b43fd6b..24adb34 100644 --- a/test/Expectations/Crud/83/v1/Model/ResourceModel/Obsolete/Collection.php +++ b/test/Expectations/Crud/83/v1/Model/ResourceModel/Obsolete/Collection.php @@ -2,10 +2,14 @@ namespace Mygento\SampleModule\Model\ResourceModel\Obsolete; -class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection +use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; +use Mygento\SampleModule\Model\Obsolete; +use Mygento\SampleModule\Model\ResourceModel\Obsolete as ObsoleteResource; + +class Collection extends AbstractCollection { /** @var string */ - protected $_idFieldName = 'id'; + protected $_idFieldName = ObsoleteResource::TABLE_PRIMARY_KEY; /** * Define resource model @@ -13,8 +17,8 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab protected function _construct() { $this->_init( - \Mygento\SampleModule\Model\Obsolete::class, - \Mygento\SampleModule\Model\ResourceModel\Obsolete::class + Obsolete::class, + ObsoleteResource::class ); } } diff --git a/test/Expectations/Crud/83/v1/Model/ResourceModel/Obsolete/Grid/Collection.php b/test/Expectations/Crud/83/v1/Model/ResourceModel/Obsolete/Grid/Collection.php index 2c5da87..04b03be 100644 --- a/test/Expectations/Crud/83/v1/Model/ResourceModel/Obsolete/Grid/Collection.php +++ b/test/Expectations/Crud/83/v1/Model/ResourceModel/Obsolete/Grid/Collection.php @@ -2,41 +2,36 @@ namespace Mygento\SampleModule\Model\ResourceModel\Obsolete\Grid; +use Magento\Framework\Api\Search\AggregationInterface; use Magento\Framework\Api\Search\SearchResultInterface; use Magento\Framework\Api\SearchCriteriaInterface; +use Magento\Framework\Data\Collection\Db\FetchStrategyInterface; +use Magento\Framework\Data\Collection\EntityFactoryInterface; +use Magento\Framework\DB\Adapter\AdapterInterface; +use Magento\Framework\Event\ManagerInterface; +use Magento\Framework\Model\ResourceModel\Db\AbstractDb; use Mygento\SampleModule\Model\ResourceModel\Obsolete\Collection as ParentCollection; +use Psr\Log\LoggerInterface; class Collection extends ParentCollection implements SearchResultInterface { - /** @var \Magento\Framework\Api\Search\AggregationInterface */ - protected $aggregations; + protected AggregationInterface $aggregations; /** - * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory - * @param \Psr\Log\LoggerInterface $logger - * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy - * @param \Magento\Framework\Event\ManagerInterface $eventManager - * @param string $mainTable - * @param string $eventPrefix - * @param string $eventObject - * @param string $resourceModel - * @param string $model - * @param \Magento\Framework\DB\Adapter\AdapterInterface|string|null $connection - * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb|null $resource * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory, - \Psr\Log\LoggerInterface $logger, - \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, - \Magento\Framework\Event\ManagerInterface $eventManager, + EntityFactoryInterface $entityFactory, + LoggerInterface $logger, + FetchStrategyInterface $fetchStrategy, + ManagerInterface $eventManager, string $mainTable, string $eventPrefix, string $eventObject, string $resourceModel, string $model = \Magento\Framework\View\Element\UiComponent\DataProvider\Document::class, - \Magento\Framework\DB\Adapter\AdapterInterface $connection = null, - \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null, + AdapterInterface $connection = null, + AbstractDb $resource = null, ) { parent::__construct( $entityFactory, diff --git a/test/Expectations/Crud/83/v1/Ui/Component/Listing/ObsoleteActions.php b/test/Expectations/Crud/83/v1/Ui/Component/Listing/ObsoleteActions.php index 10e3ce7..6d6ddfd 100644 --- a/test/Expectations/Crud/83/v1/Ui/Component/Listing/ObsoleteActions.php +++ b/test/Expectations/Crud/83/v1/Ui/Component/Listing/ObsoleteActions.php @@ -2,11 +2,10 @@ namespace Mygento\SampleModule\Ui\Component\Listing; -class ObsoleteActions extends \Mygento\Base\Ui\Component\Listing\Actions -{ - /** @var string */ - protected $route = 'sample_module'; +use Mygento\Base\Ui\Component\Listing\Actions; - /** @var string */ - protected $controller = 'obsolete'; +class ObsoleteActions extends Actions +{ + protected string $route = 'sample_module'; + protected string $controller = 'obsolete'; } diff --git a/test/Expectations/Crud/83/v1/etc/acl.xml b/test/Expectations/Crud/83/v1/etc/acl.xml index efe325a..d21b2a9 100644 --- a/test/Expectations/Crud/83/v1/etc/acl.xml +++ b/test/Expectations/Crud/83/v1/etc/acl.xml @@ -6,7 +6,6 @@ - diff --git a/test/Expectations/Crud/83/v1/etc/adminhtml/menu.xml b/test/Expectations/Crud/83/v1/etc/adminhtml/menu.xml index 0be0577..d213ff9 100644 --- a/test/Expectations/Crud/83/v1/etc/adminhtml/menu.xml +++ b/test/Expectations/Crud/83/v1/etc/adminhtml/menu.xml @@ -4,7 +4,6 @@ - diff --git a/test/Expectations/Crud/83/v1/etc/db_schema.xml b/test/Expectations/Crud/83/v1/etc/db_schema.xml index 353f15d..2292dab 100644 --- a/test/Expectations/Crud/83/v1/etc/db_schema.xml +++ b/test/Expectations/Crud/83/v1/etc/db_schema.xml @@ -37,13 +37,6 @@
- - - - - - -
diff --git a/test/Expectations/Crud/83/v1/etc/di.xml b/test/Expectations/Crud/83/v1/etc/di.xml index 8dee3f2..fa041cf 100644 --- a/test/Expectations/Crud/83/v1/etc/di.xml +++ b/test/Expectations/Crud/83/v1/etc/di.xml @@ -2,19 +2,16 @@ - - - @@ -23,7 +20,6 @@ Mygento\SampleModule\Api\ColumnsRepositoryInterface Mygento\SampleModule\Api\CartItemRepositoryInterface - Mygento\SampleModule\Api\ObsoleteRepositoryInterface Mygento\SampleModule\Api\CardRepositoryInterface Mygento\SampleModule\Api\TicketRepositoryInterface Mygento\SampleModule\Api\PosterRepositoryInterface @@ -55,15 +51,6 @@ - - - - Magento\Framework\Api\SearchCriteria\CollectionProcessor\FilterProcessor - Magento\Framework\Api\SearchCriteria\CollectionProcessor\SortingProcessor - Magento\Framework\Api\SearchCriteria\CollectionProcessor\PaginationProcessor - - - @@ -101,11 +88,6 @@ Mygento\SampleModule\Model\SearchCriteria\CartItemCollectionProcessor - - - Mygento\SampleModule\Model\SearchCriteria\ObsoleteCollectionProcessor - - Mygento\SampleModule\Model\SearchCriteria\CardCollectionProcessor @@ -160,7 +142,6 @@ Mygento\SampleModule\Model\ResourceModel\Columns\Grid\Collection Mygento\SampleModule\Model\ResourceModel\CartItem\Grid\Collection - Mygento\SampleModule\Model\ResourceModel\Obsolete\Grid\Collection Mygento\SampleModule\Model\ResourceModel\Card\Grid\Collection Mygento\SampleModule\Model\ResourceModel\Poster\Grid\Collection @@ -182,14 +163,6 @@ Mygento\SampleModule\Model\ResourceModel\CartItem - - - mygento_sample_module_obsolete - sample_module_obsolete_grid_collection - obsolete_grid_collection - Mygento\SampleModule\Model\ResourceModel\Obsolete - - mygento_sample_module_card