Skip to content

Commit

Permalink
remove legacy options, obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyraul committed Jul 31, 2024
1 parent 8d07398 commit 6bd99ee
Show file tree
Hide file tree
Showing 55 changed files with 430 additions and 1,042 deletions.
47 changes: 37 additions & 10 deletions .github/workflows/grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
- "8.3"
steps:
- uses: actions/checkout@v4

- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
Expand All @@ -46,25 +45,53 @@ jobs:
- name: Info
run: composer info
- name: Run Tests
run: php vendor/bin/grumphp run -vvv
run: php vendor/bin/grumphp run # -vvv
- name: Install Composer dependencies without dev
run: rm -fR vendor && composer install --no-progress --prefer-dist --optimize-autoloader --no-dev
if: matrix.php-versions == '8.1'
- name: Install Box
run: wget https://github.com/box-project/box/releases/download/4.5.1/box.phar
if: matrix.php-versions == '8.1'
- name: Compile phar
run: php box.phar compile
if: matrix.php-versions == '8.1'
- name: Compile Result
run: ls -lah
run: wget https://github.com/box-project/box/releases/download/4.5.1/box.phar && php box.phar compile
if: matrix.php-versions == '8.1'
# - name: Compile Result
# run: ls -lah
# if: matrix.php-versions == '8.1'
- name: Compile Result Upload
if: matrix.php-versions == '8.1'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: jeeves_new.phar
path: jeeves.phar
test:
runs-on: ubuntu-latest
needs: ["build"]
strategy:
fail-fast: false
matrix:
php-versions:
- "8.1"
- "8.2"
- "8.3"
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: jeeves_new.phar
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, intl, mysql
- name: Prepare test
run: mv .jeeves.phpunit_v1.yaml .jeeves.yaml
- name: Test phar
run: php jeeves.phar generate
release:
runs-on: ubuntu-latest
needs: ["test"]
steps:
- uses: actions/download-artifact@v4
with:
name: jeeves_new.phar
- name: Upload to Releases
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && matrix.php-versions == '8.1'
Expand Down
11 changes: 0 additions & 11 deletions .jeeves.phpunit_v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,6 @@ Mygento:
columns: ["city"]
IX_ACTIVE:
columns: ["is_active"]
Obsolete:
settings:
php_version: "7.3"
columns:
id:
type: int
pk: true
unsigned: true
comment: "Banner ID"
name:
type: varchar
Card:
api: true
cacheable: true
Expand Down
10 changes: 5 additions & 5 deletions src/Jeeves/Generators/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ class Common
protected const N = 'name';
protected const V = 'value';

protected function hasTypes(string $version): bool
{
return version_compare($version, '7.4.0', '>=');
}

protected function hasConstructorProp(string $version): bool
{
return version_compare($version, '8.0.0', '>=');
Expand All @@ -31,6 +26,11 @@ protected function hasReadOnlyClass(string $version): bool
return version_compare($version, '8.2.0', '>=');
}

protected function hasTypedConst(string $version): bool
{
return version_compare($version, '8.3.0', '>=');
}

protected function getService(): Service
{
$service = new Service();
Expand Down
33 changes: 8 additions & 25 deletions src/Jeeves/Generators/Crud/Controllers/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public function genAdminNewController(
string $rootNamespace,
string $phpVersion = PHP_VERSION
): PhpNamespace {
$typehint = $this->hasTypes($phpVersion);
$constructorProp = $this->hasConstructorProp($phpVersion);
$readonlyProp = $this->hasReadOnlyProp($phpVersion);

Expand All @@ -27,11 +26,7 @@ public function genAdminNewController(
if (!$constructorProp) {
$forward = $class->addProperty('resultForwardFactory')->setVisibility('private');

if ($typehint) {
$forward->setType('\Magento\Backend\Model\View\Result\ForwardFactory');
} else {
$forward->addComment('@var \Magento\Backend\Model\View\Result\ForwardFactory');
}
$forward->setType('\Magento\Backend\Model\View\Result\ForwardFactory');
}

$body = 'parent::__construct($repository, $coreRegistry, $context);';
Expand All @@ -41,19 +36,11 @@ public function genAdminNewController(
$construct = $class->addMethod('__construct')
->setBody($body);

if ($typehint) {
$namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity);
$namespace->addUse($repository);
$namespace->addUse('\Magento\Framework\Registry');
$namespace->addUse('\Magento\Backend\App\Action\Context');
$namespace->addUse('\Magento\Backend\Model\View\Result\ForwardFactory');
} else {
$construct
->addComment('@param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory')
->addComment('@param ' . $repository . ' $repository')
->addComment('@param \Magento\Framework\Registry $coreRegistry')
->addComment('@param \Magento\Backend\App\Action\Context $context');
}
$namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity);
$namespace->addUse($repository);
$namespace->addUse('\Magento\Framework\Registry');
$namespace->addUse('\Magento\Backend\App\Action\Context');
$namespace->addUse('\Magento\Backend\Model\View\Result\ForwardFactory');

if ($constructorProp) {
$construct
Expand All @@ -76,12 +63,8 @@ public function genAdminNewController(
. '$resultForward = $this->resultForwardFactory->create();' . PHP_EOL
. 'return $resultForward->forward(\'edit\');');

if ($typehint) {
$execute->setReturnType('\Magento\Framework\Controller\ResultInterface');
$namespace->addUse('\Magento\Framework\Controller\ResultInterface');
} else {
$execute->addComment('@return \Magento\Framework\Controller\ResultInterface');
}
$execute->setReturnType('\Magento\Framework\Controller\ResultInterface');
$namespace->addUse('\Magento\Framework\Controller\ResultInterface');

return $namespace;
}
Expand Down
13 changes: 3 additions & 10 deletions src/Jeeves/Generators/Crud/Controllers/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ public function genAdminDeleteController(
string $rootNamespace,
string $phpVersion = PHP_VERSION
): PhpNamespace {
$typehint = $this->hasTypes($phpVersion);
$namespace = new PhpNamespace($rootNamespace . '\Controller\Adminhtml\\' . $entity);

$class = $namespace->addClass('Delete')
->setExtends($rootNamespace . '\Controller\Adminhtml\\' . $entity);
$entityName = $this->getEntityPrintName($entity);

if ($typehint) {
$namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity);
}
$namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity);

$execute = $class->addMethod('execute')
->addComment('Delete ' . $entityName . ' action')
Expand All @@ -46,12 +43,8 @@ public function genAdminDeleteController(
. '}' . PHP_EOL . PHP_EOL
. 'return $resultRedirect->setPath(\'*/*/edit\', [\'id\' => $entityId]);');

if ($typehint) {
$execute->setReturnType('\Magento\Framework\Controller\ResultInterface');
$namespace->addUse('\Magento\Framework\Controller\ResultInterface');
} else {
$execute->addComment('@return \Magento\Framework\Controller\ResultInterface');
}
$execute->setReturnType('\Magento\Framework\Controller\ResultInterface');
$namespace->addUse('\Magento\Framework\Controller\ResultInterface');

return $namespace;
}
Expand Down
43 changes: 11 additions & 32 deletions src/Jeeves/Generators/Crud/Controllers/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public function genAdminEditController(
string $rootNamespace,
string $phpVersion = PHP_VERSION
): PhpNamespace {
$typehint = $this->hasTypes($phpVersion);
$constructorProp = $this->hasConstructorProp($phpVersion);
$readonlyProp = $this->hasReadOnlyProp($phpVersion);

Expand All @@ -26,11 +25,9 @@ public function genAdminEditController(
$class = $namespace->addClass('Edit')
->setExtends($rootNamespace . '\Controller\Adminhtml\\' . $entity);

if ($typehint) {
$namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity);
$namespace->addUse('\Magento\Framework\View\Result\PageFactory');
$namespace->addUse($entityClass . 'Factory');
}
$namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity);
$namespace->addUse('\Magento\Framework\View\Result\PageFactory');
$namespace->addUse($entityClass . 'Factory');

if (!$constructorProp) {
$factory = $class->addProperty('entityFactory')
Expand All @@ -39,13 +36,8 @@ public function genAdminEditController(
$result = $class->addProperty('resultPageFactory')
->setVisibility('private');

if ($typehint) {
$factory->setType($entityClass . 'Factory');
$result->setType('\Magento\Framework\View\Result\PageFactory');
} else {
$factory->addComment('@var ' . $entityClass . 'Factory');
$result->addComment('@var \Magento\Framework\View\Result\PageFactory');
}
$factory->setType($entityClass . 'Factory');
$result->setType('\Magento\Framework\View\Result\PageFactory');
}

$body = 'parent::__construct($repository, $coreRegistry, $context);';
Expand All @@ -56,19 +48,10 @@ public function genAdminEditController(
}
$construct = $class->addMethod('__construct')->setBody($body);

if ($typehint) {
$namespace
->addUse($repository)
->addUse('\Magento\Framework\Registry')
->addUse('\Magento\Backend\App\Action\Context');
} else {
$construct
->addComment('@param ' . $entityClass . 'Factory $entityFactory')
->addComment('@param \Magento\Framework\View\Result\PageFactory $resultPageFactory')
->addComment('@param ' . $repository . ' $repository')
->addComment('@param \Magento\Framework\Registry $coreRegistry')
->addComment('@param \Magento\Backend\App\Action\Context $context');
}
$namespace
->addUse($repository)
->addUse('\Magento\Framework\Registry')
->addUse('\Magento\Backend\App\Action\Context');

if ($constructorProp) {
$construct
Expand Down Expand Up @@ -126,12 +109,8 @@ public function genAdminEditController(
. 'return $resultPage;');
$namespace->addUse('\Magento\Framework\Exception\NoSuchEntityException');

if ($typehint) {
$execute->setReturnType('\Magento\Framework\Controller\ResultInterface');
$namespace->addUse('\Magento\Framework\Controller\ResultInterface');
} else {
$execute->addComment('@return \Magento\Framework\Controller\ResultInterface');
}
$execute->setReturnType('\Magento\Framework\Controller\ResultInterface');
$namespace->addUse('\Magento\Framework\Controller\ResultInterface');

return $namespace;
}
Expand Down
34 changes: 9 additions & 25 deletions src/Jeeves/Generators/Crud/Controllers/Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public function genAdminInlineController(
string $rootNamespace,
string $phpVersion = PHP_VERSION
): PhpNamespace {
$typehint = $this->hasTypes($phpVersion);
$constructorProp = $this->hasConstructorProp($phpVersion);
$readonlyProp = $this->hasReadOnlyProp($phpVersion);

Expand All @@ -25,11 +24,8 @@ public function genAdminInlineController(

if (!$constructorProp) {
$json = $class->addProperty('jsonFactory')->setVisibility('private');
if ($typehint) {
$json->setType('\Magento\Framework\Controller\Result\JsonFactory');
} else {
$json->addComment('@var \Magento\Framework\Controller\Result\JsonFactory');
}

$json->setType('\Magento\Framework\Controller\Result\JsonFactory');
}

$namespace->addUse('\Magento\Framework\Exception\NoSuchEntityException');
Expand All @@ -56,19 +52,11 @@ public function genAdminInlineController(
$construct->addParameter('coreRegistry')->setType('\Magento\Framework\Registry');
$construct->addParameter('context')->setType('\Magento\Backend\App\Action\Context');

if ($typehint) {
$namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity);
$namespace->addUse('\Magento\Framework\Controller\Result\JsonFactory');
$namespace->addUse($repository);
$namespace->addUse('\Magento\Framework\Registry');
$namespace->addUse('\Magento\Backend\App\Action\Context');
} else {
$construct
->addComment('@param \Magento\Framework\Controller\Result\JsonFactory $jsonFactory')
->addComment('@param ' . $repository . ' $repository')
->addComment('@param \Magento\Framework\Registry $coreRegistry')
->addComment('@param \Magento\Backend\App\Action\Context $context');
}
$namespace->addUse($rootNamespace . '\Controller\Adminhtml\\' . $entity);
$namespace->addUse('\Magento\Framework\Controller\Result\JsonFactory');
$namespace->addUse($repository);
$namespace->addUse('\Magento\Framework\Registry');
$namespace->addUse('\Magento\Backend\App\Action\Context');

$execute = $class->addMethod('execute')
->addComment('Execute action')
Expand Down Expand Up @@ -105,12 +93,8 @@ public function genAdminInlineController(
. self::TAB . '\'error\' => $error' . PHP_EOL
. ']);' . PHP_EOL);

if ($typehint) {
$execute->setReturnType('\Magento\Framework\Controller\ResultInterface');
$namespace->addUse('\Magento\Framework\Controller\ResultInterface');
} else {
$execute->addComment('@return \Magento\Framework\Controller\ResultInterface');
}
$execute->setReturnType('\Magento\Framework\Controller\ResultInterface');
$namespace->addUse('\Magento\Framework\Controller\ResultInterface');

return $namespace;
}
Expand Down
Loading

0 comments on commit 6bd99ee

Please sign in to comment.