Skip to content

Commit 6cae6dc

Browse files
authored
Merge pull request #49 from stape-io/feature/fix-php84-compatibility
Added PHP8.4 compatibility
2 parents 9652d7a + a4ec064 commit 6cae6dc

File tree

19 files changed

+70
-32
lines changed

19 files changed

+70
-32
lines changed

Block/Adminhtml/System/Config/CustomLoader.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@ protected function _getElementHtml(AbstractElement $element)
3838
->setElementHtml($elementHtml)
3939
->toHtml();
4040
}
41-
4241
}

Block/Gtm.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Gtm extends \Magento\Framework\View\Element\Template
2525
*
2626
* @param Template\Context $context
2727
* @param ConfigProvider $configProvider
28+
* @param EventFormatter $eventFormatter
2829
* @param array $data
2930
*/
3031
public function __construct(

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
v1.0.28
4+
- added PHP 8.4 compatibility;
5+
- fixed code style;
6+
37
v1.0.27
48
- added option to enable/disable '_stape' suffix in Datalayer events;
59

Model/Backend/CodeSnippet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function __construct(
3535
ScopeConfigInterface $config,
3636
TypeListInterface $cacheTypeList,
3737
Gtm $gtm,
38-
AbstractResource $resource = null,
39-
AbstractDb $resourceCollection = null,
38+
?AbstractResource $resource = null,
39+
?AbstractDb $resourceCollection = null,
4040
array $data = []
4141
) {
4242
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);

Model/Backend/CustomLoader.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class CustomLoader extends \Magento\Framework\App\Config\Value
3939
* @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
4040
* @param RandomString $randomString
4141
* @param RandomSuffix $randomSuffix
42-
* @param \Magento\Framework\Serialize\Serializer\Json $jsonSerializer
4342
* @param \Magento\Config\Model\ConfigFactory $configFactory
43+
* @param \Magento\Framework\Serialize\Serializer\Json $jsonSerializer
4444
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
4545
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
4646
* @param array $data
@@ -54,8 +54,8 @@ public function __construct(
5454
\Stape\Gtm\Model\Data\RandomSuffix $randomSuffix,
5555
\Magento\Config\Model\ConfigFactory $configFactory,
5656
\Magento\Framework\Serialize\Serializer\Json $jsonSerializer,
57-
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
58-
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
57+
?\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
58+
?\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
5959
array $data = []
6060
) {
6161
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
@@ -90,7 +90,9 @@ protected function saveLoaderPrefix()
9090
*/
9191
protected function saveContainerIdParams()
9292
{
93+
// phpcs:disable
9394
parse_str($this->randomSuffix->generate($this->getValue()), $suffix);
95+
// phpcs:enable
9496
$value = $this->jsonSerializer->serialize([
9597
'prefix' => $this->randomString->generate(),
9698
'suffix' => $suffix,
@@ -138,7 +140,11 @@ public function afterSave()
138140

139141
try {
140142

141-
$prefix = $this->_config->getValue(ConfigProvider::XPATH_GTM_LOADER_PREFIX, $this->getScope(), $this->getScopeId());
143+
$prefix = $this->_config->getValue(
144+
ConfigProvider::XPATH_GTM_LOADER_PREFIX,
145+
$this->getScope(),
146+
$this->getScopeId()
147+
);
142148

143149
if (!empty($loader) && empty($prefix)) {
144150
$this->saveLoaderPrefix();
@@ -157,11 +163,9 @@ public function afterSave()
157163
if (strlen($this->getValue() ?? '') < 1) {
158164
$this->resetLinkedOptions();
159165
}
160-
166+
return parent::afterSave();
161167
} catch (\Throwable $e) {
162-
168+
return parent::afterSave();
163169
}
164-
165-
return parent::afterSave();
166170
}
167171
}

Model/Data/DataProviderInterface.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,26 @@
44

55
interface DataProviderInterface
66
{
7+
/**
8+
* Retrieve data
9+
*
10+
* @return mixed
11+
*/
712
public function get();
13+
14+
/**
15+
* Add data
16+
*
17+
* @param string $eventName
18+
* @param array $data
19+
* @return mixed
20+
*/
821
public function add($eventName, $data);
22+
23+
/**
24+
* Clear data
25+
*
26+
* @return mixed
27+
*/
928
public function clear();
1029
}

Model/Data/RandomSuffix.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
class RandomSuffix
66
{
77
/**
8+
* Generate random suffix
9+
*
810
* @param null|string $loaderId
911
* @return string
1012
*/

Model/Data/Webhook/CookieList.php

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

55
class CookieList
66
{
7+
/**
8+
* Retrieve entire list of cookies
9+
*
10+
* @return string[]
11+
*/
712
public function getAll()
813
{
914
return [
@@ -48,4 +53,3 @@ public function getAll()
4853
];
4954
}
5055
}
51-

Model/Datalayer/Formatter/Event.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Event
99
/*
1010
* Stape event suffix
1111
*/
12-
const STAPE_EVENT_SUFFIX = '_stape';
12+
public const STAPE_EVENT_SUFFIX = '_stape';
1313

1414
/**
1515
* @var ConfigProvider $configProvider
@@ -27,6 +27,8 @@ public function __construct(ConfigProvider $configProvider)
2727
}
2828

2929
/**
30+
* Format event name. Add suffix if needed
31+
*
3032
* @param string $eventName
3133
* @param string|int $scopeCode
3234
* @return string

Observer/AddToCartComplete.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ public function execute(Observer $observer)
9494
'item_category' => $category ? $category->getName() : null,
9595
'price' => $this->priceCurrency->round($quoteItem->getBasePriceInclTax()),
9696
'quantity' => $qty,
97-
'variation_id' => $quoteItem->getHasChildren() ? current($quoteItem->getChildren())->getProductId() : null
97+
'variation_id' => $quoteItem->getHasChildren()
98+
? current($quoteItem->getChildren())->getProductId() : null
9899
]
99100
]
100101
]);

0 commit comments

Comments
 (0)