Zend certified PHP/Magento developer

Magento 2.3.5 Incompatible argument type errors during compilation

I’m trying to compile after upgrade to magento 2.3.5-p1
and I get this error:

public_html$ php bin/magento setup:di:compile
The directory "/public_html/generated/code/Magento" cannot be deleted Warning!rmdir(/public_html/generated/code/Magento): Directory not empty
public_html$ php bin/magento setup:di:compile
Compilation was started.
Interception cache generation... 6/8 [=========>---]  75% 1 min 399.0 MiBErrors during compilation:
        PlumrocketAmpBlockCatalogProductWidgetCategory
                Incompatible argument type: Required type: MagentoCatalogApiCategoryRepositoryInterface. Actual type: array; File:
/public_html/app/code/Plumrocket/Amp/Block/Catalog/Product/Widget/Category.php

        PlumrocketAmpControllerApiStoreSwitchAction
                Missed required argument storeSwitcher in parent::__construct call. File: /public_html/app/code/Plumrocket/Amp/Controller/Api/Store/SwitchAction.php
Total Errors Count: 2

Category.php file:

< ?php
/**
* Plumrocket Inc.
* NOTICE OF LICENSE
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package     Plumrocket Amp v2.x.x
* @copyright   Copyright (c) 2018 Plumrocket Inc. (http://www.plumrocket.com)
* @license     http://wiki.plumrocket.net/wiki/EULA  End-user License Agreement
*/
namespace PlumrocketAmpBlockCatalogProductWidget;
use MagentoFrameworkExceptionLocalizedException;
/**
* Class ListSlider
*
* @method MagentoCatalogModelResourceModelProductCollection|null getProductCollection()
* @method integer|null getProductsCount()
* @method $this setProductsCount($number)
*/
class Category extends MagentoCatalogWidgetBlockProductProductsList implements MagentoWidgetBlockBlockInterface
{
/**
* Widget identificator
*/
const WIDGET_TYPE = 'amp_category_list';
/**
* This constant does not set the default value for the "Number of Products to Display" option
*/
const DEFAULT_PRODUCTS_COUNT = 5;
/**
* Default sort by for product collection and default value for option
*/
const DEFAULT_COLLECTION_SORT_BY = 'name';
/**
* Default sort order for product collection and default value for option
*/
const DEFAULT_COLLECTION_ORDER = 'asc';
/**
* Default value for option "Display Add To Cart Button"
*/
const DEFAULT_SHOW_ADD_TO_CART = false;
/**
* @var MagentoCatalogApiCategoryRepositoryInterface
*/
private $categoryRepository;
/**
* @var bool|null
*/
private $canShow;
/**
* @return string
*/
public function getType()
{
return self::WIDGET_TYPE;
}
/**
* Category constructor.
*
* @param MagentoCatalogBlockProductContext                         $context
* @param MagentoCatalogModelResourceModelProductCollectionFactory $productCollectionFactory
* @param MagentoCatalogModelProductVisibility                      $catalogProductVisibility
* @param MagentoFrameworkAppHttpContext                            $httpContext
* @param MagentoRuleModelConditionSqlBuilder                      $sqlBuilder
* @param MagentoCatalogWidgetModelRule                              $rule
* @param MagentoWidgetHelperConditions                              $conditionsHelper
* @param MagentoCatalogApiCategoryRepositoryInterface               $categoryRepository
* @param array                                                          $data
*/
public function __construct(
MagentoCatalogBlockProductContext $context,
MagentoCatalogModelResourceModelProductCollectionFactory $productCollectionFactory,
MagentoCatalogModelProductVisibility $catalogProductVisibility,
MagentoFrameworkAppHttpContext $httpContext,
MagentoRuleModelConditionSqlBuilder $sqlBuilder,
MagentoCatalogWidgetModelRule $rule,
MagentoWidgetHelperConditions $conditionsHelper,
MagentoCatalogApiCategoryRepositoryInterface $categoryRepository,
array $data = []
) {
parent::__construct(
$context,
$productCollectionFactory,
$catalogProductVisibility,
$httpContext,
$sqlBuilder,
$rule,
$conditionsHelper,
$data
);
$this->categoryRepository = $categoryRepository;
}
/**
* Retrieve product collection
*
* @return MagentoCatalogModelResourceModelProductCollection|null
*/
public function createCollection()
{
/** @var $collection MagentoCatalogModelResourceModelProductCollection */
$collection = $this->productCollectionFactory->create();
$collection = $this->_addProductAttributesAndPrices($collection)
->setVisibility($this->catalogProductVisibility->getVisibleInCatalogIds())
->addStoreFilter()
->setPageSize($this->getPageSize())
->setCurPage(1)
->setOrder($this->getSortBy(), $this->getSortOrder());
$collection->addCategoryFilter($this->getCategory());
return $collection;
}
/**
* @return bool|null
*/
private function canShow()
{
if (null === $this->canShow) {
$this->canShow = null !== $this->getCategory();
}
return $this->canShow;
}
/**
* Set default template for widget in cms page
*
* @return $this|MagentoCatalogWidgetBlockProductProductsList
*/
protected function _beforeToHtml()
{
if (! $this->canShow()) {
return $this;
}
if (! $this->getTemplate()) {
$this->setTemplate('Plumrocket_Amp::catalog/product/widget/items.phtml');
}
return parent::_beforeToHtml();
}
/**
* Disable render for invalid widgets
*
* @return string
*/
protected function _toHtml()
{
if (! $this->canShow()) {
return '';
}
return parent::_toHtml();
}
/**
* Add cache key info
*
* @return array|int
*/
public function getCacheKeyInfo()
{
$baseCacheKeyInfo = parent::getCacheKeyInfo();
array_push($baseCacheKeyInfo, self::WIDGET_TYPE, $this->_getWidgetParams(true));
return $baseCacheKeyInfo;
}
/**
* @param bool $toString
* @return array|string
*/
protected function _getWidgetParams($toString = false)
{
$params = [
$this->getCategoryId(),
$this->getSortBy(),
$this->getSortOrder(),
$this->showAddToCart()
];
return $toString ? implode('|', $params) : $params;
}
/**
* Get selected category
*
* @return null|MagentoCatalogApiDataCategoryInterface|MagentoCatalogModelCategory
*/
public function getCategory()
{
try {
return $this->categoryRepository->get($this->getCategoryId());
} catch (MagentoFrameworkExceptionNoSuchEntityException $e) {
return null;
} catch (LocalizedException $e) {
return null;
}
}
/**
* Retrieve count of products
*
* @return int
*/
public function hasItems()
{
return $this->getProductCollection()->getSize();
}
/**
* Retrieve number of products to display
*
* @return int
*/
public function getPageSize()
{
if ((int)$this->getProductsCount()) {
return (int)$this->getProductsCount();
}
return self::DEFAULT_PRODUCTS_COUNT;
}
/**
* Retrieve category id
*
* @return int
* @throws LocalizedException
*/
public function getCategoryId()
{
$catId = $this->getData('category');
if ($catId && strpos($catId, '/') !== false) {
$result = explode('/', $catId);
$catId = $result[1];
}
if (! (int)$catId || ! is_numeric($catId)) {
throw new LocalizedException(__('Category id is not valid'));
}
return (int)$catId;
}
/**
* Retrieve sort by: price, position and etc.
*
* @return mixed
*/
public function getSortBy()
{
if (! $this->hasData('sort_by')) {
$this->setData('sort_by', self::DEFAULT_COLLECTION_SORT_BY);
}
return $this->getData('sort_by');
}
/**
* Retrieve sort order: asc/desc
*
* @return string
*/
public function getSortOrder()
{
if (! $this->hasData('sort_order')) {
$this->setData('sort_order', self::DEFAULT_COLLECTION_ORDER);
}
return $this->getData('sort_order');
}
/**
* @return bool
*/
public function showAddToCart()
{
if (! $this->hasData('show_add_to_cart')) {
$this->setData('show_add_to_cart', self::DEFAULT_SHOW_ADD_TO_CART);
}
return (bool)$this->getData('show_add_to_cart');
}
}

SwitchAction.php file:

< ?php
/**
* Plumrocket Inc.
*
* NOTICE OF LICENSE
*
* This source file is subject to the End-user License Agreement
* that is available through the world-wide-web at this URL:
* http://wiki.plumrocket.net/wiki/EULA
* If you are unable to obtain it through the world-wide-web, please
* send an email to support@plumrocket.com so we can send you a copy immediately.
*
* @package     Plumrocket_Amp
* @copyright   Copyright (c) 2019 Plumrocket Inc. (http://www.plumrocket.com)
* @license     http://wiki.plumrocket.net/wiki/EULA  End-user License Agreement
*/
namespace PlumrocketAmpControllerApiStore;
use MagentoFrameworkAppActionContext as ActionContext;
use MagentoFrameworkAppHttpContext as HttpContext;
use MagentoFrameworkAppRequestInvalidRequestException;
use MagentoFrameworkAppRequestInterface;
use MagentoFrameworkExceptionNoSuchEntityException;
use MagentoStoreApiStoreCookieManagerInterface;
use MagentoStoreApiStoreRepositoryInterface;
use MagentoStoreModelStoreIsInactiveException;
use MagentoStoreModelStoreManagerInterface;
use MagentoStoreModelStoreSwitcherInterface;
use PlumrocketAmpModelResultAmpJson;
use PlumrocketAmpModelResultAmpJsonFactory;
use MagentoStoreModelStore;
class SwitchAction extends MagentoStoreControllerStoreSwitchAction implements
PlumrocketAmpModelMagentoTwoTwoCsrfAwareActionInterface
{
use PlumrocketAmpControllerValidateForCsrfTrait;
/**
* @var AmpJsonFactory
*/
private $ampResultFactory;
/**
* SwitchAction constructor.
*
* @param ActionContext                               $context
* @param StoreCookieManagerInterface                 $storeCookieManager
* @param HttpContext                                 $httpContext
* @param StoreRepositoryInterface                    $storeRepository
* @param StoreManagerInterface                       $storeManager
* @param AmpJsonFactory $ampResultFactory
*/
public function __construct(
ActionContext $context,
StoreCookieManagerInterface $storeCookieManager,
HttpContext $httpContext,
StoreRepositoryInterface $storeRepository,
StoreManagerInterface $storeManager,
AmpJsonFactory $ampResultFactory
) {
parent::__construct(
$context,
$storeCookieManager,
$httpContext,
$storeRepository,
$storeManager
);
$this->ampResultFactory = $ampResultFactory;
}
/**
* @return AmpJson
*/
public function execute() : AmpJson
{
$ampJsonResult = $this->ampResultFactory->create();
$currentActiveStore = $this->storeManager->getStore();
$targetStoreCode = $this->_request->getParam(
'___store',
$this->storeCookieManager->getStoreCodeFromCookie()
);
$fromStoreCode = $this->_request->getParam('___from_store');
$error = null;
try {
$fromStore = $this->storeRepository->get($fromStoreCode);
$targetStore = $this->storeRepository->getActiveStoreByCode($targetStoreCode);
} catch (StoreIsInactiveException $e) {
$error = __('Requested store is inactive');
} catch (NoSuchEntityException $e) {
$error = __("The store that was requested wasn't found. Verify the store and try again.");
}
if ($error !== null) {
$ampJsonResult->addErrorMessage($error);
} else {
$defaultStoreView = $this->storeManager->getDefaultStoreView();
if ($defaultStoreView->getId() == $targetStore->getId()) {
$this->storeCookieManager->deleteStoreCookie($targetStore);
} else {
$this->httpContext->setValue(Store::ENTITY, $targetStore->getCode(), $defaultStoreView->getCode());
$this->storeCookieManager->setStoreCookie($targetStore);
}
if ($targetStore->isUseStoreInUrl()) {
// Change store code in redirect url
if (strpos($this->_redirect->getRedirectUrl(), $currentActiveStore->getBaseUrl()) !== false) {
$redirectUrl = str_replace(
$currentActiveStore->getBaseUrl(),
$targetStore->getBaseUrl(),
$this->_redirect->getRedirectUrl()
);
} else {
$redirectUrl = $targetStore->getBaseUrl();
}
} else {
$redirectUrl = $this->_redirect->getRedirectUrl();
}
$ampJsonResult->setFormRedirect($redirectUrl);
}
return $ampJsonResult;
}
}

any idea how to slove the issue?
Thanks,
Kobi