From ad41563657012c690c26958fdfb3772639690ef3 Mon Sep 17 00:00:00 2001 From: nikita tarasov Date: Fri, 24 Mar 2023 16:01:48 +0300 Subject: [PATCH] 8.1 features --- composer.json | 6 +- grumphp.yml | 4 +- src/Jeeves/Console/Command/EmptyProject.php | 383 ------------------ src/Jeeves/Generators/Common.php | 20 + .../Generators/Crud/Controllers/Create.php | 45 +- .../Generators/Crud/Controllers/Delete.php | 2 +- .../Generators/Crud/Controllers/Edit.php | 73 ++-- .../Generators/Crud/Controllers/Inline.php | 52 ++- .../Generators/Crud/Controllers/Mass.php | 73 ++-- .../Generators/Crud/Controllers/Save.php | 82 ++-- .../Generators/Crud/Controllers/Shared.php | 74 ++-- .../Generators/Crud/Controllers/View.php | 70 +++- .../Generators/Crud/Interfaces/Model.php | 2 +- .../Generators/Crud/Interfaces/Repository.php | 8 +- .../Generators/Crud/Interfaces/Search.php | 4 +- .../Generators/Crud/Models/Collection.php | 69 +++- src/Jeeves/Generators/Crud/Models/Model.php | 2 +- src/Jeeves/Generators/Crud/Models/Read.php | 33 +- .../Generators/Crud/Models/Resource.php | 66 ++- src/Jeeves/Generators/Crud/Models/Save.php | 55 ++- .../Generators/Crud/Repositories/Filter.php | 3 +- .../Crud/Repositories/Repository.php | 166 +++++--- .../Generators/Crud/Repositories/Search.php | 5 +- src/Jeeves/Generators/Crud/Ui/Actions.php | 2 +- .../Generators/Crud/Ui/DataProvider.php | 12 +- src/Jeeves/Generators/Crud/Ui/Grid.php | 29 +- src/Jeeves/Generators/Project/Node.php | 166 -------- test/Crud/CrudV1Test.php | 183 ++++----- .../Crud/81/v1/Controller/Adminhtml/Card.php | 13 +- .../81/v1/Controller/Adminhtml/Card/Edit.php | 12 +- .../81/v1/Controller/Adminhtml/Card/Index.php | 12 +- .../Controller/Adminhtml/Card/InlineEdit.php | 8 +- .../Controller/Adminhtml/Card/MassDelete.php | 11 +- .../Controller/Adminhtml/Card/NewAction.php | 8 +- .../81/v1/Controller/Adminhtml/Card/Save.php | 12 +- .../81/v1/Controller/Adminhtml/CartItem.php | 13 +- .../v1/Controller/Adminhtml/CartItem/Edit.php | 12 +- .../Controller/Adminhtml/CartItem/Index.php | 12 +- .../Adminhtml/CartItem/InlineEdit.php | 8 +- .../Adminhtml/CartItem/MassDelete.php | 11 +- .../Adminhtml/CartItem/NewAction.php | 8 +- .../v1/Controller/Adminhtml/CartItem/Save.php | 12 +- .../81/v1/Controller/Adminhtml/Columns.php | 13 +- .../v1/Controller/Adminhtml/Columns/Edit.php | 12 +- .../v1/Controller/Adminhtml/Columns/Index.php | 12 +- .../Adminhtml/Columns/InlineEdit.php | 8 +- .../Adminhtml/Columns/MassDelete.php | 11 +- .../Adminhtml/Columns/NewAction.php | 8 +- .../v1/Controller/Adminhtml/Columns/Save.php | 12 +- .../81/v1/Controller/Adminhtml/Poster.php | 13 +- .../v1/Controller/Adminhtml/Poster/Index.php | 12 +- .../Crud/81/v1/Model/CardRepository.php | 25 +- .../Crud/81/v1/Model/CartItemRepository.php | 21 +- .../Crud/81/v1/Model/ColumnsRepository.php | 21 +- .../Crud/81/v1/Model/PosterRepository.php | 21 +- .../Crud/81/v1/Model/ResourceModel/Card.php | 11 +- .../Model/ResourceModel/Card/Collection.php | 7 +- .../Card/Relation/Store/ReadHandler.php | 5 +- .../Card/Relation/Store/SaveHandler.php | 11 +- .../Crud/82/v1/Controller/Adminhtml/Card.php | 13 +- .../82/v1/Controller/Adminhtml/Card/Edit.php | 12 +- .../82/v1/Controller/Adminhtml/Card/Index.php | 12 +- .../Controller/Adminhtml/Card/InlineEdit.php | 8 +- .../Controller/Adminhtml/Card/MassDelete.php | 11 +- .../Controller/Adminhtml/Card/NewAction.php | 8 +- .../82/v1/Controller/Adminhtml/Card/Save.php | 12 +- .../82/v1/Controller/Adminhtml/CartItem.php | 13 +- .../v1/Controller/Adminhtml/CartItem/Edit.php | 12 +- .../Controller/Adminhtml/CartItem/Index.php | 12 +- .../Adminhtml/CartItem/InlineEdit.php | 8 +- .../Adminhtml/CartItem/MassDelete.php | 11 +- .../Adminhtml/CartItem/NewAction.php | 8 +- .../v1/Controller/Adminhtml/CartItem/Save.php | 12 +- .../82/v1/Controller/Adminhtml/Columns.php | 13 +- .../v1/Controller/Adminhtml/Columns/Edit.php | 12 +- .../v1/Controller/Adminhtml/Columns/Index.php | 12 +- .../Adminhtml/Columns/InlineEdit.php | 8 +- .../Adminhtml/Columns/MassDelete.php | 11 +- .../Adminhtml/Columns/NewAction.php | 8 +- .../v1/Controller/Adminhtml/Columns/Save.php | 12 +- .../82/v1/Controller/Adminhtml/Poster.php | 13 +- .../v1/Controller/Adminhtml/Poster/Index.php | 12 +- .../Crud/82/v1/Model/CardRepository.php | 25 +- .../Crud/82/v1/Model/CartItemRepository.php | 21 +- .../Crud/82/v1/Model/ColumnsRepository.php | 21 +- .../Crud/82/v1/Model/PosterRepository.php | 21 +- .../Crud/82/v1/Model/ResourceModel/Card.php | 11 +- .../Model/ResourceModel/Card/Collection.php | 7 +- .../Card/Relation/Store/ReadHandler.php | 5 +- .../Card/Relation/Store/SaveHandler.php | 11 +- test/Expectations/Project/.editorconfig | 14 - test/Expectations/Project/.eslintrc.json | 45 -- test/Expectations/Project/.php_cs | 51 --- test/Expectations/Project/.scss-lint.yml | 237 ----------- test/Expectations/Project/.shippable.yml | 21 - test/Expectations/Project/Gemfile | 4 - test/Expectations/Project/app/etc/config.php | 123 ------ test/Expectations/Project/composer.json | 73 ---- test/Expectations/Project/config/deploy.rb | 83 ---- test/Expectations/Project/grumphp.yml | 13 - test/Expectations/Project/gulpfile.js | 70 ---- test/Expectations/Project/package.json | 24 -- test/Project/ProjectTest.php | 72 ---- 103 files changed, 951 insertions(+), 2318 deletions(-) delete mode 100644 src/Jeeves/Console/Command/EmptyProject.php delete mode 100644 src/Jeeves/Generators/Project/Node.php delete mode 100644 test/Expectations/Project/.editorconfig delete mode 100644 test/Expectations/Project/.eslintrc.json delete mode 100644 test/Expectations/Project/.php_cs delete mode 100644 test/Expectations/Project/.scss-lint.yml delete mode 100644 test/Expectations/Project/.shippable.yml delete mode 100644 test/Expectations/Project/Gemfile delete mode 100644 test/Expectations/Project/app/etc/config.php delete mode 100644 test/Expectations/Project/composer.json delete mode 100644 test/Expectations/Project/config/deploy.rb delete mode 100644 test/Expectations/Project/grumphp.yml delete mode 100644 test/Expectations/Project/gulpfile.js delete mode 100644 test/Expectations/Project/package.json delete mode 100644 test/Project/ProjectTest.php diff --git a/composer.json b/composer.json index dc65ceb..e1800cc 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,8 @@ "symfony/console": "^5.0", "symfony/filesystem": "^5.0", "symfony/yaml": "^5.0", - "sabre/xml": "^2.2", - "nette/php-generator": "^3.0", + "sabre/xml": "^4.0", + "nette/php-generator": "^3.0|^4.0", "consolidation/self-update": "^2.0.3", "mygento/coding-standard": "~2.14.0-beta5" }, @@ -33,4 +33,4 @@ } }, "bin": ["bin/jeeves"] -} +} \ No newline at end of file diff --git a/grumphp.yml b/grumphp.yml index 559ba5f..0bc04fd 100644 --- a/grumphp.yml +++ b/grumphp.yml @@ -5,8 +5,8 @@ grumphp: - "die(" - "var_dump(" - "exit;" - phplint: - exclude: ['./test/Expectations/Crud/v1'] +# phplint: +# exclude: ['./test/Expectations/Crud'] phpunit: testsuite: 'Test' phpcsfixer: diff --git a/src/Jeeves/Console/Command/EmptyProject.php b/src/Jeeves/Console/Command/EmptyProject.php deleted file mode 100644 index dedc0a3..0000000 --- a/src/Jeeves/Console/Command/EmptyProject.php +++ /dev/null @@ -1,383 +0,0 @@ -setName('project-template') - ->setAliases(['empty-project']) - ->setDescription('Create new project template') - ->setDefinition([ - new InputArgument('name', InputArgument::OPTIONAL, 'Name of the entity'), - new InputArgument('path', InputArgument::OPTIONAL, 'Path of the module', '.'), - new InputArgument('repo', InputArgument::OPTIONAL, 'Project repository url'), - new InputArgument('vendor', InputArgument::OPTIONAL, 'Vendor of the module', 'mygento'), - ]) - ->setHelp( - <<php jeeves.phar project-template -EOT - ); - } - - protected function execute(InputInterface $input, OutputInterface $output): int - { - $io = $this->getIO(); - $path = $input->getArgument('path') . '/'; - $vendor = strtolower($input->getArgument('vendor')); - $name = strtolower($input->getArgument('name')); - $name = $io->askAndValidate( - 'Project Name [' . $name . ']: ', - function ($value) use ($name) { - if (null === $value) { - return $name; - } - - return $value; - }, - null, - $name - ); - - $repo = strtolower($input->getArgument('repo')); - $repo = $io->askAndValidate( - 'Project repository [' . $repo . ']: ', - function ($value) use ($repo) { - if (null === $value) { - return $repo; - } - - return $value; - }, - null, - $repo - ); - - $nodeGenerator = new \Mygento\Jeeves\Generators\Project\Node(); - $this->writeFile($path . 'package.json', $nodeGenerator->generatePackages($name)); - $this->writeFile($path . 'gulpfile.js', $nodeGenerator->generateGulp($name)); - $this->writeFile($path . '.eslintrc.json', $nodeGenerator->generateJsLint()); - - $phpGenerator = new \Mygento\Jeeves\Generators\Project\Php(); - if (!is_dir($path . 'app')) { - mkdir($path . 'app'); - } - - if (!is_dir($path . 'app/etc')) { - mkdir($path . 'app/etc'); - } - - if (!is_dir($path . 'app/design')) { - mkdir($path . 'app/design'); - } - - if (!is_dir($path . 'app/design/frontend')) { - mkdir($path . 'app/design/frontend'); - } - $v = ucfirst($vendor); - - if (!is_dir($path . 'app/design/frontend/' . $v)) { - mkdir($path . 'app/design/frontend/' . $v); - } - - if (!is_dir($path . 'app/design/frontend/' . $v . '/' . $name)) { - mkdir($path . 'app/design/frontend/' . $v . '/' . $name); - } - - if (!is_dir($path . 'app/design/frontend/' . $v . '/' . $name . '/web')) { - mkdir($path . 'app/design/frontend/' . $v . '/' . $name . '/web'); - } - - if (!is_dir($path . 'app/design/frontend/' . $v . '/' . $name . '/web/scss')) { - mkdir($path . 'app/design/frontend/' . $v . '/' . $name . '/web/scss'); - } - - if (!is_dir($path . 'app/design/frontend/' . $v . '/' . $name . '/web/css')) { - mkdir($path . 'app/design/frontend/' . $v . '/' . $name . '/web/css'); - } - - $this->writeFile($path . 'app/etc/config.php', $phpGenerator->generateConfig()); - $this->writeFile($path . 'composer.json', $phpGenerator->generateComposer($vendor, $name)); - $this->writeFile($path . 'grumphp.yml', $phpGenerator->generateLint()); - $this->writeFile($path . '.php_cs', $phpGenerator->generateFixer()); - - $deployGenerator = new \Mygento\Jeeves\Generators\Project\Deploy(); - if (!is_dir($path . 'config')) { - mkdir($path . 'config'); - } - $this->writeFile($path . 'config/deploy.rb', $deployGenerator->generateDeployer($name, $repo)); - $this->writeFile($path . 'Gemfile', $deployGenerator->generateGems()); - - $editor = <<writeFile($path . '.editorconfig', $editor); - - $scss = <<writeFile($path . '.scss-lint.yml', $scss); - - return 0; - } -} diff --git a/src/Jeeves/Generators/Common.php b/src/Jeeves/Generators/Common.php index a3075d6..5c99690 100644 --- a/src/Jeeves/Generators/Common.php +++ b/src/Jeeves/Generators/Common.php @@ -11,6 +11,26 @@ 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', '>='); + } + + protected function hasReadOnlyProp(string $version): bool + { + return version_compare($version, '8.1.0', '>='); + } + + protected function hasReadOnlyClass(string $version): bool + { + return version_compare($version, '8.2.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 091234f..03b42db 100644 --- a/src/Jeeves/Generators/Crud/Controllers/Create.php +++ b/src/Jeeves/Generators/Crud/Controllers/Create.php @@ -14,21 +14,32 @@ public function genAdminNewController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); + $constructorProp = $this->hasConstructorProp($phpVersion); + $readonlyProp = $this->hasReadOnlyProp($phpVersion); + $namespace = new PhpNamespace($rootNamespace . '\Controller\Adminhtml\\' . $entity); $class = $namespace->addClass($className) ->setExtends($rootNamespace . '\Controller\Adminhtml\\' . $entity); $entityName = $this->getEntityPrintName($entity); - $forward = $class->addProperty('resultForwardFactory') - ->setVisibility('private'); + 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'); + } + } + $body = 'parent::__construct($repository, $coreRegistry, $context);'; + if (!$constructorProp) { + $body .= PHP_EOL . PHP_EOL . '$this->resultForwardFactory = $resultForwardFactory;' . PHP_EOL; + } $construct = $class->addMethod('__construct') - ->setBody( - 'parent::__construct($repository, $coreRegistry, $context);' . PHP_EOL . PHP_EOL . - '$this->resultForwardFactory = $resultForwardFactory;' . PHP_EOL - ); + ->setBody($body); if ($typehint) { $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); @@ -36,21 +47,27 @@ public function genAdminNewController( $namespace->addUse('\Magento\Framework\Registry'); $namespace->addUse('\Magento\Backend\App\Action\Context'); $namespace->addUse('\Magento\Backend\Model\View\Result\ForwardFactory'); - $forward->setType('\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'); - $forward->addComment('@var \Magento\Backend\Model\View\Result\ForwardFactory'); } - $construct->addParameter('resultForwardFactory') - ->setTypeHint('\Magento\Backend\Model\View\Result\ForwardFactory'); - $construct->addParameter('repository')->setTypeHint($repository); - $construct->addParameter('coreRegistry')->setTypeHint('\Magento\Framework\Registry'); - $construct->addParameter('context')->setTypeHint('\Magento\Backend\App\Action\Context'); + if ($constructorProp) { + $construct + ->addPromotedParameter('resultForwardFactory') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType('\Magento\Backend\Model\View\Result\ForwardFactory'); + } else { + $construct->addParameter('resultForwardFactory')->setType('\Magento\Backend\Model\View\Result\ForwardFactory'); + } + + $construct->addParameter('repository')->setType($repository); + $construct->addParameter('coreRegistry')->setType('\Magento\Framework\Registry'); + $construct->addParameter('context')->setType('\Magento\Backend\App\Action\Context'); $execute = $class->addMethod('execute') ->addComment('Create new ' . $entityName) diff --git a/src/Jeeves/Generators/Crud/Controllers/Delete.php b/src/Jeeves/Generators/Crud/Controllers/Delete.php index f693203..b339155 100644 --- a/src/Jeeves/Generators/Crud/Controllers/Delete.php +++ b/src/Jeeves/Generators/Crud/Controllers/Delete.php @@ -12,7 +12,7 @@ public function genAdminDeleteController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Controller\Adminhtml\\' . $entity); $class = $namespace->addClass('Delete') diff --git a/src/Jeeves/Generators/Crud/Controllers/Edit.php b/src/Jeeves/Generators/Crud/Controllers/Edit.php index 82fa373..b02797c 100644 --- a/src/Jeeves/Generators/Crud/Controllers/Edit.php +++ b/src/Jeeves/Generators/Crud/Controllers/Edit.php @@ -16,7 +16,10 @@ public function genAdminEditController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); + $constructorProp = $this->hasConstructorProp($phpVersion); + $readonlyProp = $this->hasReadOnlyProp($phpVersion); + $entityName = $this->getEntityPrintName($entity); $namespace = new PhpNamespace($rootNamespace . '\Controller\Adminhtml\\' . $entity); @@ -29,31 +32,35 @@ public function genAdminEditController( $namespace->addUse($entityClass . 'Factory'); } - $factory = $class->addProperty('entityFactory') - ->setVisibility('private'); + if (!$constructorProp) { + $factory = $class->addProperty('entityFactory') + ->setVisibility('private'); - $result = $class->addProperty('resultPageFactory') - ->setVisibility('private'); + $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'); + 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'); + } } - $construct = $class->addMethod('__construct') - ->setBody( - 'parent::__construct($repository, $coreRegistry, $context);' . PHP_EOL . PHP_EOL + $body = 'parent::__construct($repository, $coreRegistry, $context);'; + if (!$constructorProp) { + $body .= PHP_EOL . PHP_EOL . '$this->entityFactory = $entityFactory;' . PHP_EOL - . '$this->resultPageFactory = $resultPageFactory;' . PHP_EOL - ); + . '$this->resultPageFactory = $resultPageFactory;' . PHP_EOL; + } + $construct = $class->addMethod('__construct')->setBody($body); if ($typehint) { - $namespace->addUse($repository); - $namespace->addUse('\Magento\Framework\Registry'); - $namespace->addUse('\Magento\Backend\App\Action\Context'); + $namespace + ->addUse($repository) + ->addUse('\Magento\Framework\Registry') + ->addUse('\Magento\Backend\App\Action\Context'); } else { $construct ->addComment('@param ' . $entityClass . 'Factory $entityFactory') @@ -63,11 +70,29 @@ public function genAdminEditController( ->addComment('@param \Magento\Backend\App\Action\Context $context'); } - $construct->addParameter('entityFactory')->setTypeHint($entityClass . 'Factory'); - $construct->addParameter('resultPageFactory')->setTypeHint('\Magento\Framework\View\Result\PageFactory'); - $construct->addParameter('repository')->setTypeHint($repository); - $construct->addParameter('coreRegistry')->setTypeHint('\Magento\Framework\Registry'); - $construct->addParameter('context')->setTypeHint('\Magento\Backend\App\Action\Context'); + if ($constructorProp) { + $construct + ->addPromotedParameter('entityFactory') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType($entityClass . 'Factory'); + + $construct + ->addPromotedParameter('resultPageFactory') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType('\Magento\Framework\View\Result\PageFactory'); + } else { + $construct + ->addParameter('entityFactory') + ->setType($entityClass . 'Factory'); + $construct + ->addParameter('resultPageFactory') + ->setType('\Magento\Framework\View\Result\PageFactory'); + } + $construct->addParameter('repository')->setType($repository); + $construct->addParameter('coreRegistry')->setType('\Magento\Framework\Registry'); + $construct->addParameter('context')->setType('\Magento\Backend\App\Action\Context'); $execute = $class->addMethod('execute') ->addComment('Edit ' . $entityName . ' action') diff --git a/src/Jeeves/Generators/Crud/Controllers/Inline.php b/src/Jeeves/Generators/Crud/Controllers/Inline.php index f731e9c..436c84e 100644 --- a/src/Jeeves/Generators/Crud/Controllers/Inline.php +++ b/src/Jeeves/Generators/Crud/Controllers/Inline.php @@ -14,36 +14,50 @@ public function genAdminInlineController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); + $constructorProp = $this->hasConstructorProp($phpVersion); + $readonlyProp = $this->hasReadOnlyProp($phpVersion); + $namespace = new PhpNamespace($rootNamespace . '\Controller\Adminhtml\\' . $entity); $class = $namespace->addClass($className) ->setExtends($rootNamespace . '\Controller\Adminhtml\\' . $entity); - $json = $class->addProperty('jsonFactory') - ->setVisibility('private'); - - if ($typehint) { - $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); - $json->setType('\Magento\Framework\Controller\Result\JsonFactory'); - } else { - $json->addComment('@var \Magento\Framework\Controller\Result\JsonFactory'); + 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'); + } } + $namespace->addUse('\Magento\Framework\Exception\NoSuchEntityException'); - $construct = $class->addMethod('__construct') - ->setBody( - 'parent::__construct($repository, $coreRegistry, $context);' . PHP_EOL . PHP_EOL - . '$this->jsonFactory = $jsonFactory;' - ); + $body = 'parent::__construct($repository, $coreRegistry, $context);'; + if (!$constructorProp) { + $body .= PHP_EOL . PHP_EOL . '$this->jsonFactory = $jsonFactory;'; + } + $construct = $class->addMethod('__construct')->setBody($body); - $construct->addParameter('jsonFactory') - ->setTypeHint('\Magento\Framework\Controller\Result\JsonFactory'); - $construct->addParameter('repository')->setTypeHint($repository); - $construct->addParameter('coreRegistry')->setTypeHint('\Magento\Framework\Registry'); - $construct->addParameter('context')->setTypeHint('\Magento\Backend\App\Action\Context'); + if ($constructorProp) { + $construct + ->addPromotedParameter('jsonFactory') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType('\Magento\Framework\Controller\Result\JsonFactory'); + } else { + $construct + ->addParameter('jsonFactory') + ->setType('\Magento\Framework\Controller\Result\JsonFactory'); + } + + $construct->addParameter('repository')->setType($repository); + $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'); diff --git a/src/Jeeves/Generators/Crud/Controllers/Mass.php b/src/Jeeves/Generators/Crud/Controllers/Mass.php index 0ed055b..af40639 100644 --- a/src/Jeeves/Generators/Crud/Controllers/Mass.php +++ b/src/Jeeves/Generators/Crud/Controllers/Mass.php @@ -15,35 +15,45 @@ public function genAdminMassController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); + $constructorProp = $this->hasConstructorProp($phpVersion); + $readonlyProp = $this->hasReadOnlyProp($phpVersion); + $namespace = new PhpNamespace($rootNamespace . '\Controller\Adminhtml\\' . $entity); $namespace->addUse('Magento\Framework\Controller\ResultFactory'); $class = $namespace->addClass($className) ->setExtends($rootNamespace . '\Controller\Adminhtml\\' . $entity); - $filter = $class->addProperty('filter') - ->setVisibility('private'); - - $collect = $class->addProperty('collectionFactory') - ->setVisibility('private'); - if ($typehint) { $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); $namespace->addUse('\Magento\Ui\Component\MassAction\Filter'); $namespace->addUse($collection); - $filter->setType('\Magento\Ui\Component\MassAction\Filter'); - $collect->setType($collection); - } else { - $filter->addComment('@var \Magento\Ui\Component\MassAction\Filter'); - $collect->addComment('@var ' . $collection); } - $construct = $class->addMethod('__construct') - ->setBody('$this->filter = $filter;' . PHP_EOL - . '$this->collectionFactory = $collectionFactory;' . PHP_EOL - . 'parent::__construct($repository, $coreRegistry, $context); - '); + if (!$constructorProp) { + $filter = $class->addProperty('filter') + ->setVisibility('private'); + + $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); + } + } + + $body = ''; + if (!$constructorProp) { + $body .= '$this->filter = $filter;' . PHP_EOL + . '$this->collectionFactory = $collectionFactory;' . PHP_EOL; + } + $body .= 'parent::__construct($repository, $coreRegistry, $context);'; + $construct = $class->addMethod('__construct')->setBody($body); if ($typehint) { $namespace->addUse($repository); @@ -58,13 +68,28 @@ public function genAdminMassController( ->addComment('@param \Magento\Backend\App\Action\Context $context'); } - $construct->addParameter('collectionFactory') - ->setTypeHint($collection); - $construct->addParameter('filter') - ->setTypeHint('\Magento\Ui\Component\MassAction\Filter'); - $construct->addParameter('repository')->setTypeHint($repository); - $construct->addParameter('coreRegistry')->setTypeHint('\Magento\Framework\Registry'); - $construct->addParameter('context')->setTypeHint('\Magento\Backend\App\Action\Context'); + if ($constructorProp) { + $construct + ->addPromotedParameter('collectionFactory') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType($collection); + $construct + ->addPromotedParameter('filter') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType('\Magento\Ui\Component\MassAction\Filter'); + } else { + $construct + ->addParameter('collectionFactory') + ->setType($collection); + $construct + ->addParameter('filter') + ->setType('\Magento\Ui\Component\MassAction\Filter'); + } + $construct->addParameter('repository')->setType($repository); + $construct->addParameter('coreRegistry')->setType('\Magento\Framework\Registry'); + $construct->addParameter('context')->setType('\Magento\Backend\App\Action\Context'); $execute = $class->addMethod('execute') ->addComment('Execute action') diff --git a/src/Jeeves/Generators/Crud/Controllers/Save.php b/src/Jeeves/Generators/Crud/Controllers/Save.php index 2fc2a34..9a8a4e4 100644 --- a/src/Jeeves/Generators/Crud/Controllers/Save.php +++ b/src/Jeeves/Generators/Crud/Controllers/Save.php @@ -16,7 +16,10 @@ public function genAdminSaveController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); + $constructorProp = $this->hasConstructorProp($phpVersion); + $readonlyProp = $this->hasReadOnlyProp($phpVersion); + $entityName = $this->getEntityPrintName($entity); $namespace = new PhpNamespace($rootNamespace . '\Controller\Adminhtml\\' . $entity); $namespace->addUse('Magento\Framework\Exception\LocalizedException'); @@ -24,35 +27,39 @@ public function genAdminSaveController( $class = $namespace->addClass('Save') ->setExtends($rootNamespace . '\Controller\Adminhtml\\' . $entity); - $persistor = $class->addProperty('dataPersistor') - ->setVisibility('private'); + if (!$constructorProp) { + $persistor = $class->addProperty('dataPersistor') + ->setVisibility('private'); - $factory = $class->addProperty('entityFactory') - ->setVisibility('private'); + $factory = $class->addProperty('entityFactory') + ->setVisibility('private'); - if ($typehint) { - $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); - $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'); + 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'); + } } - $construct = $class->addMethod('__construct') - ->setBody( - 'parent::__construct($repository, $coreRegistry, $context);' . PHP_EOL . PHP_EOL + $body = 'parent::__construct($repository, $coreRegistry, $context);'; + if (!$constructorProp) { + $body .= PHP_EOL . PHP_EOL . '$this->dataPersistor = $dataPersistor;' . PHP_EOL - . '$this->entityFactory = $entityFactory;' . PHP_EOL - ); + . '$this->entityFactory = $entityFactory;' . PHP_EOL; + } + $construct = $class->addMethod('__construct')->setBody($body); if ($typehint) { - $namespace->addUse('\Magento\Framework\App\Request\DataPersistorInterface'); - $namespace->addUse($entityClass . 'Factory'); - $namespace->addUse($repository); - $namespace->addUse('\Magento\Framework\Registry'); - $namespace->addUse('\Magento\Backend\App\Action\Context'); - $namespace->addUse('\Magento\Framework\Exception\NoSuchEntityException'); + $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') @@ -62,12 +69,29 @@ public function genAdminSaveController( ->addComment('@param \Magento\Backend\App\Action\Context $context'); } - $construct->addParameter('dataPersistor') - ->setTypeHint('\Magento\Framework\App\Request\DataPersistorInterface'); - $construct->addParameter('entityFactory')->setTypeHint($entityClass . 'Factory'); - $construct->addParameter('repository')->setTypeHint($repository); - $construct->addParameter('coreRegistry')->setTypeHint('\Magento\Framework\Registry'); - $construct->addParameter('context')->setTypeHint('\Magento\Backend\App\Action\Context'); + if ($constructorProp) { + $construct + ->addPromotedParameter('dataPersistor') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType('\Magento\Framework\App\Request\DataPersistorInterface'); + $construct + ->addPromotedParameter('entityFactory') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType($entityClass . 'Factory'); + } else { + $construct + ->addParameter('dataPersistor') + ->setType('\Magento\Framework\App\Request\DataPersistorInterface'); + $construct + ->addParameter('entityFactory') + ->setType($entityClass . 'Factory'); + } + + $construct->addParameter('repository')->setType($repository); + $construct->addParameter('coreRegistry')->setType('\Magento\Framework\Registry'); + $construct->addParameter('context')->setType('\Magento\Backend\App\Action\Context'); $execute = $class->addMethod('execute') ->addComment('Save ' . $entityName . ' action') diff --git a/src/Jeeves/Generators/Crud/Controllers/Shared.php b/src/Jeeves/Generators/Crud/Controllers/Shared.php index 04ae35a..fe21968 100644 --- a/src/Jeeves/Generators/Crud/Controllers/Shared.php +++ b/src/Jeeves/Generators/Crud/Controllers/Shared.php @@ -14,7 +14,10 @@ public function genAdminAbstractController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); + $constructorProp = $this->hasConstructorProp($phpVersion); + $readonlyProp = $this->hasReadOnlyProp($phpVersion); + $namespace = new PhpNamespace($rootNamespace . '\Controller\Adminhtml'); if ($typehint) { @@ -29,38 +32,61 @@ public function genAdminAbstractController( ->addComment('') ->addComment('@see _isAllowed()'); - $reg = $class->addProperty('coreRegistry') - ->setVisibility('protected'); - if ($typehint) { $namespace->addUse('\Magento\Framework\Registry'); - $reg->setType('\Magento\Framework\Registry'); - } else { - $reg->addComment('Core registry'); - $reg->addComment(''); - $reg->addComment('@var \Magento\Framework\Registry'); + $namespace->addUse($repository); } - $repo = $class->addProperty('repository') - ->setVisibility('protected'); + if (!$constructorProp) { + $reg = $class->addProperty('coreRegistry') + ->setVisibility('protected'); - if ($typehint) { - $repo->setType($repository); - $namespace->addUse($repository); - } else { - $repo->addComment($className . ' repository') - ->addComment('') - ->addComment('@var ' . $repository); + if ($typehint) { + $reg->setType('\Magento\Framework\Registry'); + } else { + $reg->addComment('Core registry'); + $reg->addComment(''); + $reg->addComment('@var \Magento\Framework\Registry'); + } + + $repo = $class->addProperty('repository') + ->setVisibility('protected'); + + if ($typehint) { + $repo->setType($repository); + } else { + $repo->addComment($className . ' repository') + ->addComment('') + ->addComment('@var ' . $repository); + } } - $construct = $class->addMethod('__construct') - ->setBody('parent::__construct($context);' . PHP_EOL . PHP_EOL + $body = 'parent::__construct($context);'; + if (!$constructorProp) { + $body .= PHP_EOL . PHP_EOL . '$this->repository = $repository;' . PHP_EOL - . '$this->coreRegistry = $coreRegistry;'); + . '$this->coreRegistry = $coreRegistry;'; + } + + $construct = $class->addMethod('__construct') + ->setBody($body); - $construct->addParameter('repository')->setTypeHint($repository); - $construct->addParameter('coreRegistry')->setTypeHint('\Magento\Framework\Registry'); - $construct->addParameter('context')->setTypeHint('\Magento\Backend\App\Action\Context'); + if ($constructorProp) { + $construct + ->addPromotedParameter('repository') + ->setReadOnly($readonlyProp) + ->setProtected() + ->setType($repository); + $construct + ->addPromotedParameter('coreRegistry') + ->setReadOnly($readonlyProp) + ->setProtected() + ->setType('\Magento\Framework\Registry'); + } else { + $construct->addParameter('repository')->setType($repository); + $construct->addParameter('coreRegistry')->setType('\Magento\Framework\Registry'); + } + $construct->addParameter('context')->setType('\Magento\Backend\App\Action\Context'); if (!$typehint) { $construct diff --git a/src/Jeeves/Generators/Crud/Controllers/View.php b/src/Jeeves/Generators/Crud/Controllers/View.php index 6f20e46..af751b3 100644 --- a/src/Jeeves/Generators/Crud/Controllers/View.php +++ b/src/Jeeves/Generators/Crud/Controllers/View.php @@ -15,40 +15,68 @@ public function genAdminViewController( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); + $constructorProp = $this->hasConstructorProp($phpVersion); + $readonlyProp = $this->hasReadOnlyProp($phpVersion); + $entityName = $this->getEntityPrintName($entity); $namespace = new PhpNamespace($rootNamespace . '\Controller\Adminhtml\\' . $entity); $class = $namespace->addClass('Index') ->setExtends($rootNamespace . '\Controller\Adminhtml\\' . $entity); - $result = $class->addProperty('resultPageFactory') - ->setVisibility('private'); - $pers = $class->addProperty('dataPersistor') - ->setVisibility('private'); - if ($typehint) { - $result->setType('\Magento\Framework\View\Result\PageFactory'); - $pers->setType('\Magento\Framework\App\Request\DataPersistorInterface'); $namespace->addUse('\Magento\Framework\View\Result\PageFactory'); $namespace->addUse('\Magento\Framework\App\Request\DataPersistorInterface'); $namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity); - } else { - $pers->addComment('@var \Magento\Framework\App\Request\DataPersistorInterface'); - $result->addComment('@var \Magento\Framework\View\Result\PageFactory'); } - $construct = $class->addMethod('__construct') - ->setBody( - 'parent::__construct($repository, $coreRegistry, $context);' . PHP_EOL . PHP_EOL + if (!$constructorProp) { + $result = $class->addProperty('resultPageFactory') + ->setVisibility('private'); + $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'); + } + } + + $body = 'parent::__construct($repository, $coreRegistry, $context);'; + if (!$constructorProp) { + $body .= PHP_EOL . PHP_EOL . '$this->resultPageFactory = $resultPageFactory;' . PHP_EOL - . '$this->dataPersistor = $dataPersistor;' . PHP_EOL - ); + . '$this->dataPersistor = $dataPersistor;' . PHP_EOL; + } + $construct = $class->addMethod('__construct') + ->setBody($body); + + if ($constructorProp) { + $construct + ->addPromotedParameter('resultPageFactory') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType('\Magento\Framework\View\Result\PageFactory'); + $construct + ->addPromotedParameter('dataPersistor') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType('\Magento\Framework\App\Request\DataPersistorInterface'); + } else { + $construct + ->addParameter('resultPageFactory') + ->setType('\Magento\Framework\View\Result\PageFactory'); + $construct + ->addParameter('dataPersistor') + ->setType('\Magento\Framework\App\Request\DataPersistorInterface'); + } - $construct->addParameter('resultPageFactory')->setTypeHint('\Magento\Framework\View\Result\PageFactory'); - $construct->addParameter('dataPersistor')->setTypeHint('\Magento\Framework\App\Request\DataPersistorInterface'); - $construct->addParameter('repository')->setTypeHint($repository); - $construct->addParameter('coreRegistry')->setTypeHint('\Magento\Framework\Registry'); - $construct->addParameter('context')->setTypeHint('\Magento\Backend\App\Action\Context'); + $construct->addParameter('repository')->setType($repository); + $construct->addParameter('coreRegistry')->setType('\Magento\Framework\Registry'); + $construct->addParameter('context')->setType('\Magento\Backend\App\Action\Context'); if ($typehint) { $namespace->addUse($repository); diff --git a/src/Jeeves/Generators/Crud/Interfaces/Model.php b/src/Jeeves/Generators/Crud/Interfaces/Model.php index a6334fa..b21ce51 100644 --- a/src/Jeeves/Generators/Crud/Interfaces/Model.php +++ b/src/Jeeves/Generators/Crud/Interfaces/Model.php @@ -17,7 +17,7 @@ public function genModelInterface( bool $withStore = false, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Api\Data'); $interface = $namespace->addInterface($className); diff --git a/src/Jeeves/Generators/Crud/Interfaces/Repository.php b/src/Jeeves/Generators/Crud/Interfaces/Repository.php index 892677c..557c33d 100644 --- a/src/Jeeves/Generators/Crud/Interfaces/Repository.php +++ b/src/Jeeves/Generators/Crud/Interfaces/Repository.php @@ -16,7 +16,7 @@ public function genModelRepositoryInterface( bool $hasApi = false, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Api'); $interface = $namespace->addInterface($className); @@ -37,7 +37,7 @@ public function genModelRepositoryInterface( $save->addComment('@return ' . $entInterface); } - $save->addParameter('entity')->setTypeHint($entInterface); + $save->addParameter('entity')->setType($entInterface); if ($typehint) { $save->setReturnType($entInterface); @@ -75,7 +75,7 @@ public function genModelRepositoryInterface( } $getList->addParameter('searchCriteria') - ->setTypeHint('\Magento\Framework\Api\SearchCriteriaInterface'); + ->setType('\Magento\Framework\Api\SearchCriteriaInterface'); if ($typehint) { $getList->setReturnType($resultInterface); @@ -95,7 +95,7 @@ public function genModelRepositoryInterface( } $del->addParameter('entity') - ->setTypeHint($entInterface); + ->setType($entInterface); if ($typehint) { $del->setReturnType('bool'); diff --git a/src/Jeeves/Generators/Crud/Interfaces/Search.php b/src/Jeeves/Generators/Crud/Interfaces/Search.php index bb8dc46..0726aa4 100644 --- a/src/Jeeves/Generators/Crud/Interfaces/Search.php +++ b/src/Jeeves/Generators/Crud/Interfaces/Search.php @@ -15,7 +15,7 @@ public function genModelSearchInterface( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Api\Data'); $namespace->addUse('\Magento\Framework\Api\SearchResultsInterface'); @@ -34,7 +34,7 @@ public function genModelSearchInterface( ->setVisibility('public') ->addComment('Set list of ' . $print) ->addComment('@param ' . $entInterface . '[] $items'); - $set->addParameter('items')->setTypeHint('array'); + $set->addParameter('items')->setType('array'); if ($typehint) { // $set->setReturnType('self'); diff --git a/src/Jeeves/Generators/Crud/Models/Collection.php b/src/Jeeves/Generators/Crud/Models/Collection.php index c1fadbc..0b07afd 100644 --- a/src/Jeeves/Generators/Crud/Models/Collection.php +++ b/src/Jeeves/Generators/Crud/Models/Collection.php @@ -18,7 +18,10 @@ public function genResourceCollection( bool $withStore = false, string $phpVersion = PHP_VERSION ) { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $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'); @@ -69,13 +72,15 @@ public function genResourceCollection( $namespace->addUse('\Magento\Framework\Model\ResourceModel\Db\AbstractDb'); } - $mdPool = $class->addProperty('metadataPool'); - $mdPool->setVisibility('private'); + 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'); + if ($typehint) { + $mdPool->setType('\Magento\Framework\EntityManager\MetadataPool'); + } else { + $mdPool->addComment('@var \Magento\Framework\EntityManager\MetadataPool'); + } } $construct = $class->addMethod('__construct')->setVisibility('public'); @@ -91,23 +96,51 @@ public function genResourceCollection( } $construct->addComment('@SuppressWarnings(PHPMD.ExcessiveParameterList)'); - $construct->addParameter('metadataPool')->setType('\Magento\Framework\EntityManager\MetadataPool'); - $construct->addParameter('entityFactory')->setType('\Magento\Framework\Data\Collection\EntityFactoryInterface'); - $construct->addParameter('logger')->setType('\Psr\Log\LoggerInterface'); - $construct->addParameter('fetchStrategy')->setType('\Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); - $construct->addParameter('eventManager')->setType('\Magento\Framework\Event\ManagerInterface'); - $construct->addParameter('connection')->setType('\Magento\Framework\DB\Adapter\AdapterInterface')->setDefaultValue(null); - $construct->addParameter('resource')->setTypeHint('\Magento\Framework\Model\ResourceModel\Db\AbstractDb')->setDefaultValue(null); - - $construct->setBody('parent::__construct(' . PHP_EOL + if ($constructorProp) { + $construct + ->addPromotedParameter('metadataPool') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType('\Magento\Framework\EntityManager\MetadataPool'); + } else { + $construct + ->addParameter('metadataPool') + ->setType('\Magento\Framework\EntityManager\MetadataPool'); + } + $construct + ->addParameter('entityFactory') + ->setType('\Magento\Framework\Data\Collection\EntityFactoryInterface'); + $construct + ->addParameter('logger') + ->setType('\Psr\Log\LoggerInterface'); + $construct + ->addParameter('fetchStrategy') + ->setType('\Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); + $construct + ->addParameter('eventManager') + ->setType('\Magento\Framework\Event\ManagerInterface'); + $construct + ->addParameter('connection') + ->setType('\Magento\Framework\DB\Adapter\AdapterInterface') + ->setDefaultValue(null); + $construct + ->addParameter('resource') + ->setType('\Magento\Framework\Model\ResourceModel\Db\AbstractDb') + ->setDefaultValue(null); + + $body = 'parent::__construct(' . PHP_EOL . self::TAB . '$entityFactory,' . PHP_EOL . self::TAB . '$logger,' . PHP_EOL . self::TAB . '$fetchStrategy,' . PHP_EOL . self::TAB . '$eventManager,' . PHP_EOL . self::TAB . '$connection,' . PHP_EOL . self::TAB . '$resource' . PHP_EOL - . ');' . PHP_EOL - . '$this->metadataPool = $metadataPool;'); + . ');'; + if (!$constructorProp) { + $body .= PHP_EOL + . '$this->metadataPool = $metadataPool;'; + } + $construct->setBody($body); $afterLoad = $class->addMethod('_afterLoad')->setVisibility('protected'); $afterLoad->setBody( diff --git a/src/Jeeves/Generators/Crud/Models/Model.php b/src/Jeeves/Generators/Crud/Models/Model.php index 373d3ca..f4f1990 100644 --- a/src/Jeeves/Generators/Crud/Models/Model.php +++ b/src/Jeeves/Generators/Crud/Models/Model.php @@ -18,7 +18,7 @@ public function genModel( bool $withStore = false, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Model'); $namespace->addUse('Magento\Framework\Model\AbstractModel'); $namespace->addUse($entInterface); diff --git a/src/Jeeves/Generators/Crud/Models/Read.php b/src/Jeeves/Generators/Crud/Models/Read.php index 33ed661..d85de26 100644 --- a/src/Jeeves/Generators/Crud/Models/Read.php +++ b/src/Jeeves/Generators/Crud/Models/Read.php @@ -14,26 +14,45 @@ public function genReadHandler( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); + $constructorProp = $this->hasConstructorProp($phpVersion); + $readonlyProp = $this->hasReadOnlyProp($phpVersion); + $namespace = new PhpNamespace($rootNamespace . '\Model\ResourceModel\\' . $entity . '\\Relation\\Store'); $namespace->addUse($interface); $class = $namespace->addClass('ReadHandler'); $class->addImplement('\Magento\Framework\EntityManager\Operation\ExtensionInterface'); - $res = $class->addProperty('resource')->setVisibility('private'); if ($typehint) { $namespace->addUse('\Magento\Framework\EntityManager\Operation\ExtensionInterface'); $namespace->addUse($resourceClass); - $res->setType($resourceClass); - } else { - $res->addComment('@var ' . $resourceClass); + } + + if (!$constructorProp) { + $res = $class->addProperty('resource')->setVisibility('private'); + if ($typehint) { + $res->setType($resourceClass); + } else { + $res->addComment('@var ' . $resourceClass); + } } $construct = $class->addMethod('__construct') ->setVisibility('public'); - $construct->addParameter('resource')->setType($resourceClass); - $construct->setBody('$this->resource = $resource;'); + if ($constructorProp) { + $construct + ->addPromotedParameter('resource') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType($resourceClass); + } else { + $construct->addParameter('resource')->setType($resourceClass); + } + + if (!$constructorProp) { + $construct->setBody('$this->resource = $resource;'); + } $execute = $class->addMethod('execute') ->addComment('@inheritDoc') diff --git a/src/Jeeves/Generators/Crud/Models/Resource.php b/src/Jeeves/Generators/Crud/Models/Resource.php index 6c7b32a..b4587f2 100644 --- a/src/Jeeves/Generators/Crud/Models/Resource.php +++ b/src/Jeeves/Generators/Crud/Models/Resource.php @@ -16,7 +16,10 @@ public function genResourceModel( bool $withStore = false, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); + $constructorProp = $this->hasConstructorProp($phpVersion); + $readonlyProp = $this->hasReadOnlyProp($phpVersion); + $namespace = new PhpNamespace($rootNamespace . '\Model\ResourceModel'); if ($typehint) { @@ -47,21 +50,26 @@ public function genResourceModel( return $namespace; } - $em = $class->addProperty('entityManager'); - $em->setVisibility('private'); + if (!$constructorProp) { + $em = $class->addProperty('entityManager'); + $em->setVisibility('private'); + + $mdPool = $class->addProperty('metadataPool'); + $mdPool->setVisibility('private'); - $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'); + } + } if ($typehint) { - $namespace->addUse('\Magento\Framework\EntityManager\EntityManager'); - $em->setType('\Magento\Framework\EntityManager\EntityManager'); - $namespace->addUse('\Magento\Framework\EntityManager\MetadataPool'); - $mdPool->setType('\Magento\Framework\EntityManager\MetadataPool'); - $namespace->addUse('\Magento\Framework\Model\ResourceModel\Db\Context'); - } else { - $em->addComment('@var \Magento\Framework\EntityManager\EntityManager'); - $mdPool->addComment('@var \Magento\Framework\EntityManager\MetadataPool'); + $namespace->addUse('\Magento\Framework\EntityManager\EntityManager') + ->addUse('\Magento\Framework\EntityManager\MetadataPool') + ->addUse('\Magento\Framework\Model\ResourceModel\Db\Context'); } $construct = $class->addMethod('__construct'); @@ -74,8 +82,26 @@ public function genResourceModel( ->addComment('@param string $connectionName'); } - $construct->addParameter('entityManager')->setType('\Magento\Framework\EntityManager\EntityManager'); - $construct->addParameter('metadataPool')->setType('\Magento\Framework\EntityManager\MetadataPool'); + if ($constructorProp) { + $construct + ->addPromotedParameter('entityManager') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType('\Magento\Framework\EntityManager\EntityManager'); + $construct + ->addPromotedParameter('metadataPool') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType('\Magento\Framework\EntityManager\MetadataPool'); + } else { + $construct + ->addParameter('entityManager') + ->setType('\Magento\Framework\EntityManager\EntityManager'); + $construct + ->addParameter('metadataPool') + ->setType('\Magento\Framework\EntityManager\MetadataPool'); + } + $construct->addParameter('context')->setType('\Magento\Framework\Model\ResourceModel\Db\Context'); $conParam = $construct->addParameter('connectionName')->setDefaultValue(null); @@ -83,9 +109,13 @@ public function genResourceModel( $conParam->setType('string'); } - $construct->setBody('parent::__construct($context, $connectionName);' . PHP_EOL - . '$this->entityManager = $entityManager;' . PHP_EOL - . '$this->metadataPool = $metadataPool;'); + $body = 'parent::__construct($context, $connectionName);'; + if (!$constructorProp) { + $body .= PHP_EOL + . '$this->entityManager = $entityManager;' . PHP_EOL + . '$this->metadataPool = $metadataPool;'; + } + $construct->setBody($body); $connection = $class->addMethod('getConnection') ->addComment('@inheritDoc') diff --git a/src/Jeeves/Generators/Crud/Models/Save.php b/src/Jeeves/Generators/Crud/Models/Save.php index 3eb2552..8ef7b15 100644 --- a/src/Jeeves/Generators/Crud/Models/Save.php +++ b/src/Jeeves/Generators/Crud/Models/Save.php @@ -14,7 +14,10 @@ public function genSaveHandler( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); + $constructorProp = $this->hasConstructorProp($phpVersion); + $readonlyProp = $this->hasReadOnlyProp($phpVersion); + $namespace = new PhpNamespace($rootNamespace . '\Model\ResourceModel\\' . $entity . '\\Relation\\Store'); $namespace->addUse($interface); $namespace->addUse($rootNamespace . '\Model\ResourceModel\\' . $entity); @@ -23,25 +26,47 @@ public function genSaveHandler( $class = $namespace->addClass('SaveHandler'); $class->addImplement('\Magento\Framework\EntityManager\Operation\ExtensionInterface'); - $res = $class->addProperty('resource') - ->setVisibility('private'); - $mtdPool = $class->addProperty('metadataPool') - ->setVisibility('private'); - if ($typehint) { $namespace->addUse('\Magento\Framework\EntityManager\Operation\ExtensionInterface'); - $res->setType($resourceClass); - $mtdPool->setType('\Magento\Framework\EntityManager\MetadataPool'); + } + + 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'); + } + } + + $construct = $class->addMethod('__construct')->setVisibility('public'); + if ($constructorProp) { + $construct + ->addPromotedParameter('resource') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType($resourceClass); + $construct + ->addPromotedParameter('metadataPool') + ->setReadOnly($readonlyProp) + ->setPrivate() + ->setType('\Magento\Framework\EntityManager\MetadataPool'); } else { - $res->addComment('@var ' . $resourceClass); - $mtdPool->addComment('@var \Magento\Framework\EntityManager\MetadataPool'); + $construct + ->addParameter('resource') + ->setType($resourceClass); + $construct + ->addParameter('metadataPool') + ->setType('\Magento\Framework\EntityManager\MetadataPool'); } - $construct = $class->addMethod('__construct') - ->setVisibility('public'); - $construct->addParameter('resource')->setType($resourceClass); - $construct->addParameter('metadataPool')->setType('\Magento\Framework\EntityManager\MetadataPool'); - $construct->setBody('$this->resource = $resource;' . PHP_EOL . '$this->metadataPool = $metadataPool;'); + if (!$constructorProp) { + $construct->setBody('$this->resource = $resource;' . PHP_EOL . '$this->metadataPool = $metadataPool;'); + } $execute = $class->addMethod('execute') ->addComment('@inheritDoc') diff --git a/src/Jeeves/Generators/Crud/Repositories/Filter.php b/src/Jeeves/Generators/Crud/Repositories/Filter.php index b310425..c9c31b3 100644 --- a/src/Jeeves/Generators/Crud/Repositories/Filter.php +++ b/src/Jeeves/Generators/Crud/Repositories/Filter.php @@ -13,7 +13,8 @@ public function getRepoFilter( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); + $namespace = new PhpNamespace($rootNamespace . '\Model\SearchCriteria'); $namespace->addUse($interface); $namespace->addUse('Magento\Framework\Api\Filter'); diff --git a/src/Jeeves/Generators/Crud/Repositories/Repository.php b/src/Jeeves/Generators/Crud/Repositories/Repository.php index f4dc451..aede0b8 100644 --- a/src/Jeeves/Generators/Crud/Repositories/Repository.php +++ b/src/Jeeves/Generators/Crud/Repositories/Repository.php @@ -19,7 +19,11 @@ public function genRepository( bool $withStore = false, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); + $constructorProp = $this->hasConstructorProp($phpVersion); + $readonlyProp = $this->hasReadOnlyProp($phpVersion); + $readonlyClass = false; //$this->hasReadOnlyClass($phpVersion); + $namespace = new PhpNamespace($rootNamespace . '\Model'); $namespace->addUse('\Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface'); $namespace->addUse('\Magento\Framework\Exception\NoSuchEntityException'); @@ -30,30 +34,42 @@ public function genRepository( $class->setImplements([$repoInterface]); $class->setComment('@SuppressWarnings(PHPMD.CouplingBetweenObjects)'); - $rs = $class->addProperty('resource') - ->setVisibility('private'); - $cf = $class->addProperty('collectionFactory') - ->setVisibility('private'); - $ef = $class->addProperty('entityFactory') - ->setVisibility('private'); - $sr = $class->addProperty('searchResultsFactory') - ->setVisibility('private'); + if ($readonlyClass) { /** @phpstan-ignore-line */ + $class->setReadOnly($readonlyClass); /** @phpstan-ignore-line */ + } + + if (!$constructorProp) { + $rs = $class->addProperty('resource') + ->setVisibility('private'); + $cf = $class->addProperty('collectionFactory') + ->setVisibility('private'); + $ef = $class->addProperty('entityFactory') + ->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'); - } else { - $rs->addComment('@var ' . $resource); - $cf->addComment('@var ' . $collection . 'Factory'); - $ef->addComment('@var ' . $entityInterface . 'Factory'); - $sr->addComment('@var ' . $results . 'Factory'); } $construct = $class->addMethod('__construct')->setVisibility('public'); @@ -65,48 +81,102 @@ public function genRepository( ->addComment('@param ' . $results . 'Factory $searchResultsFactory'); } - $construct->addParameter('resource')->setType($resource); - $construct->addParameter('collectionFactory')->setType($collection . 'Factory'); - $construct->addParameter('entityFactory')->setType($entityInterface . 'Factory'); - $construct->addParameter('searchResultsFactory')->setType($results . 'Factory'); + if ($constructorProp) { + $construct + ->addPromotedParameter('resource') + ->setReadOnly($readonlyProp && !$readonlyClass) /** @phpstan-ignore-line */ + ->setPrivate() + ->setType($resource); + $construct + ->addPromotedParameter('collectionFactory') + ->setReadOnly($readonlyProp && !$readonlyClass) /** @phpstan-ignore-line */ + ->setPrivate() + ->setType($collection . 'Factory'); + $construct + ->addPromotedParameter('entityFactory') + ->setReadOnly($readonlyProp && !$readonlyClass) /** @phpstan-ignore-line */ + ->setPrivate() + ->setType($entityInterface . 'Factory'); + $construct + ->addPromotedParameter('searchResultsFactory') + ->setReadOnly($readonlyProp && !$readonlyClass) /** @phpstan-ignore-line */ + ->setPrivate() + ->setType($results . 'Factory'); + } else { + $construct + ->addParameter('resource') + ->setType($resource); + $construct + ->addParameter('collectionFactory') + ->setType($collection . 'Factory'); + $construct + ->addParameter('entityFactory') + ->setType($entityInterface . 'Factory'); + $construct + ->addParameter('searchResultsFactory') + ->setType($results . 'Factory'); + } if ($withStore) { $namespace->addUse('Magento\Store\Model\StoreManagerInterface'); - $sm = $class->addProperty('storeManager') - ->setVisibility('private'); - $construct - ->addParameter('storeManager') - ->setType('\Magento\Store\Model\StoreManagerInterface'); + if (!$constructorProp) { + $sm = $class->addProperty('storeManager')->setPrivate(); + if ($typehint) { + $sm->setType('\Magento\Store\Model\StoreManagerInterface'); + } else { + $sm->addComment('@var StoreManagerInterface'); + } + } - if ($typehint) { - $sm->setType('\Magento\Store\Model\StoreManagerInterface'); + if ($constructorProp) { + $construct + ->addPromotedParameter('storeManager') + ->setReadOnly($readonlyProp && !$readonlyClass) /** @phpstan-ignore-line */ + ->setPrivate() + ->setType('\Magento\Store\Model\StoreManagerInterface'); } else { $construct - ->addComment('@param StoreManagerInterface $storeManager'); - $sm->addComment('@var StoreManagerInterface'); + ->addParameter('storeManager') + ->setType('\Magento\Store\Model\StoreManagerInterface'); + if (!$typehint) { + $construct->addComment('@param StoreManagerInterface $storeManager'); + } } } - $cp = $class->addProperty('collectionProcessor') - ->setVisibility('private'); - - $construct->addParameter('collectionProcessor') - ->setType('Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface'); + if (!$constructorProp) { + $cp = $class->addProperty('collectionProcessor') + ->setPrivate(); + if ($typehint) { + $cp->setType('\Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface'); + } else { + $cp->addComment('@var CollectionProcessorInterface'); + } + } - if ($typehint) { - $cp->setType('\Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface'); + if ($constructorProp) { + $construct->addPromotedParameter('collectionProcessor') + ->setReadOnly($readonlyProp && !$readonlyClass) /** @phpstan-ignore-line */ + ->setPrivate() + ->setType('Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface'); } else { + $construct->addParameter('collectionProcessor') + ->setType('Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface'); + } + + if (!$typehint) { $construct->addComment('@param CollectionProcessorInterface $collectionProcessor'); - $cp->addComment('@var CollectionProcessorInterface'); } - $construct->setBody('$this->resource = $resource;' . PHP_EOL - . '$this->collectionFactory = $collectionFactory;' . PHP_EOL - . '$this->entityFactory = $entityFactory;' . PHP_EOL - . '$this->searchResultsFactory = $searchResultsFactory;' . PHP_EOL - . '$this->collectionProcessor = $collectionProcessor;' - . ($withStore ? PHP_EOL . '$this->storeManager = $storeManager;' : '')); + if (!$constructorProp) { + $construct->setBody('$this->resource = $resource;' . PHP_EOL + . '$this->collectionFactory = $collectionFactory;' . PHP_EOL + . '$this->entityFactory = $entityFactory;' . PHP_EOL + . '$this->searchResultsFactory = $searchResultsFactory;' . PHP_EOL + . '$this->collectionProcessor = $collectionProcessor;' + . ($withStore ? PHP_EOL . '$this->storeManager = $storeManager;' : '')); + } $getById = $class->addMethod('getById')->setVisibility('public'); $getByIdParam = $getById->addParameter('entityId'); @@ -163,7 +233,7 @@ public function genRepository( $delete = $class->addMethod('delete')->setVisibility('public'); - $delete->addParameter('entity')->setTypeHint($entityInterface); + $delete->addParameter('entity')->setType($entityInterface); if ($typehint) { $delete->addComment('@throws CouldNotDeleteException'); @@ -207,7 +277,7 @@ public function genRepository( ->setVisibility('public'); - $getList->addParameter('criteria')->setTypeHint('\Magento\Framework\Api\SearchCriteriaInterface'); + $getList->addParameter('criteria')->setType('\Magento\Framework\Api\SearchCriteriaInterface'); if ($typehint) { $namespace->addUse('\Magento\Framework\Api\SearchCriteriaInterface'); diff --git a/src/Jeeves/Generators/Crud/Repositories/Search.php b/src/Jeeves/Generators/Crud/Repositories/Search.php index ac6200c..f9b6a20 100644 --- a/src/Jeeves/Generators/Crud/Repositories/Search.php +++ b/src/Jeeves/Generators/Crud/Repositories/Search.php @@ -13,13 +13,14 @@ public function genModelSearch( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); + $namespace = new PhpNamespace($rootNamespace . '\Model'); $namespace->addUse($interface); $namespace->addUse('\Magento\Framework\Api\SearchResults'); $class = $namespace->addClass($className); - $class->addExtend('\Magento\Framework\Api\SearchResults'); + $class->setExtends('\Magento\Framework\Api\SearchResults'); $class->setImplements([$interface]); return $namespace; diff --git a/src/Jeeves/Generators/Crud/Ui/Actions.php b/src/Jeeves/Generators/Crud/Ui/Actions.php index 5da3509..f3cd55e 100644 --- a/src/Jeeves/Generators/Crud/Ui/Actions.php +++ b/src/Jeeves/Generators/Crud/Ui/Actions.php @@ -15,7 +15,7 @@ public function getActions( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Ui\Component\Listing'); $class = $namespace->addClass($className); $class->setExtends('\Mygento\Base\Ui\Component\Listing\Actions'); diff --git a/src/Jeeves/Generators/Crud/Ui/DataProvider.php b/src/Jeeves/Generators/Crud/Ui/DataProvider.php index c45518c..89e1fd1 100644 --- a/src/Jeeves/Generators/Crud/Ui/DataProvider.php +++ b/src/Jeeves/Generators/Crud/Ui/DataProvider.php @@ -16,7 +16,7 @@ public function getProvider( string $rootNamespace, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $typehint = $this->hasTypes($phpVersion); $namespace = new PhpNamespace($rootNamespace . '\Model\\' . ucfirst($entity)); $namespace->addUse('Magento\Framework\App\Request\DataPersistorInterface'); $namespace->addUse($collectionFactory); @@ -63,14 +63,14 @@ public function getProvider( ->addComment('@param \Magento\Ui\DataProvider\Modifier\PoolInterface|null $pool'); } - $construct->addParameter('collectionFactory')->setTypeHint($collectionFactory); - $construct->addParameter('dataPersistor')->setTypeHint('\Magento\Framework\App\Request\DataPersistorInterface'); + $construct->addParameter('collectionFactory')->setType($collectionFactory); + $construct->addParameter('dataPersistor')->setType('\Magento\Framework\App\Request\DataPersistorInterface'); $construct->addParameter('name')->setType('string'); $construct->addParameter('primaryFieldName')->setType('string'); $construct->addParameter('requestFieldName')->setType('string'); - $construct->addParameter('meta')->setTypeHint('array')->setDefaultValue([]); - $construct->addParameter('data')->setTypeHint('array')->setDefaultValue([]); - $construct->addParameter('pool')->setTypeHint('\Magento\Ui\DataProvider\Modifier\PoolInterface')->setDefaultValue(null); + $construct->addParameter('meta')->setType('array')->setDefaultValue([]); + $construct->addParameter('data')->setType('array')->setDefaultValue([]); + $construct->addParameter('pool')->setType('\Magento\Ui\DataProvider\Modifier\PoolInterface')->setDefaultValue(null); $construct->setBody('parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool);' . PHP_EOL . PHP_EOL . '$this->collection = $collectionFactory->create();' . PHP_EOL diff --git a/src/Jeeves/Generators/Crud/Ui/Grid.php b/src/Jeeves/Generators/Crud/Ui/Grid.php index 29f6520..5b71a10 100644 --- a/src/Jeeves/Generators/Crud/Ui/Grid.php +++ b/src/Jeeves/Generators/Crud/Ui/Grid.php @@ -16,7 +16,8 @@ public function generateGridCollection( bool $withStore = false, string $phpVersion = PHP_VERSION ): PhpNamespace { - $typehint = version_compare($phpVersion, '7.4.0', '>='); + $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'); @@ -45,19 +46,19 @@ public function generateGridCollection( if ($withStore) { $construct->addParameter('metadataPool')->setType('\Magento\Framework\EntityManager\MetadataPool'); } - $construct->addParameter('entityFactory')->setTypeHint('\Magento\Framework\Data\Collection\EntityFactoryInterface'); - $construct->addParameter('logger')->setTypeHint('\Psr\Log\LoggerInterface'); - $construct->addParameter('fetchStrategy')->setTypeHint('\Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); - $construct->addParameter('eventManager')->setTypeHint('\Magento\Framework\Event\ManagerInterface'); - $construct->addParameter('mainTable')->setTypeHint('string'); - $construct->addParameter('eventPrefix')->setTypeHint('string'); - $construct->addParameter('eventObject')->setTypeHint('string'); - $construct->addParameter('resourceModel')->setTypeHint('string'); + $construct->addParameter('entityFactory')->setType('\Magento\Framework\Data\Collection\EntityFactoryInterface'); + $construct->addParameter('logger')->setType('\Psr\Log\LoggerInterface'); + $construct->addParameter('fetchStrategy')->setType('\Magento\Framework\Data\Collection\Db\FetchStrategyInterface'); + $construct->addParameter('eventManager')->setType('\Magento\Framework\Event\ManagerInterface'); + $construct->addParameter('mainTable')->setType('string'); + $construct->addParameter('eventPrefix')->setType('string'); + $construct->addParameter('eventObject')->setType('string'); + $construct->addParameter('resourceModel')->setType('string'); $construct->addParameter('model') - ->setTypeHint('string') + ->setType('string') ->setDefaultValue(new Literal('\Magento\Framework\View\Element\UiComponent\DataProvider\Document::class')); - $construct->addParameter('connection')->setTypeHint('\Magento\Framework\DB\Adapter\AdapterInterface')->setDefaultValue(null); - $construct->addParameter('resource')->setTypeHint('\Magento\Framework\Model\ResourceModel\Db\AbstractDb')->setDefaultValue(null); + $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'); @@ -122,7 +123,7 @@ public function generateGridCollection( ->addComment('@SuppressWarnings(PHPMD.UnusedFormalParameter)') ->setVisibility('public'); $setSearchCriteria->addParameter('searchCriteria') - ->setTypeHint('\Magento\Framework\Api\SearchCriteriaInterface') + ->setType('\Magento\Framework\Api\SearchCriteriaInterface') ->setDefaultValue(null); $setSearchCriteria->setBody('return $this;'); @@ -144,7 +145,7 @@ public function generateGridCollection( ->addComment('@return $this') ->addComment('@SuppressWarnings(PHPMD.UnusedFormalParameter)') ->setVisibility('public'); - $setItems->addParameter('items')->setTypeHint('array')->setDefaultValue(null); + $setItems->addParameter('items')->setType('array')->setDefaultValue(null); $setItems->setBody('return $this;'); return $namespace; diff --git a/src/Jeeves/Generators/Project/Node.php b/src/Jeeves/Generators/Project/Node.php deleted file mode 100644 index 871c8b7..0000000 --- a/src/Jeeves/Generators/Project/Node.php +++ /dev/null @@ -1,166 +0,0 @@ - $name, - 'private' => true, - 'version' => '1.0.0', - 'description' => '', - 'main' => 'gulpfile.js', - 'dependencies' => [ - 'font-awesome' => '^4.7.0', - 'gulp' => '4.0.0', - 'gulp-changed' => '^3.2.0', - 'gulp-cssnano' => '^2.1.3', - 'gulp-eslint' => '^5.0.0', - 'gulp-sass' => '^4.0.2', - 'gulp-scss-lint' => '^0.7.1', - 'node-normalize-scss' => '^8.0.0', - 'node-reset-scss' => '^1.0.1', - 'sassime' => '^1.1.6', - ], - 'devDependencies' => [ - 'gulp-notify' => '^3.2.0', - 'gulp-sourcemaps' => '^2.6.4', - 'guppy-pre-commit' => '^0.4.0', - ], - ], - JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES - ); - } - - public function generateJsLint() - { - return json_encode( - [ - 'env' => [ - 'node' => true, - 'browser' => true, - 'jquery' => true, - 'amd' => true, - 'prototypejs' => true, - ], - 'globals' => new \ArrayObject(), - 'parserOptions' => [ - 'ecmaVersion' => 6, - ], - 'extends' => 'eslint:recommended', - 'rules' => [ - 'indent' => ['error', 2], - 'keyword-spacing' => [ - 'error', - [ - 'before' => true, - 'after' => true, - ], - ], - 'linebreak-style' => [ - 'error', - 'unix', - ], - 'no-multiple-empty-lines' => 'error', - 'no-unused-vars' => 'warn', - 'quotes' => [ - 'error', - 'single', - ], - 'semi' => [ - 'error', - 'always', - ], - 'space-before-blocks' => [ - 'error', - 'always', - ], - ], - ], - JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES - ); - } - - public function generateGulp($name) - { - $theme_folder = '${theme_folder}'; - $scss_folder = '${scss_folder}'; - - return << 1%'] - }) -}; - - -gulp.task('scss-lint', () => { - return gulp.src([`${scss_folder}/**/*.scss`, `!${scss_folder}/vendor/**/*.scss`]) - .pipe(scsslint({ - 'maxBuffer': 307200 - })) - .pipe(scsslint.failReporter('E')); -}); -gulp.task('js-lint', () => { - return gulp.src([`${theme_folder}/**/*.js`, '!node_modules/**', `!${theme_folder}/web/js/vendor/**/*.js`, `!${theme_folder}/web/mage/**/*.js`]) - .pipe(eslint()) - .pipe(eslint.format()) - .pipe(eslint.failAfterError()); -}); - -gulp.task('lint', gulp.parallel('scss-lint', 'js-lint')); -gulp.task('pre-commit', gulp.series('lint')); - -gulp.task('scss', () => { - return gulp.src([`${scss_folder}/**/*.scss`]) - .pipe(notProduction ? sourcemaps.init() : noop()) - .pipe(sass(include_opt).on('error', sass.logError)) - .pipe(cssnano(css_options)) - .pipe(notProduction ? sourcemaps.write('.') : noop()) - .pipe(gulp.dest(css_folder)) - .pipe(notProduction ? notify({ - message: 'Styles complete', - onLast: true - }) : noop()); -}); - -gulp.task('serve', gulp.series('scss', () => { - return gulp.watch(`${scss_folder}/**/*.scss`, gulp.series('scss')); -})); - -gulp.task('build', gulp.series('scss')); -gulp.task('default', gulp.parallel('serve', 'pre-commit')); - -CONFIG; - } -} diff --git a/test/Crud/CrudV1Test.php b/test/Crud/CrudV1Test.php index dfb51f8..38af8d7 100644 --- a/test/Crud/CrudV1Test.php +++ b/test/Crud/CrudV1Test.php @@ -24,18 +24,25 @@ protected function setUp(): void $this->commandTester = new CommandTester($command); } - public function testCrudV1() + public function provider(): array { + $variants = []; foreach (self::VARIANTS as $v) { - if (version_compare(PHP_VERSION, $v, '>=')) { - $this->path = str_replace('.', '', $v) . App::DS . self::V; - $this->checkEveryThing(); + list($v1, $v2) = explode('.', $v); + if (version_compare(PHP_VERSION, $v, '>=') && version_compare(PHP_VERSION, $v1 . '.' . ($v2 + 1), '<')) { + $variants[] = [str_replace('.', '', $v) . App::DS . self::V]; } } + + return $variants; } - private function checkEveryThing() + /** + * @dataProvider provider + */ + public function testCrudV1(string $path) { + $this->path = $path; $this->commandTester->execute([ '--config_file' => '.jeeves.phpunit_' . self::V . '.yaml', '--path' => self::GEN_PATH . $this->path, @@ -77,26 +84,24 @@ private function checkInterfaces() private function checkModels() { - if (\PHP_VERSION_ID >= 70400) { - $this->checkFile('Model/Columns.php'); - $this->checkFile('Model/ResourceModel/Columns.php'); - $this->checkFile('Model/ResourceModel/Columns/Collection.php'); + $this->checkFile('Model/Columns.php'); + $this->checkFile('Model/ResourceModel/Columns.php'); + $this->checkFile('Model/ResourceModel/Columns/Collection.php'); - $this->checkFile('Model/CartItem.php'); - $this->checkFile('Model/ResourceModel/CartItem.php'); - $this->checkFile('Model/ResourceModel/CartItem/Collection.php'); + $this->checkFile('Model/CartItem.php'); + $this->checkFile('Model/ResourceModel/CartItem.php'); + $this->checkFile('Model/ResourceModel/CartItem/Collection.php'); - $this->checkFile('Model/Poster.php'); - $this->checkFile('Model/ResourceModel/Poster.php'); - $this->checkFile('Model/ResourceModel/Poster/Collection.php'); + $this->checkFile('Model/Poster.php'); + $this->checkFile('Model/ResourceModel/Poster.php'); + $this->checkFile('Model/ResourceModel/Poster/Collection.php'); - $this->checkFile('Model/Card.php'); - $this->checkFile('Model/ResourceModel/Card.php'); - $this->checkFile('Model/ResourceModel/Card/Collection.php'); + $this->checkFile('Model/Card.php'); + $this->checkFile('Model/ResourceModel/Card.php'); + $this->checkFile('Model/ResourceModel/Card/Collection.php'); - $this->checkFile('Model/ResourceModel/Card/Relation/Store/ReadHandler.php'); - $this->checkFile('Model/ResourceModel/Card/Relation/Store/SaveHandler.php'); - } + $this->checkFile('Model/ResourceModel/Card/Relation/Store/ReadHandler.php'); + $this->checkFile('Model/ResourceModel/Card/Relation/Store/SaveHandler.php'); $this->checkFile('Model/Obsolete.php'); $this->checkFile('Model/ResourceModel/Obsolete.php'); @@ -105,26 +110,22 @@ private function checkModels() private function checkRepository() { - if (\PHP_VERSION_ID >= 70400) { - $this->checkFile('Model/ColumnsRepository.php'); - $this->checkFile('Model/CartItemRepository.php'); - $this->checkFile('Model/ObsoleteRepository.php'); - $this->checkFile('Model/PosterRepository.php'); - $this->checkFile('Model/CardRepository.php'); - - $this->checkFile('Model/SearchCriteria/CardStoreFilter.php'); - } + $this->checkFile('Model/ColumnsRepository.php'); + $this->checkFile('Model/CartItemRepository.php'); + $this->checkFile('Model/ObsoleteRepository.php'); + $this->checkFile('Model/PosterRepository.php'); + $this->checkFile('Model/CardRepository.php'); + + $this->checkFile('Model/SearchCriteria/CardStoreFilter.php'); } private function checkSearchResults() { - if (\PHP_VERSION_ID >= 70400) { - $this->checkFile('Model/ColumnsSearchResults.php'); - $this->checkFile('Model/CartItemSearchResults.php'); - $this->checkFile('Model/ObsoleteSearchResults.php'); - $this->checkFile('Model/PosterSearchResults.php'); - $this->checkFile('Model/CardSearchResults.php'); - } + $this->checkFile('Model/ColumnsSearchResults.php'); + $this->checkFile('Model/CartItemSearchResults.php'); + $this->checkFile('Model/ObsoleteSearchResults.php'); + $this->checkFile('Model/PosterSearchResults.php'); + $this->checkFile('Model/CardSearchResults.php'); } private function checkGui() @@ -140,43 +141,41 @@ private function checkGui() private function checkControllers() { - if (\PHP_VERSION_ID >= 70400) { - $this->checkFile('Controller/Adminhtml/Columns.php'); - $this->checkFile('Controller/Adminhtml/Columns/Index.php'); - $this->checkFile('Controller/Adminhtml/Columns/Delete.php'); - $this->checkFile('Controller/Adminhtml/Columns/Edit.php'); - $this->checkFile('Controller/Adminhtml/Columns/InlineEdit.php'); - $this->checkFile('Controller/Adminhtml/Columns/MassDelete.php'); - $this->checkFile('Controller/Adminhtml/Columns/NewAction.php'); - $this->checkFile('Controller/Adminhtml/Columns/Save.php'); - - $this->checkFile('Controller/Adminhtml/CartItem.php'); - $this->checkFile('Controller/Adminhtml/CartItem/Index.php'); - $this->checkFile('Controller/Adminhtml/CartItem/Delete.php'); - $this->checkFile('Controller/Adminhtml/CartItem/Edit.php'); - $this->checkFile('Controller/Adminhtml/CartItem/InlineEdit.php'); - $this->checkFile('Controller/Adminhtml/CartItem/MassDelete.php'); - $this->checkFile('Controller/Adminhtml/CartItem/NewAction.php'); - $this->checkFile('Controller/Adminhtml/CartItem/Save.php'); - - $this->checkFile('Controller/Adminhtml/Card.php'); - $this->checkFile('Controller/Adminhtml/Card/Index.php'); - $this->checkFile('Controller/Adminhtml/Card/Delete.php'); - $this->checkFile('Controller/Adminhtml/Card/Edit.php'); - $this->checkFile('Controller/Adminhtml/Card/InlineEdit.php'); - $this->checkFile('Controller/Adminhtml/Card/MassDelete.php'); - $this->checkFile('Controller/Adminhtml/Card/NewAction.php'); - $this->checkFile('Controller/Adminhtml/Card/Save.php'); - - $this->checkFile('Controller/Adminhtml/Poster.php'); - $this->checkFile('Controller/Adminhtml/Poster/Index.php'); - $this->checkNoFile('Controller/Adminhtml/Poster/Delete.php'); - $this->checkNoFile('Controller/Adminhtml/Poster/Edit.php'); - $this->checkNoFile('Controller/Adminhtml/Poster/InlineEdit.php'); - $this->checkNoFile('Controller/Adminhtml/Poster/MassDelete.php'); - $this->checkNoFile('Controller/Adminhtml/Poster/NewAction.php'); - $this->checkNoFile('Controller/Adminhtml/Poster/Save.php'); - } + $this->checkFile('Controller/Adminhtml/Columns.php'); + $this->checkFile('Controller/Adminhtml/Columns/Index.php'); + $this->checkFile('Controller/Adminhtml/Columns/Delete.php'); + $this->checkFile('Controller/Adminhtml/Columns/Edit.php'); + $this->checkFile('Controller/Adminhtml/Columns/InlineEdit.php'); + $this->checkFile('Controller/Adminhtml/Columns/MassDelete.php'); + $this->checkFile('Controller/Adminhtml/Columns/NewAction.php'); + $this->checkFile('Controller/Adminhtml/Columns/Save.php'); + + $this->checkFile('Controller/Adminhtml/CartItem.php'); + $this->checkFile('Controller/Adminhtml/CartItem/Index.php'); + $this->checkFile('Controller/Adminhtml/CartItem/Delete.php'); + $this->checkFile('Controller/Adminhtml/CartItem/Edit.php'); + $this->checkFile('Controller/Adminhtml/CartItem/InlineEdit.php'); + $this->checkFile('Controller/Adminhtml/CartItem/MassDelete.php'); + $this->checkFile('Controller/Adminhtml/CartItem/NewAction.php'); + $this->checkFile('Controller/Adminhtml/CartItem/Save.php'); + + $this->checkFile('Controller/Adminhtml/Card.php'); + $this->checkFile('Controller/Adminhtml/Card/Index.php'); + $this->checkFile('Controller/Adminhtml/Card/Delete.php'); + $this->checkFile('Controller/Adminhtml/Card/Edit.php'); + $this->checkFile('Controller/Adminhtml/Card/InlineEdit.php'); + $this->checkFile('Controller/Adminhtml/Card/MassDelete.php'); + $this->checkFile('Controller/Adminhtml/Card/NewAction.php'); + $this->checkFile('Controller/Adminhtml/Card/Save.php'); + + $this->checkFile('Controller/Adminhtml/Poster.php'); + $this->checkFile('Controller/Adminhtml/Poster/Index.php'); + $this->checkNoFile('Controller/Adminhtml/Poster/Delete.php'); + $this->checkNoFile('Controller/Adminhtml/Poster/Edit.php'); + $this->checkNoFile('Controller/Adminhtml/Poster/InlineEdit.php'); + $this->checkNoFile('Controller/Adminhtml/Poster/MassDelete.php'); + $this->checkNoFile('Controller/Adminhtml/Poster/NewAction.php'); + $this->checkNoFile('Controller/Adminhtml/Poster/Save.php'); $this->checkFile('Controller/Adminhtml/Obsolete.php'); $this->checkFile('Controller/Adminhtml/Obsolete/Index.php'); @@ -213,35 +212,31 @@ private function checkLayout() private function checkUi() { - if (\PHP_VERSION_ID >= 70400) { - $this->checkFile('Ui/Component/Listing/ColumnsActions.php'); - $this->checkFile('Model/Columns/DataProvider.php'); - $this->checkFile('Model/ResourceModel/Columns/Grid/Collection.php'); - } + $this->checkFile('Ui/Component/Listing/ColumnsActions.php'); + $this->checkFile('Model/Columns/DataProvider.php'); + $this->checkFile('Model/ResourceModel/Columns/Grid/Collection.php'); + $this->checkXml('view/adminhtml/ui_component/sample_module_columns_listing.xml'); $this->checkXml('view/adminhtml/ui_component/sample_module_columns_edit.xml'); - if (\PHP_VERSION_ID >= 70400) { - $this->checkFile('Ui/Component/Listing/CartItemActions.php'); - $this->checkFile('Model/CartItem/DataProvider.php'); - $this->checkFile('Model/ResourceModel/CartItem/Grid/Collection.php'); - } + $this->checkFile('Ui/Component/Listing/CartItemActions.php'); + $this->checkFile('Model/CartItem/DataProvider.php'); + $this->checkFile('Model/ResourceModel/CartItem/Grid/Collection.php'); + $this->checkXml('view/adminhtml/ui_component/sample_module_cartitem_listing.xml'); $this->checkXml('view/adminhtml/ui_component/sample_module_cartitem_edit.xml'); - if (\PHP_VERSION_ID >= 70400) { - $this->checkFile('Ui/Component/Listing/CardActions.php'); - $this->checkFile('Model/Card/DataProvider.php'); - $this->checkFile('Model/ResourceModel/Card/Grid/Collection.php'); - } + $this->checkFile('Ui/Component/Listing/CardActions.php'); + $this->checkFile('Model/Card/DataProvider.php'); + $this->checkFile('Model/ResourceModel/Card/Grid/Collection.php'); + $this->checkXml('view/adminhtml/ui_component/sample_module_card_listing.xml'); $this->checkXml('view/adminhtml/ui_component/sample_module_card_edit.xml'); - if (\PHP_VERSION_ID >= 70400) { - $this->checkNoFile('Ui/Component/Listing/PosterActions.php'); - $this->checkFile('Model/Poster/DataProvider.php'); - $this->checkFile('Model/ResourceModel/Poster/Grid/Collection.php'); - } + $this->checkNoFile('Ui/Component/Listing/PosterActions.php'); + $this->checkFile('Model/Poster/DataProvider.php'); + $this->checkFile('Model/ResourceModel/Poster/Grid/Collection.php'); + $this->checkXml('view/adminhtml/ui_component/sample_module_poster_listing.xml'); $this->checkNoFile('view/adminhtml/ui_component/sample_module_poster_edit.xml'); diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card.php index efb9030..9085338 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card.php @@ -15,14 +15,11 @@ abstract class Card extends Action */ public const ADMIN_RESOURCE = 'Mygento_SampleModule::card'; - protected Registry $coreRegistry; - protected CardRepositoryInterface $repository; - - public function __construct(CardRepositoryInterface $repository, Registry $coreRegistry, Action\Context $context) - { + public function __construct( + protected readonly CardRepositoryInterface $repository, + protected readonly Registry $coreRegistry, + Action\Context $context, + ) { parent::__construct($context); - - $this->repository = $repository; - $this->coreRegistry = $coreRegistry; } } diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/Edit.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/Edit.php index dd753fd..6cac1d4 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/Edit.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/Edit.php @@ -13,20 +13,14 @@ class Edit extends Card { - private CardInterfaceFactory $entityFactory; - private PageFactory $resultPageFactory; - public function __construct( - CardInterfaceFactory $entityFactory, - PageFactory $resultPageFactory, + private readonly CardInterfaceFactory $entityFactory, + private readonly PageFactory $resultPageFactory, CardRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->entityFactory = $entityFactory; - $this->resultPageFactory = $resultPageFactory; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/Index.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/Index.php index 9b183ad..e99cbac 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/Index.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/Index.php @@ -12,20 +12,14 @@ class Index extends Card { - private PageFactory $resultPageFactory; - private DataPersistorInterface $dataPersistor; - public function __construct( - PageFactory $resultPageFactory, - DataPersistorInterface $dataPersistor, + private readonly PageFactory $resultPageFactory, + private readonly DataPersistorInterface $dataPersistor, CardRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->resultPageFactory = $resultPageFactory; - $this->dataPersistor = $dataPersistor; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/InlineEdit.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/InlineEdit.php index 6eb28c4..2ee0199 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/InlineEdit.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/InlineEdit.php @@ -12,17 +12,13 @@ class InlineEdit extends Card { - private JsonFactory $jsonFactory; - public function __construct( - JsonFactory $jsonFactory, + private readonly JsonFactory $jsonFactory, CardRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->jsonFactory = $jsonFactory; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/MassDelete.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/MassDelete.php index be6c505..39de5c0 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/MassDelete.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/MassDelete.php @@ -13,18 +13,13 @@ class MassDelete extends Card { - private Filter $filter; - private CollectionFactory $collectionFactory; - public function __construct( - CollectionFactory $collectionFactory, - Filter $filter, + private readonly CollectionFactory $collectionFactory, + private readonly Filter $filter, CardRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { - $this->filter = $filter; - $this->collectionFactory = $collectionFactory; parent::__construct($repository, $coreRegistry, $context); } diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/NewAction.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/NewAction.php index 7a7c399..80db90f 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/NewAction.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/NewAction.php @@ -11,17 +11,13 @@ class NewAction extends Card { - private ForwardFactory $resultForwardFactory; - public function __construct( - ForwardFactory $resultForwardFactory, + private readonly ForwardFactory $resultForwardFactory, CardRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->resultForwardFactory = $resultForwardFactory; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/Save.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/Save.php index 925be37..e8da5c7 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/Save.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Card/Save.php @@ -14,20 +14,14 @@ class Save extends Card { - private DataPersistorInterface $dataPersistor; - private CardInterfaceFactory $entityFactory; - public function __construct( - DataPersistorInterface $dataPersistor, - CardInterfaceFactory $entityFactory, + private readonly DataPersistorInterface $dataPersistor, + private readonly CardInterfaceFactory $entityFactory, CardRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->dataPersistor = $dataPersistor; - $this->entityFactory = $entityFactory; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem.php index 9bdb650..7ee7bb8 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem.php @@ -15,14 +15,11 @@ abstract class CartItem extends Action */ public const ADMIN_RESOURCE = 'Mygento_SampleModule::cartitem'; - protected Registry $coreRegistry; - protected CartItemRepositoryInterface $repository; - - public function __construct(CartItemRepositoryInterface $repository, Registry $coreRegistry, Action\Context $context) - { + public function __construct( + protected readonly CartItemRepositoryInterface $repository, + protected readonly Registry $coreRegistry, + Action\Context $context, + ) { parent::__construct($context); - - $this->repository = $repository; - $this->coreRegistry = $coreRegistry; } } diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/Edit.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/Edit.php index 5f9951f..b178abf 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/Edit.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/Edit.php @@ -13,20 +13,14 @@ class Edit extends CartItem { - private CartItemInterfaceFactory $entityFactory; - private PageFactory $resultPageFactory; - public function __construct( - CartItemInterfaceFactory $entityFactory, - PageFactory $resultPageFactory, + private readonly CartItemInterfaceFactory $entityFactory, + private readonly PageFactory $resultPageFactory, CartItemRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->entityFactory = $entityFactory; - $this->resultPageFactory = $resultPageFactory; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/Index.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/Index.php index 3d64e74..ab659aa 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/Index.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/Index.php @@ -12,20 +12,14 @@ class Index extends CartItem { - private PageFactory $resultPageFactory; - private DataPersistorInterface $dataPersistor; - public function __construct( - PageFactory $resultPageFactory, - DataPersistorInterface $dataPersistor, + private readonly PageFactory $resultPageFactory, + private readonly DataPersistorInterface $dataPersistor, CartItemRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->resultPageFactory = $resultPageFactory; - $this->dataPersistor = $dataPersistor; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/InlineEdit.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/InlineEdit.php index 46ea5da..059c13a 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/InlineEdit.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/InlineEdit.php @@ -12,17 +12,13 @@ class InlineEdit extends CartItem { - private JsonFactory $jsonFactory; - public function __construct( - JsonFactory $jsonFactory, + private readonly JsonFactory $jsonFactory, CartItemRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->jsonFactory = $jsonFactory; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/MassDelete.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/MassDelete.php index ae7b8af..87ac680 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/MassDelete.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/MassDelete.php @@ -13,18 +13,13 @@ class MassDelete extends CartItem { - private Filter $filter; - private CollectionFactory $collectionFactory; - public function __construct( - CollectionFactory $collectionFactory, - Filter $filter, + private readonly CollectionFactory $collectionFactory, + private readonly Filter $filter, CartItemRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { - $this->filter = $filter; - $this->collectionFactory = $collectionFactory; parent::__construct($repository, $coreRegistry, $context); } diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/NewAction.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/NewAction.php index 7c9996f..617be48 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/NewAction.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/NewAction.php @@ -11,17 +11,13 @@ class NewAction extends CartItem { - private ForwardFactory $resultForwardFactory; - public function __construct( - ForwardFactory $resultForwardFactory, + private readonly ForwardFactory $resultForwardFactory, CartItemRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->resultForwardFactory = $resultForwardFactory; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/Save.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/Save.php index f3ba568..1576426 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/Save.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/CartItem/Save.php @@ -14,20 +14,14 @@ class Save extends CartItem { - private DataPersistorInterface $dataPersistor; - private CartItemInterfaceFactory $entityFactory; - public function __construct( - DataPersistorInterface $dataPersistor, - CartItemInterfaceFactory $entityFactory, + private readonly DataPersistorInterface $dataPersistor, + private readonly CartItemInterfaceFactory $entityFactory, CartItemRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->dataPersistor = $dataPersistor; - $this->entityFactory = $entityFactory; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns.php index a518829..063a1e6 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns.php @@ -15,14 +15,11 @@ abstract class Columns extends Action */ public const ADMIN_RESOURCE = 'Mygento_SampleModule::columns'; - protected Registry $coreRegistry; - protected ColumnsRepositoryInterface $repository; - - public function __construct(ColumnsRepositoryInterface $repository, Registry $coreRegistry, Action\Context $context) - { + public function __construct( + protected readonly ColumnsRepositoryInterface $repository, + protected readonly Registry $coreRegistry, + Action\Context $context, + ) { parent::__construct($context); - - $this->repository = $repository; - $this->coreRegistry = $coreRegistry; } } diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/Edit.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/Edit.php index 2a87f61..d87ad2a 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/Edit.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/Edit.php @@ -13,20 +13,14 @@ class Edit extends Columns { - private ColumnsInterfaceFactory $entityFactory; - private PageFactory $resultPageFactory; - public function __construct( - ColumnsInterfaceFactory $entityFactory, - PageFactory $resultPageFactory, + private readonly ColumnsInterfaceFactory $entityFactory, + private readonly PageFactory $resultPageFactory, ColumnsRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->entityFactory = $entityFactory; - $this->resultPageFactory = $resultPageFactory; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/Index.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/Index.php index c32da73..693c393 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/Index.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/Index.php @@ -12,20 +12,14 @@ class Index extends Columns { - private PageFactory $resultPageFactory; - private DataPersistorInterface $dataPersistor; - public function __construct( - PageFactory $resultPageFactory, - DataPersistorInterface $dataPersistor, + private readonly PageFactory $resultPageFactory, + private readonly DataPersistorInterface $dataPersistor, ColumnsRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->resultPageFactory = $resultPageFactory; - $this->dataPersistor = $dataPersistor; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/InlineEdit.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/InlineEdit.php index 5f4b437..d38fd2d 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/InlineEdit.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/InlineEdit.php @@ -12,17 +12,13 @@ class InlineEdit extends Columns { - private JsonFactory $jsonFactory; - public function __construct( - JsonFactory $jsonFactory, + private readonly JsonFactory $jsonFactory, ColumnsRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->jsonFactory = $jsonFactory; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/MassDelete.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/MassDelete.php index 13d7a09..838c543 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/MassDelete.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/MassDelete.php @@ -13,18 +13,13 @@ class MassDelete extends Columns { - private Filter $filter; - private CollectionFactory $collectionFactory; - public function __construct( - CollectionFactory $collectionFactory, - Filter $filter, + private readonly CollectionFactory $collectionFactory, + private readonly Filter $filter, ColumnsRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { - $this->filter = $filter; - $this->collectionFactory = $collectionFactory; parent::__construct($repository, $coreRegistry, $context); } diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/NewAction.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/NewAction.php index 80cc1e2..5ff63b5 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/NewAction.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/NewAction.php @@ -11,17 +11,13 @@ class NewAction extends Columns { - private ForwardFactory $resultForwardFactory; - public function __construct( - ForwardFactory $resultForwardFactory, + private readonly ForwardFactory $resultForwardFactory, ColumnsRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->resultForwardFactory = $resultForwardFactory; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/Save.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/Save.php index dff1bcf..73c4248 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/Save.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Columns/Save.php @@ -14,20 +14,14 @@ class Save extends Columns { - private DataPersistorInterface $dataPersistor; - private ColumnsInterfaceFactory $entityFactory; - public function __construct( - DataPersistorInterface $dataPersistor, - ColumnsInterfaceFactory $entityFactory, + private readonly DataPersistorInterface $dataPersistor, + private readonly ColumnsInterfaceFactory $entityFactory, ColumnsRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->dataPersistor = $dataPersistor; - $this->entityFactory = $entityFactory; } /** diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Poster.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Poster.php index 7c93781..5507757 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Poster.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Poster.php @@ -15,14 +15,11 @@ abstract class Poster extends Action */ public const ADMIN_RESOURCE = 'Mygento_SampleModule::poster'; - protected Registry $coreRegistry; - protected PosterRepositoryInterface $repository; - - public function __construct(PosterRepositoryInterface $repository, Registry $coreRegistry, Action\Context $context) - { + public function __construct( + protected readonly PosterRepositoryInterface $repository, + protected readonly Registry $coreRegistry, + Action\Context $context, + ) { parent::__construct($context); - - $this->repository = $repository; - $this->coreRegistry = $coreRegistry; } } diff --git a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Poster/Index.php b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Poster/Index.php index 0c8b2ec..c28ca72 100644 --- a/test/Expectations/Crud/81/v1/Controller/Adminhtml/Poster/Index.php +++ b/test/Expectations/Crud/81/v1/Controller/Adminhtml/Poster/Index.php @@ -12,20 +12,14 @@ class Index extends Poster { - private PageFactory $resultPageFactory; - private DataPersistorInterface $dataPersistor; - public function __construct( - PageFactory $resultPageFactory, - DataPersistorInterface $dataPersistor, + private readonly PageFactory $resultPageFactory, + private readonly DataPersistorInterface $dataPersistor, PosterRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->resultPageFactory = $resultPageFactory; - $this->dataPersistor = $dataPersistor; } /** diff --git a/test/Expectations/Crud/81/v1/Model/CardRepository.php b/test/Expectations/Crud/81/v1/Model/CardRepository.php index 27a6e0f..41d04d3 100644 --- a/test/Expectations/Crud/81/v1/Model/CardRepository.php +++ b/test/Expectations/Crud/81/v1/Model/CardRepository.php @@ -20,27 +20,14 @@ */ class CardRepository implements CardRepositoryInterface { - private ResourceModel\Card $resource; - private CollectionFactory $collectionFactory; - private CardInterfaceFactory $entityFactory; - private CardSearchResultsInterfaceFactory $searchResultsFactory; - private StoreManagerInterface $storeManager; - private CollectionProcessorInterface $collectionProcessor; - public function __construct( - ResourceModel\Card $resource, - CollectionFactory $collectionFactory, - CardInterfaceFactory $entityFactory, - CardSearchResultsInterfaceFactory $searchResultsFactory, - StoreManagerInterface $storeManager, - CollectionProcessorInterface $collectionProcessor + private readonly ResourceModel\Card $resource, + private readonly CollectionFactory $collectionFactory, + private readonly CardInterfaceFactory $entityFactory, + private readonly CardSearchResultsInterfaceFactory $searchResultsFactory, + private readonly StoreManagerInterface $storeManager, + private readonly CollectionProcessorInterface $collectionProcessor, ) { - $this->resource = $resource; - $this->collectionFactory = $collectionFactory; - $this->entityFactory = $entityFactory; - $this->searchResultsFactory = $searchResultsFactory; - $this->collectionProcessor = $collectionProcessor; - $this->storeManager = $storeManager; } /** diff --git a/test/Expectations/Crud/81/v1/Model/CartItemRepository.php b/test/Expectations/Crud/81/v1/Model/CartItemRepository.php index 4783232..80ece61 100644 --- a/test/Expectations/Crud/81/v1/Model/CartItemRepository.php +++ b/test/Expectations/Crud/81/v1/Model/CartItemRepository.php @@ -19,24 +19,13 @@ */ class CartItemRepository implements CartItemRepositoryInterface { - private ResourceModel\CartItem $resource; - private CollectionFactory $collectionFactory; - private CartItemInterfaceFactory $entityFactory; - private CartItemSearchResultsInterfaceFactory $searchResultsFactory; - private CollectionProcessorInterface $collectionProcessor; - public function __construct( - ResourceModel\CartItem $resource, - CollectionFactory $collectionFactory, - CartItemInterfaceFactory $entityFactory, - CartItemSearchResultsInterfaceFactory $searchResultsFactory, - CollectionProcessorInterface $collectionProcessor + private readonly ResourceModel\CartItem $resource, + private readonly CollectionFactory $collectionFactory, + private readonly CartItemInterfaceFactory $entityFactory, + private readonly CartItemSearchResultsInterfaceFactory $searchResultsFactory, + private readonly CollectionProcessorInterface $collectionProcessor, ) { - $this->resource = $resource; - $this->collectionFactory = $collectionFactory; - $this->entityFactory = $entityFactory; - $this->searchResultsFactory = $searchResultsFactory; - $this->collectionProcessor = $collectionProcessor; } /** diff --git a/test/Expectations/Crud/81/v1/Model/ColumnsRepository.php b/test/Expectations/Crud/81/v1/Model/ColumnsRepository.php index 0ed79c4..b6af139 100644 --- a/test/Expectations/Crud/81/v1/Model/ColumnsRepository.php +++ b/test/Expectations/Crud/81/v1/Model/ColumnsRepository.php @@ -19,24 +19,13 @@ */ class ColumnsRepository implements ColumnsRepositoryInterface { - private ResourceModel\Columns $resource; - private CollectionFactory $collectionFactory; - private ColumnsInterfaceFactory $entityFactory; - private ColumnsSearchResultsInterfaceFactory $searchResultsFactory; - private CollectionProcessorInterface $collectionProcessor; - public function __construct( - ResourceModel\Columns $resource, - CollectionFactory $collectionFactory, - ColumnsInterfaceFactory $entityFactory, - ColumnsSearchResultsInterfaceFactory $searchResultsFactory, - CollectionProcessorInterface $collectionProcessor + private readonly ResourceModel\Columns $resource, + private readonly CollectionFactory $collectionFactory, + private readonly ColumnsInterfaceFactory $entityFactory, + private readonly ColumnsSearchResultsInterfaceFactory $searchResultsFactory, + private readonly CollectionProcessorInterface $collectionProcessor, ) { - $this->resource = $resource; - $this->collectionFactory = $collectionFactory; - $this->entityFactory = $entityFactory; - $this->searchResultsFactory = $searchResultsFactory; - $this->collectionProcessor = $collectionProcessor; } /** diff --git a/test/Expectations/Crud/81/v1/Model/PosterRepository.php b/test/Expectations/Crud/81/v1/Model/PosterRepository.php index 1ab97b4..e243ef5 100644 --- a/test/Expectations/Crud/81/v1/Model/PosterRepository.php +++ b/test/Expectations/Crud/81/v1/Model/PosterRepository.php @@ -19,24 +19,13 @@ */ class PosterRepository implements PosterRepositoryInterface { - private ResourceModel\Poster $resource; - private CollectionFactory $collectionFactory; - private PosterInterfaceFactory $entityFactory; - private PosterSearchResultsInterfaceFactory $searchResultsFactory; - private CollectionProcessorInterface $collectionProcessor; - public function __construct( - ResourceModel\Poster $resource, - CollectionFactory $collectionFactory, - PosterInterfaceFactory $entityFactory, - PosterSearchResultsInterfaceFactory $searchResultsFactory, - CollectionProcessorInterface $collectionProcessor + private readonly ResourceModel\Poster $resource, + private readonly CollectionFactory $collectionFactory, + private readonly PosterInterfaceFactory $entityFactory, + private readonly PosterSearchResultsInterfaceFactory $searchResultsFactory, + private readonly CollectionProcessorInterface $collectionProcessor, ) { - $this->resource = $resource; - $this->collectionFactory = $collectionFactory; - $this->entityFactory = $entityFactory; - $this->searchResultsFactory = $searchResultsFactory; - $this->collectionProcessor = $collectionProcessor; } /** diff --git a/test/Expectations/Crud/81/v1/Model/ResourceModel/Card.php b/test/Expectations/Crud/81/v1/Model/ResourceModel/Card.php index b55c93f..adca5d1 100644 --- a/test/Expectations/Crud/81/v1/Model/ResourceModel/Card.php +++ b/test/Expectations/Crud/81/v1/Model/ResourceModel/Card.php @@ -14,18 +14,13 @@ class Card extends AbstractDb public const TABLE_NAME = 'mygento_sample_module_card'; public const TABLE_PRIMARY_KEY = 'card_id'; - private EntityManager $entityManager; - private MetadataPool $metadataPool; - public function __construct( - EntityManager $entityManager, - MetadataPool $metadataPool, + private readonly EntityManager $entityManager, + private readonly MetadataPool $metadataPool, Context $context, - string $connectionName = null + string $connectionName = null, ) { parent::__construct($context, $connectionName); - $this->entityManager = $entityManager; - $this->metadataPool = $metadataPool; } /** diff --git a/test/Expectations/Crud/81/v1/Model/ResourceModel/Card/Collection.php b/test/Expectations/Crud/81/v1/Model/ResourceModel/Card/Collection.php index e8ac53a..79b083e 100644 --- a/test/Expectations/Crud/81/v1/Model/ResourceModel/Card/Collection.php +++ b/test/Expectations/Crud/81/v1/Model/ResourceModel/Card/Collection.php @@ -19,19 +19,17 @@ class Collection extends AbstractCollection /** @var string */ protected $_idFieldName = CardResource::TABLE_PRIMARY_KEY; - private MetadataPool $metadataPool; - /** * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - MetadataPool $metadataPool, + private readonly MetadataPool $metadataPool, EntityFactoryInterface $entityFactory, LoggerInterface $logger, FetchStrategyInterface $fetchStrategy, ManagerInterface $eventManager, AdapterInterface $connection = null, - AbstractDb $resource = null + AbstractDb $resource = null, ) { parent::__construct( $entityFactory, @@ -41,7 +39,6 @@ public function __construct( $connection, $resource ); - $this->metadataPool = $metadataPool; } /** diff --git a/test/Expectations/Crud/81/v1/Model/ResourceModel/Card/Relation/Store/ReadHandler.php b/test/Expectations/Crud/81/v1/Model/ResourceModel/Card/Relation/Store/ReadHandler.php index 24c2313..a884a57 100644 --- a/test/Expectations/Crud/81/v1/Model/ResourceModel/Card/Relation/Store/ReadHandler.php +++ b/test/Expectations/Crud/81/v1/Model/ResourceModel/Card/Relation/Store/ReadHandler.php @@ -8,11 +8,8 @@ class ReadHandler implements ExtensionInterface { - private Card $resource; - - public function __construct(Card $resource) + public function __construct(private readonly Card $resource) { - $this->resource = $resource; } /** diff --git a/test/Expectations/Crud/81/v1/Model/ResourceModel/Card/Relation/Store/SaveHandler.php b/test/Expectations/Crud/81/v1/Model/ResourceModel/Card/Relation/Store/SaveHandler.php index 3a2e5be..369b40a 100644 --- a/test/Expectations/Crud/81/v1/Model/ResourceModel/Card/Relation/Store/SaveHandler.php +++ b/test/Expectations/Crud/81/v1/Model/ResourceModel/Card/Relation/Store/SaveHandler.php @@ -9,13 +9,10 @@ class SaveHandler implements ExtensionInterface { - private Card $resource; - private MetadataPool $metadataPool; - - public function __construct(Card $resource, MetadataPool $metadataPool) - { - $this->resource = $resource; - $this->metadataPool = $metadataPool; + public function __construct( + private readonly Card $resource, + private readonly MetadataPool $metadataPool, + ) { } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card.php index efb9030..9085338 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card.php @@ -15,14 +15,11 @@ abstract class Card extends Action */ public const ADMIN_RESOURCE = 'Mygento_SampleModule::card'; - protected Registry $coreRegistry; - protected CardRepositoryInterface $repository; - - public function __construct(CardRepositoryInterface $repository, Registry $coreRegistry, Action\Context $context) - { + public function __construct( + protected readonly CardRepositoryInterface $repository, + protected readonly Registry $coreRegistry, + Action\Context $context, + ) { parent::__construct($context); - - $this->repository = $repository; - $this->coreRegistry = $coreRegistry; } } diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/Edit.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/Edit.php index dd753fd..6cac1d4 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/Edit.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/Edit.php @@ -13,20 +13,14 @@ class Edit extends Card { - private CardInterfaceFactory $entityFactory; - private PageFactory $resultPageFactory; - public function __construct( - CardInterfaceFactory $entityFactory, - PageFactory $resultPageFactory, + private readonly CardInterfaceFactory $entityFactory, + private readonly PageFactory $resultPageFactory, CardRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->entityFactory = $entityFactory; - $this->resultPageFactory = $resultPageFactory; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/Index.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/Index.php index 9b183ad..e99cbac 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/Index.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/Index.php @@ -12,20 +12,14 @@ class Index extends Card { - private PageFactory $resultPageFactory; - private DataPersistorInterface $dataPersistor; - public function __construct( - PageFactory $resultPageFactory, - DataPersistorInterface $dataPersistor, + private readonly PageFactory $resultPageFactory, + private readonly DataPersistorInterface $dataPersistor, CardRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->resultPageFactory = $resultPageFactory; - $this->dataPersistor = $dataPersistor; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/InlineEdit.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/InlineEdit.php index 6eb28c4..2ee0199 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/InlineEdit.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/InlineEdit.php @@ -12,17 +12,13 @@ class InlineEdit extends Card { - private JsonFactory $jsonFactory; - public function __construct( - JsonFactory $jsonFactory, + private readonly JsonFactory $jsonFactory, CardRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->jsonFactory = $jsonFactory; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/MassDelete.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/MassDelete.php index be6c505..39de5c0 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/MassDelete.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/MassDelete.php @@ -13,18 +13,13 @@ class MassDelete extends Card { - private Filter $filter; - private CollectionFactory $collectionFactory; - public function __construct( - CollectionFactory $collectionFactory, - Filter $filter, + private readonly CollectionFactory $collectionFactory, + private readonly Filter $filter, CardRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { - $this->filter = $filter; - $this->collectionFactory = $collectionFactory; parent::__construct($repository, $coreRegistry, $context); } diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/NewAction.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/NewAction.php index 7a7c399..80db90f 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/NewAction.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/NewAction.php @@ -11,17 +11,13 @@ class NewAction extends Card { - private ForwardFactory $resultForwardFactory; - public function __construct( - ForwardFactory $resultForwardFactory, + private readonly ForwardFactory $resultForwardFactory, CardRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->resultForwardFactory = $resultForwardFactory; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/Save.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/Save.php index 925be37..e8da5c7 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/Save.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Card/Save.php @@ -14,20 +14,14 @@ class Save extends Card { - private DataPersistorInterface $dataPersistor; - private CardInterfaceFactory $entityFactory; - public function __construct( - DataPersistorInterface $dataPersistor, - CardInterfaceFactory $entityFactory, + private readonly DataPersistorInterface $dataPersistor, + private readonly CardInterfaceFactory $entityFactory, CardRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->dataPersistor = $dataPersistor; - $this->entityFactory = $entityFactory; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem.php index 9bdb650..7ee7bb8 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem.php @@ -15,14 +15,11 @@ abstract class CartItem extends Action */ public const ADMIN_RESOURCE = 'Mygento_SampleModule::cartitem'; - protected Registry $coreRegistry; - protected CartItemRepositoryInterface $repository; - - public function __construct(CartItemRepositoryInterface $repository, Registry $coreRegistry, Action\Context $context) - { + public function __construct( + protected readonly CartItemRepositoryInterface $repository, + protected readonly Registry $coreRegistry, + Action\Context $context, + ) { parent::__construct($context); - - $this->repository = $repository; - $this->coreRegistry = $coreRegistry; } } diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/Edit.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/Edit.php index 5f9951f..b178abf 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/Edit.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/Edit.php @@ -13,20 +13,14 @@ class Edit extends CartItem { - private CartItemInterfaceFactory $entityFactory; - private PageFactory $resultPageFactory; - public function __construct( - CartItemInterfaceFactory $entityFactory, - PageFactory $resultPageFactory, + private readonly CartItemInterfaceFactory $entityFactory, + private readonly PageFactory $resultPageFactory, CartItemRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->entityFactory = $entityFactory; - $this->resultPageFactory = $resultPageFactory; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/Index.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/Index.php index 3d64e74..ab659aa 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/Index.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/Index.php @@ -12,20 +12,14 @@ class Index extends CartItem { - private PageFactory $resultPageFactory; - private DataPersistorInterface $dataPersistor; - public function __construct( - PageFactory $resultPageFactory, - DataPersistorInterface $dataPersistor, + private readonly PageFactory $resultPageFactory, + private readonly DataPersistorInterface $dataPersistor, CartItemRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->resultPageFactory = $resultPageFactory; - $this->dataPersistor = $dataPersistor; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/InlineEdit.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/InlineEdit.php index 46ea5da..059c13a 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/InlineEdit.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/InlineEdit.php @@ -12,17 +12,13 @@ class InlineEdit extends CartItem { - private JsonFactory $jsonFactory; - public function __construct( - JsonFactory $jsonFactory, + private readonly JsonFactory $jsonFactory, CartItemRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->jsonFactory = $jsonFactory; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/MassDelete.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/MassDelete.php index ae7b8af..87ac680 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/MassDelete.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/MassDelete.php @@ -13,18 +13,13 @@ class MassDelete extends CartItem { - private Filter $filter; - private CollectionFactory $collectionFactory; - public function __construct( - CollectionFactory $collectionFactory, - Filter $filter, + private readonly CollectionFactory $collectionFactory, + private readonly Filter $filter, CartItemRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { - $this->filter = $filter; - $this->collectionFactory = $collectionFactory; parent::__construct($repository, $coreRegistry, $context); } diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/NewAction.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/NewAction.php index 7c9996f..617be48 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/NewAction.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/NewAction.php @@ -11,17 +11,13 @@ class NewAction extends CartItem { - private ForwardFactory $resultForwardFactory; - public function __construct( - ForwardFactory $resultForwardFactory, + private readonly ForwardFactory $resultForwardFactory, CartItemRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->resultForwardFactory = $resultForwardFactory; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/Save.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/Save.php index f3ba568..1576426 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/Save.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/CartItem/Save.php @@ -14,20 +14,14 @@ class Save extends CartItem { - private DataPersistorInterface $dataPersistor; - private CartItemInterfaceFactory $entityFactory; - public function __construct( - DataPersistorInterface $dataPersistor, - CartItemInterfaceFactory $entityFactory, + private readonly DataPersistorInterface $dataPersistor, + private readonly CartItemInterfaceFactory $entityFactory, CartItemRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->dataPersistor = $dataPersistor; - $this->entityFactory = $entityFactory; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns.php index a518829..063a1e6 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns.php @@ -15,14 +15,11 @@ abstract class Columns extends Action */ public const ADMIN_RESOURCE = 'Mygento_SampleModule::columns'; - protected Registry $coreRegistry; - protected ColumnsRepositoryInterface $repository; - - public function __construct(ColumnsRepositoryInterface $repository, Registry $coreRegistry, Action\Context $context) - { + public function __construct( + protected readonly ColumnsRepositoryInterface $repository, + protected readonly Registry $coreRegistry, + Action\Context $context, + ) { parent::__construct($context); - - $this->repository = $repository; - $this->coreRegistry = $coreRegistry; } } diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/Edit.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/Edit.php index 2a87f61..d87ad2a 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/Edit.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/Edit.php @@ -13,20 +13,14 @@ class Edit extends Columns { - private ColumnsInterfaceFactory $entityFactory; - private PageFactory $resultPageFactory; - public function __construct( - ColumnsInterfaceFactory $entityFactory, - PageFactory $resultPageFactory, + private readonly ColumnsInterfaceFactory $entityFactory, + private readonly PageFactory $resultPageFactory, ColumnsRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->entityFactory = $entityFactory; - $this->resultPageFactory = $resultPageFactory; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/Index.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/Index.php index c32da73..693c393 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/Index.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/Index.php @@ -12,20 +12,14 @@ class Index extends Columns { - private PageFactory $resultPageFactory; - private DataPersistorInterface $dataPersistor; - public function __construct( - PageFactory $resultPageFactory, - DataPersistorInterface $dataPersistor, + private readonly PageFactory $resultPageFactory, + private readonly DataPersistorInterface $dataPersistor, ColumnsRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->resultPageFactory = $resultPageFactory; - $this->dataPersistor = $dataPersistor; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/InlineEdit.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/InlineEdit.php index 5f4b437..d38fd2d 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/InlineEdit.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/InlineEdit.php @@ -12,17 +12,13 @@ class InlineEdit extends Columns { - private JsonFactory $jsonFactory; - public function __construct( - JsonFactory $jsonFactory, + private readonly JsonFactory $jsonFactory, ColumnsRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->jsonFactory = $jsonFactory; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/MassDelete.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/MassDelete.php index 13d7a09..838c543 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/MassDelete.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/MassDelete.php @@ -13,18 +13,13 @@ class MassDelete extends Columns { - private Filter $filter; - private CollectionFactory $collectionFactory; - public function __construct( - CollectionFactory $collectionFactory, - Filter $filter, + private readonly CollectionFactory $collectionFactory, + private readonly Filter $filter, ColumnsRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { - $this->filter = $filter; - $this->collectionFactory = $collectionFactory; parent::__construct($repository, $coreRegistry, $context); } diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/NewAction.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/NewAction.php index 80cc1e2..5ff63b5 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/NewAction.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/NewAction.php @@ -11,17 +11,13 @@ class NewAction extends Columns { - private ForwardFactory $resultForwardFactory; - public function __construct( - ForwardFactory $resultForwardFactory, + private readonly ForwardFactory $resultForwardFactory, ColumnsRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->resultForwardFactory = $resultForwardFactory; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/Save.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/Save.php index dff1bcf..73c4248 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/Save.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Columns/Save.php @@ -14,20 +14,14 @@ class Save extends Columns { - private DataPersistorInterface $dataPersistor; - private ColumnsInterfaceFactory $entityFactory; - public function __construct( - DataPersistorInterface $dataPersistor, - ColumnsInterfaceFactory $entityFactory, + private readonly DataPersistorInterface $dataPersistor, + private readonly ColumnsInterfaceFactory $entityFactory, ColumnsRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->dataPersistor = $dataPersistor; - $this->entityFactory = $entityFactory; } /** diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Poster.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Poster.php index 7c93781..5507757 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Poster.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Poster.php @@ -15,14 +15,11 @@ abstract class Poster extends Action */ public const ADMIN_RESOURCE = 'Mygento_SampleModule::poster'; - protected Registry $coreRegistry; - protected PosterRepositoryInterface $repository; - - public function __construct(PosterRepositoryInterface $repository, Registry $coreRegistry, Action\Context $context) - { + public function __construct( + protected readonly PosterRepositoryInterface $repository, + protected readonly Registry $coreRegistry, + Action\Context $context, + ) { parent::__construct($context); - - $this->repository = $repository; - $this->coreRegistry = $coreRegistry; } } diff --git a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Poster/Index.php b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Poster/Index.php index 0c8b2ec..c28ca72 100644 --- a/test/Expectations/Crud/82/v1/Controller/Adminhtml/Poster/Index.php +++ b/test/Expectations/Crud/82/v1/Controller/Adminhtml/Poster/Index.php @@ -12,20 +12,14 @@ class Index extends Poster { - private PageFactory $resultPageFactory; - private DataPersistorInterface $dataPersistor; - public function __construct( - PageFactory $resultPageFactory, - DataPersistorInterface $dataPersistor, + private readonly PageFactory $resultPageFactory, + private readonly DataPersistorInterface $dataPersistor, PosterRepositoryInterface $repository, Registry $coreRegistry, - Context $context + Context $context, ) { parent::__construct($repository, $coreRegistry, $context); - - $this->resultPageFactory = $resultPageFactory; - $this->dataPersistor = $dataPersistor; } /** diff --git a/test/Expectations/Crud/82/v1/Model/CardRepository.php b/test/Expectations/Crud/82/v1/Model/CardRepository.php index 27a6e0f..41d04d3 100644 --- a/test/Expectations/Crud/82/v1/Model/CardRepository.php +++ b/test/Expectations/Crud/82/v1/Model/CardRepository.php @@ -20,27 +20,14 @@ */ class CardRepository implements CardRepositoryInterface { - private ResourceModel\Card $resource; - private CollectionFactory $collectionFactory; - private CardInterfaceFactory $entityFactory; - private CardSearchResultsInterfaceFactory $searchResultsFactory; - private StoreManagerInterface $storeManager; - private CollectionProcessorInterface $collectionProcessor; - public function __construct( - ResourceModel\Card $resource, - CollectionFactory $collectionFactory, - CardInterfaceFactory $entityFactory, - CardSearchResultsInterfaceFactory $searchResultsFactory, - StoreManagerInterface $storeManager, - CollectionProcessorInterface $collectionProcessor + private readonly ResourceModel\Card $resource, + private readonly CollectionFactory $collectionFactory, + private readonly CardInterfaceFactory $entityFactory, + private readonly CardSearchResultsInterfaceFactory $searchResultsFactory, + private readonly StoreManagerInterface $storeManager, + private readonly CollectionProcessorInterface $collectionProcessor, ) { - $this->resource = $resource; - $this->collectionFactory = $collectionFactory; - $this->entityFactory = $entityFactory; - $this->searchResultsFactory = $searchResultsFactory; - $this->collectionProcessor = $collectionProcessor; - $this->storeManager = $storeManager; } /** diff --git a/test/Expectations/Crud/82/v1/Model/CartItemRepository.php b/test/Expectations/Crud/82/v1/Model/CartItemRepository.php index 4783232..80ece61 100644 --- a/test/Expectations/Crud/82/v1/Model/CartItemRepository.php +++ b/test/Expectations/Crud/82/v1/Model/CartItemRepository.php @@ -19,24 +19,13 @@ */ class CartItemRepository implements CartItemRepositoryInterface { - private ResourceModel\CartItem $resource; - private CollectionFactory $collectionFactory; - private CartItemInterfaceFactory $entityFactory; - private CartItemSearchResultsInterfaceFactory $searchResultsFactory; - private CollectionProcessorInterface $collectionProcessor; - public function __construct( - ResourceModel\CartItem $resource, - CollectionFactory $collectionFactory, - CartItemInterfaceFactory $entityFactory, - CartItemSearchResultsInterfaceFactory $searchResultsFactory, - CollectionProcessorInterface $collectionProcessor + private readonly ResourceModel\CartItem $resource, + private readonly CollectionFactory $collectionFactory, + private readonly CartItemInterfaceFactory $entityFactory, + private readonly CartItemSearchResultsInterfaceFactory $searchResultsFactory, + private readonly CollectionProcessorInterface $collectionProcessor, ) { - $this->resource = $resource; - $this->collectionFactory = $collectionFactory; - $this->entityFactory = $entityFactory; - $this->searchResultsFactory = $searchResultsFactory; - $this->collectionProcessor = $collectionProcessor; } /** diff --git a/test/Expectations/Crud/82/v1/Model/ColumnsRepository.php b/test/Expectations/Crud/82/v1/Model/ColumnsRepository.php index 0ed79c4..b6af139 100644 --- a/test/Expectations/Crud/82/v1/Model/ColumnsRepository.php +++ b/test/Expectations/Crud/82/v1/Model/ColumnsRepository.php @@ -19,24 +19,13 @@ */ class ColumnsRepository implements ColumnsRepositoryInterface { - private ResourceModel\Columns $resource; - private CollectionFactory $collectionFactory; - private ColumnsInterfaceFactory $entityFactory; - private ColumnsSearchResultsInterfaceFactory $searchResultsFactory; - private CollectionProcessorInterface $collectionProcessor; - public function __construct( - ResourceModel\Columns $resource, - CollectionFactory $collectionFactory, - ColumnsInterfaceFactory $entityFactory, - ColumnsSearchResultsInterfaceFactory $searchResultsFactory, - CollectionProcessorInterface $collectionProcessor + private readonly ResourceModel\Columns $resource, + private readonly CollectionFactory $collectionFactory, + private readonly ColumnsInterfaceFactory $entityFactory, + private readonly ColumnsSearchResultsInterfaceFactory $searchResultsFactory, + private readonly CollectionProcessorInterface $collectionProcessor, ) { - $this->resource = $resource; - $this->collectionFactory = $collectionFactory; - $this->entityFactory = $entityFactory; - $this->searchResultsFactory = $searchResultsFactory; - $this->collectionProcessor = $collectionProcessor; } /** diff --git a/test/Expectations/Crud/82/v1/Model/PosterRepository.php b/test/Expectations/Crud/82/v1/Model/PosterRepository.php index 1ab97b4..e243ef5 100644 --- a/test/Expectations/Crud/82/v1/Model/PosterRepository.php +++ b/test/Expectations/Crud/82/v1/Model/PosterRepository.php @@ -19,24 +19,13 @@ */ class PosterRepository implements PosterRepositoryInterface { - private ResourceModel\Poster $resource; - private CollectionFactory $collectionFactory; - private PosterInterfaceFactory $entityFactory; - private PosterSearchResultsInterfaceFactory $searchResultsFactory; - private CollectionProcessorInterface $collectionProcessor; - public function __construct( - ResourceModel\Poster $resource, - CollectionFactory $collectionFactory, - PosterInterfaceFactory $entityFactory, - PosterSearchResultsInterfaceFactory $searchResultsFactory, - CollectionProcessorInterface $collectionProcessor + private readonly ResourceModel\Poster $resource, + private readonly CollectionFactory $collectionFactory, + private readonly PosterInterfaceFactory $entityFactory, + private readonly PosterSearchResultsInterfaceFactory $searchResultsFactory, + private readonly CollectionProcessorInterface $collectionProcessor, ) { - $this->resource = $resource; - $this->collectionFactory = $collectionFactory; - $this->entityFactory = $entityFactory; - $this->searchResultsFactory = $searchResultsFactory; - $this->collectionProcessor = $collectionProcessor; } /** diff --git a/test/Expectations/Crud/82/v1/Model/ResourceModel/Card.php b/test/Expectations/Crud/82/v1/Model/ResourceModel/Card.php index b55c93f..adca5d1 100644 --- a/test/Expectations/Crud/82/v1/Model/ResourceModel/Card.php +++ b/test/Expectations/Crud/82/v1/Model/ResourceModel/Card.php @@ -14,18 +14,13 @@ class Card extends AbstractDb public const TABLE_NAME = 'mygento_sample_module_card'; public const TABLE_PRIMARY_KEY = 'card_id'; - private EntityManager $entityManager; - private MetadataPool $metadataPool; - public function __construct( - EntityManager $entityManager, - MetadataPool $metadataPool, + private readonly EntityManager $entityManager, + private readonly MetadataPool $metadataPool, Context $context, - string $connectionName = null + string $connectionName = null, ) { parent::__construct($context, $connectionName); - $this->entityManager = $entityManager; - $this->metadataPool = $metadataPool; } /** diff --git a/test/Expectations/Crud/82/v1/Model/ResourceModel/Card/Collection.php b/test/Expectations/Crud/82/v1/Model/ResourceModel/Card/Collection.php index e8ac53a..79b083e 100644 --- a/test/Expectations/Crud/82/v1/Model/ResourceModel/Card/Collection.php +++ b/test/Expectations/Crud/82/v1/Model/ResourceModel/Card/Collection.php @@ -19,19 +19,17 @@ class Collection extends AbstractCollection /** @var string */ protected $_idFieldName = CardResource::TABLE_PRIMARY_KEY; - private MetadataPool $metadataPool; - /** * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( - MetadataPool $metadataPool, + private readonly MetadataPool $metadataPool, EntityFactoryInterface $entityFactory, LoggerInterface $logger, FetchStrategyInterface $fetchStrategy, ManagerInterface $eventManager, AdapterInterface $connection = null, - AbstractDb $resource = null + AbstractDb $resource = null, ) { parent::__construct( $entityFactory, @@ -41,7 +39,6 @@ public function __construct( $connection, $resource ); - $this->metadataPool = $metadataPool; } /** diff --git a/test/Expectations/Crud/82/v1/Model/ResourceModel/Card/Relation/Store/ReadHandler.php b/test/Expectations/Crud/82/v1/Model/ResourceModel/Card/Relation/Store/ReadHandler.php index 24c2313..a884a57 100644 --- a/test/Expectations/Crud/82/v1/Model/ResourceModel/Card/Relation/Store/ReadHandler.php +++ b/test/Expectations/Crud/82/v1/Model/ResourceModel/Card/Relation/Store/ReadHandler.php @@ -8,11 +8,8 @@ class ReadHandler implements ExtensionInterface { - private Card $resource; - - public function __construct(Card $resource) + public function __construct(private readonly Card $resource) { - $this->resource = $resource; } /** diff --git a/test/Expectations/Crud/82/v1/Model/ResourceModel/Card/Relation/Store/SaveHandler.php b/test/Expectations/Crud/82/v1/Model/ResourceModel/Card/Relation/Store/SaveHandler.php index 3a2e5be..369b40a 100644 --- a/test/Expectations/Crud/82/v1/Model/ResourceModel/Card/Relation/Store/SaveHandler.php +++ b/test/Expectations/Crud/82/v1/Model/ResourceModel/Card/Relation/Store/SaveHandler.php @@ -9,13 +9,10 @@ class SaveHandler implements ExtensionInterface { - private Card $resource; - private MetadataPool $metadataPool; - - public function __construct(Card $resource, MetadataPool $metadataPool) - { - $this->resource = $resource; - $this->metadataPool = $metadataPool; + public function __construct( + private readonly Card $resource, + private readonly MetadataPool $metadataPool, + ) { } /** diff --git a/test/Expectations/Project/.editorconfig b/test/Expectations/Project/.editorconfig deleted file mode 100644 index 99bde9f..0000000 --- a/test/Expectations/Project/.editorconfig +++ /dev/null @@ -1,14 +0,0 @@ -root = true - -[*] -indent_style = space -indent_size = 4 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true - -[*.{json,yml,js,scss,css}] -indent_size = 2 - -[*.md] -trim_trailing_whitespace = false diff --git a/test/Expectations/Project/.eslintrc.json b/test/Expectations/Project/.eslintrc.json deleted file mode 100644 index b5a3f8f..0000000 --- a/test/Expectations/Project/.eslintrc.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "env": { - "node": true, - "browser": true, - "jquery": true, - "amd": true, - "prototypejs": true - }, - "globals": {}, - "parserOptions": { - "ecmaVersion": 6 - }, - "extends": "eslint:recommended", - "rules": { - "indent": [ - "error", - 2 - ], - "keyword-spacing": [ - "error", - { - "before": true, - "after": true - } - ], - "linebreak-style": [ - "error", - "unix" - ], - "no-multiple-empty-lines": "error", - "no-unused-vars": "warn", - "quotes": [ - "error", - "single" - ], - "semi": [ - "error", - "always" - ], - "space-before-blocks": [ - "error", - "always" - ] - } -} diff --git a/test/Expectations/Project/.php_cs b/test/Expectations/Project/.php_cs deleted file mode 100644 index ae855a7..0000000 --- a/test/Expectations/Project/.php_cs +++ /dev/null @@ -1,51 +0,0 @@ -in('app') - ->name('*.phtml') - ->exclude('dev/tests/functional/generated') - ->exclude('dev/tests/functional/var') - ->exclude('dev/tests/functional/vendor') - ->exclude('dev/tests/integration/tmp') - ->exclude('dev/tests/integration/var') - ->exclude('lib/internal/Cm') - ->exclude('lib/internal/Credis') - ->exclude('lib/internal/Less') - ->exclude('lib/internal/LinLibertineFont') - ->exclude('pub/media') - ->exclude('pub/static') - ->exclude('setup/vendor') - ->exclude('var'); - -return PhpCsFixer\Config::create() - ->setFinder($finder) - ->setRules([ - '@PSR2' => true, - 'array_syntax' => ['syntax' => 'short'], - 'concat_space' => ['spacing' => 'one'], - 'include' => true, - 'new_with_braces' => true, - 'no_empty_statement' => true, - 'no_extra_consecutive_blank_lines' => true, - 'no_leading_import_slash' => true, - 'no_leading_namespace_whitespace' => true, - 'no_multiline_whitespace_around_double_arrow' => true, - 'no_multiline_whitespace_before_semicolons' => true, - 'no_singleline_whitespace_before_semicolons' => true, - 'no_trailing_comma_in_singleline_array' => true, - 'no_unused_imports' => true, - 'no_whitespace_in_blank_line' => true, - 'object_operator_without_whitespace' => true, - 'ordered_imports' => true, - 'standardize_not_equals' => true, - 'ternary_operator_spaces' => true, - // mygento - 'phpdoc_order' => true, - 'phpdoc_types' => true, - 'phpdoc_add_missing_param_annotation' => true, - 'single_quote' => true, - 'ternary_to_null_coalescing' => true, - 'lowercase_cast' => true, - 'no_empty_comment' => true, - 'no_empty_phpdoc' => true, - 'return_type_declaration' => true, - ]); diff --git a/test/Expectations/Project/.scss-lint.yml b/test/Expectations/Project/.scss-lint.yml deleted file mode 100644 index 780daca..0000000 --- a/test/Expectations/Project/.scss-lint.yml +++ /dev/null @@ -1,237 +0,0 @@ -severity: error - -linters: - - BangFormat: - enabled: true - space_before_bang: true - space_after_bang: false - - BemDepth: - enabled: true - max_elements: 3 - - BorderZero: - enabled: true - convention: zero - - ChainedClasses: - enabled: false - - ColorKeyword: - enabled: true - - ColorVariable: - enabled: true - - Comment: - enabled: false - - DebugStatement: - enabled: true - - DeclarationOrder: - enabled: true - - DisableLinterReason: - enabled: true - - DuplicateProperty: - enabled: true - - ElsePlacement: - enabled: true - style: same_line - - EmptyLineBetweenBlocks: - enabled: true - ignore_single_line_blocks: true - - EmptyRule: - enabled: true - - ExtendDirective: - enabled: false - - FinalNewline: - enabled: true - present: true - - HexLength: - enabled: true - style: short - - HexNotation: - enabled: true - style: lowercase - - HexValidation: - enabled: true - - IdSelector: - enabled: true - severity: warning - - ImportantRule: - enabled: true - severity: warning - - ImportPath: - enabled: true - leading_underscore: false - filename_extension: false - - Indentation: - enabled: true - allow_non_nested_indentation: true - character: space - width: 2 - - LeadingZero: - enabled: true - style: include_zero - - LengthVariable: - enabled: false - severity: warning - - MergeableSelector: - enabled: false - force_nesting: false - - NameFormat: - enabled: true - convention: hyphenated_lowercase - allow_leading_underscore: true - - NestingDepth: - enabled: true - max_depth: 3 - - PlaceholderInExtend: - enabled: true - - PrivateNamingConvention: - enabled: true - prefix: _ - - PropertyCount: - enabled: false - - PropertySortOrder: - enabled: false - - PropertySpelling: - enabled: true - extra_properties: [] - - PropertyUnits: - enabled: true - global: ['em', 'rem', '%', 'vh', 'vw'] - properties: - line-height: [] # No units allowed - font-size: [] # No units allowed - border: [] - transition: ['s'] - - PseudoElement: - enabled: true - - QualifyingElement: - enabled: true - allow_element_with_attribute: false - allow_element_with_class: false - allow_element_with_id: false - severity: warning - - SelectorDepth: - enabled: true - max_depth: 3 - - SelectorFormat: - enabled: false - convention: hyphenated_lowercase - - Shorthand: - enabled: true - - SingleLinePerProperty: - enabled: true - allow_single_line_rule_sets: false - - SingleLinePerSelector: - enabled: true - - SpaceAfterComma: - enabled: true - - SpaceAfterPropertyColon: - enabled: true - style: one_space - - SpaceAfterPropertyName: - enabled: true - - SpaceAfterVariableColon: - enabled: true - style: at_least_one_space - - SpaceAfterVariableName: - enabled: true - - SpaceAroundOperator: - enabled: true - style: one_space - - SpaceBeforeBrace: - enabled: true - style: space - allow_single_line_padding: true - - SpaceBetweenParens: - enabled: true - spaces: 0 - - StringQuotes: - enabled: true - style: single_quotes - - TrailingSemicolon: - enabled: true - - TrailingZero: - enabled: true - - TrailingWhitespace: - enabled: true - - TransitionAll: - enabled: false - - UnnecessaryMantissa: - enabled: true - - UnnecessaryParentReference: - enabled: true - - UrlFormat: - enabled: false - - UrlQuotes: - enabled: true - - VariableForProperty: - enabled: true - properties: - - color - - font-size - - line-height - - VendorPrefixes: - enabled: true - identifier_list: base - include: [] - exclude: [] - - ZeroUnit: - enabled: true diff --git a/test/Expectations/Project/.shippable.yml b/test/Expectations/Project/.shippable.yml deleted file mode 100644 index bdd22c5..0000000 --- a/test/Expectations/Project/.shippable.yml +++ /dev/null @@ -1,21 +0,0 @@ -branches: - only: - - stage - - production - -build: - pre_ci_boot: - image_name: mygento/deployer - image_tag: v1-full - pull: true - ci: - - apt-get install libxml2-utils - - composer self-update - - bundle install - - if [[ $IS_PULL_REQUEST == true ]]; then npm install --production --silent --no-progress; fi - - if [[ $IS_PULL_REQUEST == true ]]; then NODE_ENV=production gulp lint; fi - - if [[ $IS_PULL_REQUEST == true ]]; then rm composer.json; rm composer.lock; fi - - if [[ $IS_PULL_REQUEST == true ]]; then composer require mygento/coding-standard --quiet; fi - - if [[ $IS_PULL_REQUEST == true ]]; then php vendor/bin/grumphp run; fi - on_success: - - if [[ $IS_PULL_REQUEST != true ]]; then mina $BRANCH deploy; fi diff --git a/test/Expectations/Project/Gemfile b/test/Expectations/Project/Gemfile deleted file mode 100644 index 14b885b..0000000 --- a/test/Expectations/Project/Gemfile +++ /dev/null @@ -1,4 +0,0 @@ -source 'https://rubygems.org' - -gem 'mina', git: 'https://github.com/luckyraul/mina.git', branch: 'relative_path' -gem 'scss_lint', require: false diff --git a/test/Expectations/Project/app/etc/config.php b/test/Expectations/Project/app/etc/config.php deleted file mode 100644 index a9d8ed7..0000000 --- a/test/Expectations/Project/app/etc/config.php +++ /dev/null @@ -1,123 +0,0 @@ - - array ( - 'Magento_Store' => 1, - 'Magento_Directory' => 1, - 'Magento_AdvancedPricingImportExport' => 1, - 'Magento_Config' => 1, - 'Magento_Backend' => 1, - 'Magento_Theme' => 1, - 'Magento_Eav' => 1, - 'Magento_Backup' => 1, - 'Magento_Customer' => 1, - 'Magento_AdminNotification' => 1, - 'Magento_BundleImportExport' => 1, - 'Magento_CacheInvalidate' => 1, - 'Magento_Indexer' => 1, - 'Magento_Cms' => 1, - 'Magento_Security' => 1, - 'Magento_CatalogImportExport' => 1, - 'Magento_Rule' => 1, - 'Magento_Cron' => 1, - 'Magento_Catalog' => 1, - 'Magento_Search' => 1, - 'Magento_CatalogUrlRewrite' => 1, - 'Magento_Widget' => 1, - 'Magento_Quote' => 1, - 'Magento_SalesSequence' => 1, - 'Magento_Payment' => 1, - 'Magento_CmsUrlRewrite' => 1, - 'Magento_User' => 1, - 'Magento_ConfigurableImportExport' => 1, - 'Magento_Msrp' => 1, - 'Magento_CatalogInventory' => 1, - 'Magento_Contact' => 1, - 'Magento_Cookie' => 1, - 'Magento_Newsletter' => 1, - 'Magento_CurrencySymbol' => 1, - 'Magento_Sales' => 1, - 'Magento_Integration' => 1, - 'Magento_CustomerImportExport' => 1, - 'Magento_Deploy' => 1, - 'Magento_Developer' => 1, - 'Magento_Dhl' => 1, - 'Magento_Authorization' => 1, - 'Magento_Downloadable' => 1, - 'Magento_ImportExport' => 1, - 'Magento_Bundle' => 1, - 'Magento_Email' => 1, - 'Magento_EncryptionKey' => 1, - 'Magento_Fedex' => 1, - 'Magento_GiftMessage' => 0, - 'Magento_Checkout' => 1, - 'Magento_GoogleAnalytics' => 1, - 'Magento_Ui' => 1, - 'Magento_GroupedImportExport' => 1, - 'Magento_GroupedProduct' => 1, - 'Magento_DownloadableImportExport' => 1, - 'Magento_CatalogRule' => 1, - 'Magento_InstantPurchase' => 1, - 'Magento_Analytics' => 1, - 'Magento_LayeredNavigation' => 1, - 'Magento_Marketplace' => 1, - 'Magento_MediaStorage' => 1, - 'Magento_ConfigurableProduct' => 1, - 'Magento_Multishipping' => 1, - 'Magento_NewRelicReporting' => 1, - 'Magento_Reports' => 1, - 'Magento_OfflinePayments' => 1, - 'Magento_SalesRule' => 1, - 'Magento_PageCache' => 1, - 'Magento_Vault' => 1, - 'Magento_Paypal' => 1, - 'Magento_Persistent' => 1, - 'Magento_ProductAlert' => 1, - 'Magento_ProductVideo' => 1, - 'Magento_CheckoutAgreements' => 1, - 'Magento_QuoteAnalytics' => 1, - 'Magento_ReleaseNotification' => 1, - 'Magento_Review' => 1, - 'Magento_RequireJs' => 1, - 'Magento_Shipping' => 1, - 'Magento_ReviewAnalytics' => 1, - 'Magento_Robots' => 1, - 'Magento_Rss' => 1, - 'Magento_CatalogRuleConfigurable' => 1, - 'Magento_Captcha' => 1, - 'Magento_SalesAnalytics' => 1, - 'Magento_SalesInventory' => 1, - 'Magento_OfflineShipping' => 1, - 'Magento_ConfigurableProductSales' => 1, - 'Magento_UrlRewrite' => 1, - 'Magento_CatalogSearch' => 1, - 'Magento_CustomerAnalytics' => 1, - 'Magento_SendFriend' => 1, - 'Magento_Wishlist' => 1, - 'Magento_Signifyd' => 1, - 'Magento_Sitemap' => 1, - 'Magento_Authorizenet' => 1, - 'Magento_Swagger' => 1, - 'Magento_Swatches' => 1, - 'Magento_SwatchesLayeredNavigation' => 1, - 'Magento_Tax' => 1, - 'Magento_TaxImportExport' => 1, - 'Magento_GoogleAdwords' => 1, - 'Magento_Translation' => 1, - 'Magento_GoogleOptimizer' => 1, - 'Magento_Ups' => 1, - 'Magento_SampleData' => 1, - 'Magento_CatalogAnalytics' => 1, - 'Magento_Usps' => 1, - 'Magento_Variable' => 1, - 'Magento_Braintree' => 1, - 'Magento_Version' => 1, - 'Magento_Webapi' => 1, - 'Magento_WebapiSecurity' => 1, - 'Magento_Weee' => 1, - 'Magento_CatalogWidget' => 1, - 'Magento_WishlistAnalytics' => 1, - 'Mygento_Base' => 1, - 'Mygento_Configsync' => 1 - ), -); \ No newline at end of file diff --git a/test/Expectations/Project/composer.json b/test/Expectations/Project/composer.json deleted file mode 100644 index 20e2498..0000000 --- a/test/Expectations/Project/composer.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "mygento/sample", - "type": "project", - "version": "2.2.6", - "require": { - "magento/product-community-edition": "~2.2", - "composer/composer": "1.4.1", - "mygento/base": "~2.2", - "mygento/module-configsync": "~2.2", - "mageplaza/module-smtp": "^1.1.0", - "etws/magento-language-ru_ru": "dev-develop" - }, - "replace": { - "magento/module-marketplace": "*", - "magento/module-cybersource": "*", - "magento/module-authorizenet": "*", - "magento/module-signifyd": "*", - "temando/module-shipping-m2": "*", - "shopialfb/facebook-module": "*", - "amzn/amazon-pay-and-login-magento-2-module": "*", - "amzn/amazon-pay-and-login-with-amazon-core-module": "*", - "dotmailer/dotmailer-magento2-extension": "*", - "klarna/module-core": "*", - "klarna/module-kp": "*", - "klarna/module-ordermanagement": "*", - "vertex/module-tax": "*", - "amzn/amazon-pay-module": "*", - "amzn/login-with-amazon-module": "*" - }, - "require-dev": { - "mygento/coding-standard": "~2.2" - }, - "autoload": { - "psr-4": { - "Magento\\Framework\\": "lib/internal/Magento/Framework/", - "Magento\\Setup\\": "setup/src/Magento/Setup/", - "Magento\\": "app/code/Magento/" - }, - "psr-0": { - "": [ - "app/code/" - ] - }, - "files": [ - "app/etc/NonComposerComponentRegistration.php" - ], - "exclude-from-classmap": [ - "**/dev/**", - "**/update/**", - "**/Test/**" - ] - }, - "autoload-dev": { - "psr-4": { - "Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/", - "Magento\\Tools\\": "dev/tools/Magento/Tools/", - "Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/", - "Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/", - "Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/" - } - }, - "minimum-stability": "stable", - "prefer-stable": true, - "repositories": [ - { - "type": "composer", - "url": "https://repo.magento.com/" - } - ], - "extra": { - "magento-force": "override" - } -} diff --git a/test/Expectations/Project/config/deploy.rb b/test/Expectations/Project/config/deploy.rb deleted file mode 100644 index 47d3776..0000000 --- a/test/Expectations/Project/config/deploy.rb +++ /dev/null @@ -1,83 +0,0 @@ -require 'mina/deploy' -require 'mina/git' - -set :application_name, 'sample' # application name -set :repository, '' - -set :shared_dirs, ['var/log','var/backups','var/report','pub/media', 'var/import','var/export'] -set :shared_files, ['app/etc/env.php','pub/sitemap.xml'] - -# default -set :ssh_options, '-A' -set :forward_agent, true - -task :stage do - set :user, 'sample' - set :domain, 'host.ru' - set :deploy_to, "/var/www/sample/host.ru" - set :branch, 'stage' - set :php_bin, 'php' - set :composer_install_command, 'install --no-dev' - set :keep_releases, 3 -end - -task :production do - set :user, 'sample' - set :domain, 'host.ru' - set :deploy_to, "/var/www/sample/host.ru" - set :branch, 'production' - set :php_bin, 'php' - set :composer_install_command, 'install --no-dev --prefer-dist --no-interaction --quiet' -end - -task :setup do - command %{mkdir -p "#{fetch(:shared_path)}/pub/media"} - command %{mkdir -p "#{fetch(:shared_path)}/var/log"} - command %{mkdir -p "#{fetch(:shared_path)}/var/report"} - command %{mkdir -p "#{fetch(:shared_path)}/var/mygento/cml"} - command %{mkdir -p "#{fetch(:shared_path)}/app/etc"} - command %[curl -s https://getcomposer.org/installer | php -- --install-dir=#{fetch(:shared_path)}] -end - -task :composer do - command "php #{fetch(:shared_path)}/composer.phar self-update" - if ENV['MAGE_LOGIN'] - command "php #{fetch(:shared_path)}/composer.phar config http-basic.repo.magento.com #{ENV['MAGE_LOGIN']} #{ENV['MAGE_PWD']}" - end - command "php #{fetch(:shared_path)}/composer.phar #{fetch(:composer_install_command)}" -end - -task :npm do - command "npm install --production --silent --no-progress" - command "NODE_ENV=production gulp build" - command "rm -fR node_modules" -end - -task :magento do - command "PTH=$(pwd)" - command "#{fetch(:php_bin)} \"$PTH/bin/magento\" deploy:mode:set production -s" - command "#{fetch(:php_bin)} \"$PTH/bin/magento\" config:set dev/js/minify_files 1" - command "#{fetch(:php_bin)} \"$PTH/bin/magento\" config:set dev/css/minify_files 1" - command "#{fetch(:php_bin)} \"$PTH/bin/magento\" setup:upgrade --keep-generated" - command "#{fetch(:php_bin)} \"$PTH/bin/magento\" setup:di:compile -q" - command "#{fetch(:php_bin)} \"$PTH/bin/magento\" setup:static-content:deploy ru_RU -q" -end - -desc "Deploys the current version to the server." -task :deploy do - deploy do - invoke :'git:clone' - invoke :'composer' - invoke :'npm' - invoke :'deploy:link_shared_paths' - invoke :'magento' - - on :launch do - in_path(fetch(:current_path)) do - command "#{fetch(:php_bin)} #{fetch(:current_path)}/bin/magento setup:config:sync #{fetch(:branch)} #{fetch(:current_path)}/config/config.yml" - command "#{fetch(:php_bin)} #{fetch(:current_path)}/bin/magento cache:flush" - invoke :'deploy:cleanup' - end - end - end -end diff --git a/test/Expectations/Project/grumphp.yml b/test/Expectations/Project/grumphp.yml deleted file mode 100644 index eb870c2..0000000 --- a/test/Expectations/Project/grumphp.yml +++ /dev/null @@ -1,13 +0,0 @@ -parameters: - git_dir: . - bin_dir: vendor/bin - tasks: - git_blacklist: - keywords: - - "die(" - - "var_dump(" - - "exit;" - phplint: - phpcsfixer2: - config: '.php_cs' - xmllint: diff --git a/test/Expectations/Project/gulpfile.js b/test/Expectations/Project/gulpfile.js deleted file mode 100644 index 3ff79e3..0000000 --- a/test/Expectations/Project/gulpfile.js +++ /dev/null @@ -1,70 +0,0 @@ -const notProduction = process.env.NODE_ENV !== 'production'; - -const gulp = require('gulp'); -const sass = require('gulp-sass'); -const cssnano = require('gulp-cssnano'); -const scsslint = require('gulp-scss-lint'); -const eslint = require('gulp-eslint'); -const noop = require('through2').obj(); - -if (notProduction) { - var sourcemaps = require('gulp-sourcemaps'); - var notify = require('gulp-notify'); -} - -const theme_folder = './app/design/frontend/Mygento/sample'; -const scss_folder = `${theme_folder}/web/scss`; -const css_folder = `${theme_folder}/web/css`; - -const include_opt = {includePaths: [ - require('node-normalize-scss').includePaths, - require('node-reset-scss').includePath, - require('sassime').includePaths -]}; - -// CSS Config -const css_options = { - zindex: false, - autoprefixer: ({ - add: false, - browsers: ['> 1%'] - }) -}; - - -gulp.task('scss-lint', () => { - return gulp.src([`${scss_folder}/**/*.scss`, `!${scss_folder}/vendor/**/*.scss`]) - .pipe(scsslint({ - 'maxBuffer': 307200 - })) - .pipe(scsslint.failReporter('E')); -}); -gulp.task('js-lint', () => { - return gulp.src([`${theme_folder}/**/*.js`, '!node_modules/**', `!${theme_folder}/web/js/vendor/**/*.js`, `!${theme_folder}/web/mage/**/*.js`]) - .pipe(eslint()) - .pipe(eslint.format()) - .pipe(eslint.failAfterError()); -}); - -gulp.task('lint', gulp.parallel('scss-lint', 'js-lint')); -gulp.task('pre-commit', gulp.series('lint')); - -gulp.task('scss', () => { - return gulp.src([`${scss_folder}/**/*.scss`]) - .pipe(notProduction ? sourcemaps.init() : noop()) - .pipe(sass(include_opt).on('error', sass.logError)) - .pipe(cssnano(css_options)) - .pipe(notProduction ? sourcemaps.write('.') : noop()) - .pipe(gulp.dest(css_folder)) - .pipe(notProduction ? notify({ - message: 'Styles complete', - onLast: true - }) : noop()); -}); - -gulp.task('serve', gulp.series('scss', () => { - return gulp.watch(`${scss_folder}/**/*.scss`, gulp.series('scss')); -})); - -gulp.task('build', gulp.series('scss')); -gulp.task('default', gulp.parallel('serve', 'pre-commit')); diff --git a/test/Expectations/Project/package.json b/test/Expectations/Project/package.json deleted file mode 100644 index 499e7ec..0000000 --- a/test/Expectations/Project/package.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "sample", - "private": true, - "version": "1.0.0", - "description": "", - "main": "gulpfile.js", - "dependencies": { - "font-awesome": "^4.7.0", - "gulp": "4.0.0", - "gulp-changed": "^3.2.0", - "gulp-cssnano": "^2.1.3", - "gulp-eslint": "^5.0.0", - "gulp-sass": "^4.0.2", - "gulp-scss-lint": "^0.7.1", - "node-normalize-scss": "^8.0.0", - "node-reset-scss": "^1.0.1", - "sassime": "^1.1.6" - }, - "devDependencies": { - "gulp-notify": "^3.2.0", - "gulp-sourcemaps": "^2.6.4", - "guppy-pre-commit": "^0.4.0" - } -} diff --git a/test/Project/ProjectTest.php b/test/Project/ProjectTest.php deleted file mode 100644 index 9edb7ac..0000000 --- a/test/Project/ProjectTest.php +++ /dev/null @@ -1,72 +0,0 @@ -add(new EmptyProject()); - $command = $application->find('project-template'); - - $this->commandTester = new CommandTester($command); - $this->path = App::GEN . DIRECTORY_SEPARATOR . self::V; - } - - public function testProjectBasic() - { - $this->commandTester->execute([ - 'name' => 'Sample', - 'repo' => '', - 'path' => $this->path, - ]); - $this->checkJson('composer.json'); - $this->checkFile('app/etc/config.php'); - $this->checkFile('config/deploy.rb'); - $this->checkFile('.editorconfig'); - $this->checkJson('.eslintrc.json'); - $this->checkFile('.php_cs'); - $this->checkFile('.scss-lint.yml'); - $this->checkJson('composer.json'); - $this->checkJson('package.json'); - $this->checkFile('Gemfile'); - $this->checkFile('grumphp.yml'); - $this->checkFile('gulpfile.js'); - } - - private function checkFile($file) - { - $this->assertFileEquals( - 'test/Expectations/Project/' . $file, - $this->path . '/' . $file - ); - } - - private function checkXml($file) - { - $this->assertXmlFileEqualsXmlFile( - 'test/Expectations/Project/' . $file, - $this->path . '/' . $file - ); - } - - private function checkJson($file) - { - $this->assertJsonFileEqualsJsonFile( - 'test/Expectations/Project/' . $file, - $this->path . '/' . $file - ); - } -}