From 7cbd997ad743630499a4ca5f5295ec69b1c39546 Mon Sep 17 00:00:00 2001 From: Dominic Watts Date: Tue, 5 May 2020 23:56:38 +0100 Subject: [PATCH 1/4] Testing --- .github/workflows/phpcompatibility.yml | 9 +++++++++ .github/workflows/phpcs.yml | 9 +++++++++ .github/workflows/phpstan.yml | 14 ++++++++++++++ .gitignore | 3 +++ composer.json | 2 +- etc/module.xml | 2 +- phpstan.neon | 13 +++++++++++++ 7 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/phpcompatibility.yml create mode 100644 .github/workflows/phpcs.yml create mode 100644 .github/workflows/phpstan.yml create mode 100644 .gitignore create mode 100644 phpstan.neon diff --git a/.github/workflows/phpcompatibility.yml b/.github/workflows/phpcompatibility.yml new file mode 100644 index 0000000..195177d --- /dev/null +++ b/.github/workflows/phpcompatibility.yml @@ -0,0 +1,9 @@ +name: PHPCompatibility +on: [push] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: 7.0-7.3 + run: docker run --rm -v $PWD:/code domw/phpcompatibility phpcs --standard=PHPCompatibility --runtime-set testVersion 7.0-7.3 --colors --warning-severity=0 --report=full,summary --extensions=php,phtml ./ diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml new file mode 100644 index 0000000..3a5ecd5 --- /dev/null +++ b/.github/workflows/phpcs.yml @@ -0,0 +1,9 @@ +name: phpcs +on: [push] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Magento 2 Ruleset + run: docker run --rm -v $PWD:/code domw/phpcs phpcs --colors --standard=Magento2 --report=full,summary,gitblame --extensions=php,phtml ./ diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..417ac56 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,14 @@ +name: PHPStan +on: [push] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: MilesChou/composer-action@master + env: + COMPOSER_AUTH: ${{secrets.COMPOSER_AUTH}} + with: + args: install --prefer-dist --no-dev --ignore-platform-reqs + - name: PHPStan + run: docker run --rm -v $PWD:/code domw/phpstan phpstan analyze ./ \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6ad7c3c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/vendor +/.idea +/.vscode \ No newline at end of file diff --git a/composer.json b/composer.json index ced7e0c..1977fb5 100755 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Special offers landing page with layered navigation and widget", "type": "magento2-module", "license": "proprietary", - "version": "1.1.6", + "version": "1.1.7", "authors": [ { "name": "Dominic Xigen", diff --git a/etc/module.xml b/etc/module.xml index 41f5af8..2a02ace 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,5 +1,5 @@ - + diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..0160b32 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,13 @@ +parameters: + level: 1 + autoload_directories: + - Block + - Controller + - Model + - view + excludes_analyse: + - 'vendor' + ignoreErrors: + - '#invalid typehint#' + - '#unknown class#' + reportUnmatchedIgnoredErrors: false \ No newline at end of file From 1b837f23154d65963751923d8c48dcc9179b3be1 Mon Sep 17 00:00:00 2001 From: Dominic Watts Date: Wed, 6 May 2020 00:17:13 +0100 Subject: [PATCH 2/4] Fixes --- Block/Link.php | 3 +- Block/Widget/Special.php | 3 +- Model/Layer.php | 2 +- Model/Layer/Resolver.php | 2 +- composer.json | 4 +- phpstan.neon | 2 +- .../special/column/special_default_list.phtml | 36 ++++++----- .../special/column/special_images_list.phtml | 4 +- .../special/column/special_names_list.phtml | 6 +- .../widget/special/content/special_grid.phtml | 43 +++++++------ .../widget/special/content/special_list.phtml | 61 ++++++++++--------- 11 files changed, 91 insertions(+), 75 deletions(-) diff --git a/Block/Link.php b/Block/Link.php index 681cf1b..d33ca00 100755 --- a/Block/Link.php +++ b/Block/Link.php @@ -3,8 +3,7 @@ namespace Xigen\Special\Block; /** - * Class Link - * @package Xigen\Testimonial\Block + * Xigen Special header block link class */ class Link extends \Magento\Framework\View\Element\Html\Link { diff --git a/Block/Widget/Special.php b/Block/Widget/Special.php index c81b5ba..1253aec 100644 --- a/Block/Widget/Special.php +++ b/Block/Widget/Special.php @@ -3,7 +3,7 @@ namespace Xigen\Special\Block\Widget; /** - * Special Widget class + * Xigen Special Widget block class */ class Special extends \Magento\Catalog\Block\Product\NewProduct implements \Magento\Widget\Block\BlockInterface { @@ -19,7 +19,6 @@ class Special extends \Magento\Catalog\Block\Product\NewProduct implements \Mage /** * Name of request parameter for page number value - * @deprecated */ const PAGE_VAR_NAME = 'fp'; diff --git a/Model/Layer.php b/Model/Layer.php index aff4cee..2e509b6 100755 --- a/Model/Layer.php +++ b/Model/Layer.php @@ -7,7 +7,7 @@ use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; /** - * Layer class + * Xigen Special Layer model class */ class Layer extends \Magento\Catalog\Model\Layer { diff --git a/Model/Layer/Resolver.php b/Model/Layer/Resolver.php index c149033..1cc89a3 100755 --- a/Model/Layer/Resolver.php +++ b/Model/Layer/Resolver.php @@ -3,7 +3,7 @@ namespace Xigen\Special\Model\Layer; /** - * Resolver class + * Xigen Special model layer resolver class */ class Resolver extends \Magento\Catalog\Model\Layer\Resolver { diff --git a/composer.json b/composer.json index 1977fb5..51f6bf1 100755 --- a/composer.json +++ b/composer.json @@ -19,7 +19,9 @@ ], "require": { "magento/framework": "*", - "php": "~7.0.0||~7.1.0||~7.2.0||~7.3.0" + "php": "~7.0.0||~7.1.0||~7.2.0||~7.3.0", + "magento/module-layered-navigation": "*", + "magento/module-catalog": "*" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon index 0160b32..9949c98 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: 1 + level: 0 autoload_directories: - Block - Controller diff --git a/view/frontend/templates/product/widget/special/column/special_default_list.phtml b/view/frontend/templates/product/widget/special/column/special_default_list.phtml index 9d67544..7ba6a09 100755 --- a/view/frontend/templates/product/widget/special/column/special_default_list.phtml +++ b/view/frontend/templates/product/widget/special/column/special_default_list.phtml @@ -4,11 +4,14 @@ * See COPYING.txt for license details. */ -// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis -// phpcs:disable Magento2.Files.LineLength.MaxExceeded +// phpcs:disable Magento2.Templates.ThisInTemplate +// phpcs:disable Generic.Files.LineLength.TooLong + +use Magento\Catalog\Helper\Output; +use Magento\Framework\Data\Helper\PostHelper; ?> -getProductCollection()) && $_products->getSize()) : ?> +getProductCollection()) && $_products->getSize()): ?>
escapeHtml(__('Special Offers')) ?> @@ -17,7 +20,7 @@ getNameInLayout(); ?>
    - getItems() as $_product) : ?> + getItems() as $_product): ?> ' : '
  1. ' ?>
    - helper(Magento\Catalog\Helper\Output::class)->productAttribute($_product, $_product->getName(), 'name') ?> + helper(Output::class)->productAttribute($_product, $_product->getName(), 'name') ?> getProductPriceHtml($_product, '-widget-special-' . $suffix) ?>
    - isSaleable()) : ?> - getTypeInstance()->hasRequiredOptions($_product)) : ?> + isSaleable()): ?> + getTypeInstance()->hasRequiredOptions($_product)): ?> - + helper(Magento\Framework\Data\Helper\PostHelper::class); + $postDataHelper = $this->helper(PostHelper::class); $postData = $postDataHelper->getPostData($block->escapeUrl($block->getAddToCartUrl($_product)), ['product' => $_product->getEntityId()]); ?> - - - getIsSalable()) : ?> -
    + + getIsSalable()): ?> +
    escapeHtml(__('In stock')) ?>
    - -
    + +
    escapeHtml(__('Out of stock')) ?>
    diff --git a/view/frontend/templates/product/widget/special/column/special_images_list.phtml b/view/frontend/templates/product/widget/special/column/special_images_list.phtml index d150de9..c8079d4 100755 --- a/view/frontend/templates/product/widget/special/column/special_images_list.phtml +++ b/view/frontend/templates/product/widget/special/column/special_images_list.phtml @@ -5,7 +5,7 @@ */ ?> -getProductCollection()) && $_products->getSize()) : ?> +getProductCollection()) && $_products->getSize()): ?>
    escapeHtml(__('Special Offers')) ?> @@ -14,7 +14,7 @@ getNameInLayout(); ?>
      - getItems() as $_product) : ?> + getItems() as $_product): ?>
    1. diff --git a/view/frontend/templates/product/widget/special/column/special_names_list.phtml b/view/frontend/templates/product/widget/special/column/special_names_list.phtml index 43de438..3645910 100755 --- a/view/frontend/templates/product/widget/special/column/special_names_list.phtml +++ b/view/frontend/templates/product/widget/special/column/special_names_list.phtml @@ -4,9 +4,9 @@ * See COPYING.txt for license details. */ -// phpcs:disable Magento2.Templates.ThisInTemplate.FoundThis +// phpcs:disable Magento2.Templates.ThisInTemplate ?> -getProductCollection()) && $_products->getSize()) : ?> +getProductCollection()) && $_products->getSize()): ?>
      escapeHtml(__('Special Offers')) ?> @@ -15,7 +15,7 @@ getNameInLayout(); ?>
        - getItems() as $_product) : ?> + getItems() as $_product): ?>
      1. getProductCollection() && $block->getProductCollection()->getSize())) { $type = 'widget-special-grid'; @@ -31,7 +31,7 @@ if ($exist = ($block->getProductCollection() && $block->getProductCollection()-> } ?> - +
        escapeHtml($title) ?> @@ -41,10 +41,11 @@ if ($exist = ($block->getProductCollection() && $block->getProductCollection()->
          - + ' : '
        1. ' ?>
          - + getImage($_item, $image)->toHtml() ?>
          @@ -57,23 +58,23 @@ if ($exist = ($block->getProductCollection() && $block->getProductCollection()-> getProductPriceHtml($_item, $type); ?> - + getReviewsSummaryHtml($_item, $templateType) ?> - +
          - +
          - isSaleable()) : ?> - getTypeInstance()->hasRequiredOptions($_item)) : ?> + isSaleable()): ?> + getTypeInstance()->hasRequiredOptions($_item)): ?> - + helper(Magento\Framework\Data\Helper\PostHelper::class); $postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()]) @@ -85,18 +86,22 @@ if ($exist = ($block->getProductCollection() && $block->getProductCollection()-> escapeHtml(__('Add to Cart')) ?> - - getIsSalable()) : ?> -
          escapeHtml(__('In stock')) ?>
          - -
          escapeHtml(__('Out of stock')) ?>
          + + getIsSalable()): ?> +
          + escapeHtml(__('In stock')) ?> +
          + +
          + escapeHtml(__('Out of stock')) ?> +
          - +
          - helper(Magento\Wishlist\Helper\Data::class)->isAllow() && $showWishlist) : ?> + helper(Magento\Wishlist\Helper\Data::class)->isAllow() && $showWishlist): ?> getProductCollection() && $block->getProductCollection()-> escapeHtml(__('Add to Wish List')) ?> - getAddToCompareUrl() && $showCompare) : ?> + getAddToCompareUrl() && $showCompare): ?> helper(Magento\Catalog\Helper\Product\Compare::class);?> -getProductCollection() && $block->getProductCollection()-> } ?> - +
          escapeHtml($title) ?> @@ -42,7 +40,7 @@ if ($exist = ($block->getProductCollection() && $block->getProductCollection()->
            - + ' : '
          1. ' ?>
            getProductCollection() && $block->getProductCollection()-> getProductPriceHtml($_item, $type) ?> - + getReviewsSummaryHtml($_item, $templateType) ?> - +
            - +
            - isSaleable()) : ?> - getTypeInstance()->hasRequiredOptions($_item)) : ?> + isSaleable()): ?> + getTypeInstance()->hasRequiredOptions($_item)): ?> - + helper(Magento\Framework\Data\Helper\PostHelper::class); - $postData = $postDataHelper->getPostData($block->getAddToCartUrl($_item), ['product' => $_item->getEntityId()]) + $postDataHelper = $this->helper(PostHelper::class); + $postData = $postDataHelper->getPostData( + $block->getAddToCartUrl($_item), + ['product' => $_item->getEntityId()] + ) ?> - - getIsSalable()) : ?> -
            escapeHtml(__('In stock')) ?>
            - -
            escapeHtml(__('Out of stock')) ?>
            + + getIsSalable()): ?> +
            + escapeHtml(__('In stock')) ?> +
            + +
            + escapeHtml(__('Out of stock')) ?> +
            - +
            - +
            productAttribute( $_item, From 2aee3a435b9e4d92d727b5965865e09d46a33905 Mon Sep 17 00:00:00 2001 From: Dominic Watts Date: Wed, 6 May 2020 00:22:25 +0100 Subject: [PATCH 3/4] Comment --- Controller/Index/Index.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Controller/Index/Index.php b/Controller/Index/Index.php index e1f75c9..218b10a 100755 --- a/Controller/Index/Index.php +++ b/Controller/Index/Index.php @@ -25,6 +25,10 @@ public function __construct( return parent::__construct($context); } + /** + * Execute view action + * @return \Magento\Framework\Controller\ResultInterface + */ public function execute() { $resultPage = $this->pageFactory->create(); From 19338eed4eb6674f483431b19cb4f470a62ac6e7 Mon Sep 17 00:00:00 2001 From: Dominic Watts Date: Wed, 6 May 2020 00:25:21 +0100 Subject: [PATCH 4/4] Remove return statement --- Controller/Index/Index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/Index/Index.php b/Controller/Index/Index.php index 218b10a..2445489 100755 --- a/Controller/Index/Index.php +++ b/Controller/Index/Index.php @@ -22,7 +22,7 @@ public function __construct( \Magento\Framework\View\Result\PageFactory $pageFactory ) { $this->pageFactory = $pageFactory; - return parent::__construct($context); + parent::__construct($context); } /**