Skip to content

Commit

Permalink
Fix errors in code instead ignore in PHPStan (algolia#878)
Browse files Browse the repository at this point in the history
  • Loading branch information
vmalyk authored and damcou committed Oct 15, 2019
1 parent f6e0470 commit e784ae4
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 24 deletions.
3 changes: 3 additions & 0 deletions Block/Navigation/Renderer/CategoryRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class CategoryRenderer extends Template implements FilterRendererInterface
/** @var string */
protected $_template = 'Algolia_AlgoliaSearch::layer/filter/category.phtml';

/** @var FilterInterface */
protected $filter;

public function isMultipleSelectEnabled()
{
return false;
Expand Down
3 changes: 3 additions & 0 deletions Block/Navigation/Renderer/DefaultRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ class DefaultRenderer extends Template implements FilterRendererInterface
/** @var ConfigHelper */
private $configHelper;

/** @var FilterInterface */
protected $filter;

/**
* Constructor.
*
Expand Down
3 changes: 3 additions & 0 deletions Block/Navigation/Renderer/SliderRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class SliderRenderer extends Template implements FilterRendererInterface
/** @var FormatInterface */
protected $localeFormat;

/** @var FilterInterface */
protected $filter;

/**
*
* @param Context $context
Expand Down
2 changes: 0 additions & 2 deletions Controller/Adminhtml/Landingpage/Duplicate.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ private function copyQueryRules($landingPageFromId, $landingPageToId)
$stores[] = $store->getId();
}
}
} else {
$stores[] = $data['store_id'];
}

foreach ($stores as $storeId) {
Expand Down
14 changes: 10 additions & 4 deletions Controller/Adminhtml/Query/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Algolia\AlgoliaSearch\Helper\MerchandisingHelper;
use Algolia\AlgoliaSearch\Helper\ProxyHelper;
use Algolia\AlgoliaSearch\Model\ImageUploader;
use Algolia\AlgoliaSearch\Model\QueryFactory;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\Controller\ResultFactory;
Expand All @@ -17,6 +18,11 @@ class Save extends AbstractAction
*/
protected $dataPersistor;

/**
* @var ImageUploader
*/
protected $imageUploader;

/**
* PHP Constructor
*
Expand All @@ -27,6 +33,7 @@ class Save extends AbstractAction
* @param ProxyHelper $proxyHelper
* @param StoreManagerInterface $storeManager
* @param DataPersistorInterface $dataPersistor
* @param ImageUploader $imageUploader
*
* @return Save
*/
Expand All @@ -37,9 +44,11 @@ public function __construct(
MerchandisingHelper $merchandisingHelper,
ProxyHelper $proxyHelper,
StoreManagerInterface $storeManager,
DataPersistorInterface $dataPersistor
DataPersistorInterface $dataPersistor,
ImageUploader $imageUploader
) {
$this->dataPersistor = $dataPersistor;
$this->imageUploader = $imageUploader;

parent::__construct(
$context,
Expand Down Expand Up @@ -84,9 +93,6 @@ public function execute()

if (isset($data['banner_image'][0]['name']) && isset($data['banner_image'][0]['tmp_name'])) {
$data['banner_image'] = $data['banner_image'][0]['name'];
$this->imageUploader = \Magento\Framework\App\ObjectManager::getInstance()->get(
'Algolia\AlgoliaSearch\QueryImageUpload'
);
$this->imageUploader->moveFileFromTmp($data['banner_image']);
} elseif (isset($data['banner_image'][0]['image']) && !isset($data['banner_image'][0]['tmp_name'])) {
$data['banner_image'] = $data['banner_image'][0]['image'];
Expand Down
4 changes: 2 additions & 2 deletions Controller/Adminhtml/Queue/AbstractAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function _isAllowed()
return $this->_authorization->isAllowed('Algolia_AlgoliaSearch::manage');
}

/** @return \Algolia\AlgoliaSearch\Model */
/** @return \Algolia\AlgoliaSearch\Model\Job */
protected function initJob()
{
$jobId = (int) $this->getRequest()->getParam('id');
Expand All @@ -68,7 +68,7 @@ protected function initJob()
return null;
}

/** @var \Algolia\AlgoliaSearch\Model $model */
/** @var \Algolia\AlgoliaSearch\Model\Job $model */
$model = $this->jobFactory->create();
$this->jobResourceModel->load($model, $jobId);
if (!$model->getId()) {
Expand Down
2 changes: 1 addition & 1 deletion Model/Layer/Filter/Decimal.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function _getItemsData()
if (mb_strpos($key, '_') === false) {
continue;
}
$data[] = $this->prepareData($key, $count, $data);
$data[] = $this->prepareData($key, $count);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Model/Layer/Filter/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected function _getItemsData()
if (mb_strpos($key, '_') === false) {
continue;
}
$data[] = $this->prepareData($key, $count, $data);
$data[] = $this->prepareData($key, $count);
}
}

Expand Down
11 changes: 7 additions & 4 deletions Plugin/BackendFilterRendererPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ class BackendFilterRendererPlugin
/** @var LayoutInterface */
protected $layout;

/** @var StoreManagerInterface */
protected $storeManager;

/** @var ConfigHelper */
protected $configHelper;

/** @var string */
protected $defaultBlock = \Algolia\AlgoliaSearch\Block\Navigation\Renderer\DefaultRenderer::class;

Expand All @@ -23,9 +29,6 @@ class BackendFilterRendererPlugin
/** @var string */
protected $sliderBlock = \Algolia\AlgoliaSearch\Block\Navigation\Renderer\SliderRenderer::class;

/** @var ConfigHelper */
private $configHelper;

/**
* @param LayoutInterface $layout
* @param StoreManagerInterface $storeManager
Expand All @@ -37,8 +40,8 @@ public function __construct(
ConfigHelper $configHelper
) {
$this->layout = $layout;
$this->configHelper = $configHelper;
$this->storeManager = $storeManager;
$this->configHelper = $configHelper;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,9 @@
<argument name="imageUploader" xsi:type="object">Algolia\AlgoliaSearch\QueryImageUpload</argument>
</arguments>
</type>
<type name="Algolia\AlgoliaSearch\Controller\Adminhtml\Query\Save">
<arguments>
<argument name="imageUploader" xsi:type="object">Algolia\AlgoliaSearch\QueryImageUpload</argument>
</arguments>
</type>
</config>
11 changes: 1 addition & 10 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,4 @@ parameters:
- '#(class|type) Magento\\\S*Factory#i'
- '#(class|type) Algolia\\\S*Factory#i'
- '#Call to static method getObjectManager\(\) on an unknown class Magento\\TestFramework\\Helper\\Bootstrap.#'
- '#Access to an undefined property Algolia\\AlgoliaSearch\\Plugin\\BackendFilterRendererPlugin::\$storeManager.#'
- '#Method Algolia\\AlgoliaSearch\\Model\\Layer\\Filter\\Price::prepareData\(\) invoked with 3 parameters, 2 required.#'
- '#Method Algolia\\AlgoliaSearch\\Model\\Layer\\Filter\\Decimal::prepareData\(\) invoked with 3 parameters, 2 required.#'
- '#Parameter \$clientFactory of method Algolia\\AlgoliaSearch\\Helper\\AlgoliaHelper::__construct\(\) has invalid typehint type AlgoliaSearch\\ClientFactory.#'
- '#Return typehint of method Algolia\\AlgoliaSearch\\Controller\\Adminhtml\\Queue\\AbstractAction::initJob\(\) has invalid type Algolia\\AlgoliaSearch\\Model.#'
- '#Access to an undefined property Algolia\\AlgoliaSearch\\Controller\\Adminhtml\\Query\\Save::\$imageUploader.#'
- '#Undefined variable: \$data#'
- '#Access to an undefined property Algolia\\AlgoliaSearch\\Block\\Navigation\\Renderer\\SliderRenderer::\$filter.#'
- '#Access to an undefined property Algolia\\AlgoliaSearch\\Block\\Navigation\\Renderer\\DefaultRenderer::\$filter.#'
- '#Access to an undefined property Algolia\\AlgoliaSearch\\Block\\Navigation\\Renderer\\CategoryRenderer::\$filter.#'
- '#Parameter \$clientFactory of method Algolia\\AlgoliaSearch\\Helper\\AlgoliaHelper::__construct\(\) has invalid typehint type AlgoliaSearch\\ClientFactory.#'

0 comments on commit e784ae4

Please sign in to comment.