Skip to content

Commit 1214066

Browse files
committed
Fix PHPStan level 2
1 parent 363fead commit 1214066

File tree

8 files changed

+29
-8
lines changed

8 files changed

+29
-8
lines changed

DataLayer/Mapper/OrderItemDataMapper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ private function getPrice(OrderItemInterface $orderItem): float
108108
}
109109

110110
/**
111-
* @param ProductInterface $product
112-
* @param array $data
111+
* @param OrderItemInterface $orderItem
112+
* @param array $data
113+
*
113114
* @return array
114115
*/
115116
private function parseDataLayerMapping(OrderItemInterface $orderItem, array $data): array

DataLayer/Tag/Category/Products.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function __construct(
4343
*/
4444
public function get(): array
4545
{
46+
/** @var Category $category */
4647
$category = $this->getCurrentCategory->get();
4748
if ($category->getDisplayMode() === Category::DM_PAGE) {
4849
return [];

Test/Integration/Block/DataLayerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ public function testValidBlockContent()
2929
$layout = ObjectManager::getInstance()->get(LayoutInterface::class);
3030
$layout->getUpdate()->addHandle('datalayer_default');
3131

32+
/** @var Template $block */
3233
$block = $layout->createBlock(Template::class);
3334
$block->setNameInLayout('yireo_googletagmanager2.data-layer');
34-
$block->setTemplate('Yireo_GoogleTagManager2::luma/data-layer.phtml');
35+
$block->setTemplate('Yireo_GoogleTagManager2::luma/data-layer.phtml'); // @phpstan-ignore-line
3536
$block->setData('data_layer_view_model', ObjectManager::getInstance()->get(DataLayer::class));
3637
$block->setData('config', ObjectManager::getInstance()->get(Config::class));
3738
$html = $block->toHtml();

Test/Integration/Page/AddToWishlistTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Yireo\GoogleTagManager2\Test\Integration\Page;
44

55
use Magento\Catalog\Api\ProductRepositoryInterface;
6+
use Magento\Catalog\Model\Product;
67
use Magento\Customer\CustomerData\SectionPool;
78
use Magento\Framework\App\Request\Http as HttpRequest;
89
use Magento\Framework\App\Response\Http as HttpResponse;
@@ -33,6 +34,8 @@ public function testAddToWishlist()
3334
$this->loginCustomer();
3435

3536
$productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
37+
38+
/** @var Product $product */
3639
$product = $productRepository->get('simple');
3740
$product->setData('is_saleable', 1);
3841
$productRepository->save($product);

Test/Integration/Page/CategoryPageTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
use Magento\Catalog\Api\Data\CategoryInterface;
88
use Magento\Catalog\Block\Product\ListProduct;
9+
use Magento\Catalog\Model\Category;
10+
use Magento\CatalogWidget\Block\Product\ProductsList;
11+
use Magento\Eav\Model\Entity\Collection\AbstractCollection;
12+
use Magento\Framework\App\Response\Http;
913
use Yireo\GoogleTagManager2\Test\Integration\FixtureTrait\GetCategory;
1014
use Yireo\GoogleTagManager2\Test\Integration\FixtureTrait\Reindex;
1115
use Yireo\GoogleTagManager2\Test\Integration\PageTestCase;
@@ -35,18 +39,23 @@ public function testValidDataLayerWithOneCategory()
3539
{
3640
$this->assertEnabledFlagIsWorking();
3741

42+
/** @var Category $category */
3843
$category = $this->getCategoryByName('Category 999');
3944

45+
/** @var AbstractCollection $productCollection */
4046
$productCollection = $category->getProductCollection();
4147
$this->assertTrue($productCollection->count() >= 3, 'Product count is '.$productCollection->count());
4248

4349
$this->dispatch('catalog/category/view/id/' . $category->getId());
4450
$this->assertRequestActionName('view');
4551

46-
$body = $this->getResponse()->getBody();
52+
/** @var Http $response */
53+
$response = $this->getResponse();
54+
$body = $response->getBody();
4755
$this->assertStringContainsString($category->getName(), $body);
4856
$this->assertStringContainsString('"view_item_list"', $body);
4957

58+
/** @var ListProduct $productListBlock */
5059
$productListBlock = $this->layout->getBlock('category.products.list');
5160
$productListBlock->setCollection($productCollection);
5261
$this->assertInstanceOf(ListProduct::class, $productListBlock);
@@ -82,7 +91,7 @@ public function testValidDataLayerWithOneCategory()
8291
}
8392
}
8493

85-
private function getProductsByCategory(CategoryInterface $category): array
94+
private function getProductsByCategory(Category $category): array
8695
{
8796
return $category->getProductCollection()->toArray();
8897
}

Test/Integration/Page/CheckoutOnepageSuccessTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Magento\Framework\View\Result\PageFactory;
88
use Magento\Sales\Api\Data\OrderInterface;
99
use Magento\Sales\Api\OrderRepositoryInterface;
10+
use Magento\Sales\Model\Order;
1011
use Yireo\GoogleTagManager2\Test\Integration\PageTestCase;
1112

1213
class CheckoutOnepageSuccessTest extends PageTestCase
@@ -74,6 +75,8 @@ private function getOrder(): OrderInterface
7475
$searchResult = $orderRepository->getList($searchCriteriaBuilder->create());
7576
$orders = $searchResult->getItems();
7677
$this->assertNotEmpty($orders);
78+
79+
/** @var Order $order */
7780
$order = array_pop($orders);
7881
$this->assertNotEmpty($order);
7982
$this->assertNotEmpty($order->getId());

Test/Integration/Page/ProductPageTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Magento\Catalog\Api\ProductRepositoryInterface;
66
use Magento\Framework\App\ObjectManager;
7+
use Magento\Framework\App\Response\Http;
78
use Yireo\GoogleTagManager2\Test\Integration\FixtureTrait\GetProduct;
89
use Yireo\GoogleTagManager2\Test\Integration\PageTestCase;
910
use Yireo\IntegrationTestHelper\Test\Integration\Traits\Layout\AssertHandleInLayout;
@@ -35,7 +36,9 @@ public function testValidDataLayerWithOneCategory()
3536
$this->dispatch('catalog/product/view/id/' . $product->getId());
3637
$this->assertRequestActionName('view');
3738

38-
$body = $this->getResponse()->getBody();
39+
/** @var Http $response */
40+
$response = $this->getResponse();
41+
$body = $response->getBody();
3942
$this->assertStringContainsString($product->getName(), $body);
4043

4144
$block = $this->layout->getBlock('yireo_googletagmanager2.data-layer');

Test/Integration/SessionDataProvider/CustomerSessionDataProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public function testSettingOnce()
2323
$this->getRequest()->setParams(['sections' => 'customer']);
2424
$this->dispatch('customer/section/load');
2525
$body = $this->getResponse()->getBody(); // @phpstan-ignore-line
26-
$data = $serializer->unserialize($body, true);
26+
$data = $serializer->unserialize($body);
2727
$this->assertEquals('bar', $data['customer']['gtm_events']['foobar']['foo']);
2828

2929
$this->getRequest()->setParams(['sections' => 'customer']);
3030
$this->dispatch('customer/section/load');
3131
$body = $this->getResponse()->getBody(); // @phpstan-ignore-line
32-
$data = $serializer->unserialize($body, true);
32+
$data = $serializer->unserialize($body);
3333
$this->assertEmpty($data['customer']['gtm_events']);
3434
}
3535
}

0 commit comments

Comments
 (0)