Skip to content

Commit f7ff25b

Browse files
karyna-tandrewbess
authored andcommitted
AC-3108: Fix possible deprecation issues with 8.1
1 parent b53582a commit f7ff25b

File tree

11 files changed

+28
-24
lines changed

11 files changed

+28
-24
lines changed

app/code/Magento/Theme/view/frontend/templates/callouts/left_col.phtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
?>
77
<div class="block block-banner">
88
<div class="block-content">
9-
<?php if (strtolower(substr($block->getLinkUrl(), 0, 4)) === 'http') : ?>
9+
<?php if ($block->getLinkUrl() && strtolower(substr($block->getLinkUrl(), 0, 4)) === 'http'): ?>
1010
<a href="<?= $block->escapeUrl($block->getLinkUrl()) ?>"
1111
title="<?= $block->escapeHtmlAttr(__($block->getImgAlt())) ?>">
12-
<?php elseif ($block->getLinkUrl()) : ?>
12+
<?php elseif ($block->getLinkUrl()): ?>
1313
<a href="<?= $block->escapeUrl($block->getUrl($block->getLinkUrl())) ?>"
1414
title="<?= $block->escapeHtmlAttr(__($block->getImgAlt())) ?>">
1515
<?php endif; ?>
1616
<img src="<?= $block->escapeUrl($block->getViewFileUrl($block->getImgSrc())) ?>"
17-
<?php if (!$block->getLinkUrl()) : ?>
17+
<?php if (!$block->getLinkUrl()): ?>
1818
title="<?= $block->escapeHtmlAttr(__($block->getImgAlt())) ?>"
1919
<?php endif; ?>
2020
alt="<?= $block->escapeHtmlAttr(__($block->getImgAlt())) ?>" />
21-
<?php if ($block->getLinkUrl()) : ?>
21+
<?php if ($block->getLinkUrl()): ?>
2222
</a>
2323
<?php endif ?>
2424
</div>

app/code/Magento/Theme/view/frontend/templates/callouts/right_col.phtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
?>
77
<div class="block block-banner">
88
<div class="block-content">
9-
<?php if (strtolower(substr($block->getLinkUrl(), 0, 4)) === 'http') : ?>
9+
<?php if ($block->getLinkUrl() && strtolower(substr($block->getLinkUrl(), 0, 4)) === 'http'): ?>
1010
<a href="<?= $block->escapeUrl($block->getLinkUrl()) ?>"
1111
title="<?= $block->escapeHtmlAttr(__($block->getImgAlt())) ?>">
12-
<?php elseif ($block->getLinkUrl()) : ?>
12+
<?php elseif ($block->getLinkUrl()): ?>
1313
<a href="<?= $block->escapeUrl($block->getUrl($block->getLinkUrl())) ?>"
1414
title="<?= $block->escapeHtmlAttr(__($block->getImgAlt())) ?>">
1515
<?php endif; ?>
1616
<img src="<?= $block->escapeUrl($block->getViewFileUrl($block->getImgSrc())) ?>"
17-
<?php if (!$block->getLinkUrl()) : ?>
17+
<?php if (!$block->getLinkUrl()): ?>
1818
title="<?= $block->escapeHtmlAttr(__($block->getImgAlt())) ?>"
1919
<?php endif; ?>
2020
alt="<?= $block->escapeHtmlAttr(__($block->getImgAlt())) ?>" />
21-
<?php if ($block->getLinkUrl()) : ?>
21+
<?php if ($block->getLinkUrl()): ?>
2222
</a>
2323
<?php endif ?>
2424
</div>

app/code/Magento/Theme/view/frontend/templates/html/sections.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $groupCss = $block->getGroupCss();
1919
<?php foreach ($detailedInfoGroup as $name):?>
2020
<?php
2121
$html = $layout->renderElement($name);
22-
if (!trim($html) && ($block->getUseForce() != true)) {
22+
if (!($html !== null && trim($html)) && ($block->getUseForce() != true)) {
2323
continue;
2424
}
2525
$alias = $layout->getElementAlias($name);

app/code/Magento/Translation/Model/Inline/Parser.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ protected function _getAttributeLocation($matches, $options)
344344
*/
345345
protected function _getTagLocation($matches, $options)
346346
{
347-
$tagName = strtolower($options['tagName']);
347+
$tagName = isset($options['tagName']) ? strtolower($options['tagName']) : '';
348348

349349
return $options['tagList'][$tagName] ?? (ucfirst($tagName) . ' Text');
350350
}
@@ -386,6 +386,8 @@ protected function _applySpecialTagsFormat($tagHtml, $tagName, $trArr)
386386
*/
387387
protected function _applySimpleTagsFormat($tagHtml, $tagName, $trArr)
388388
{
389+
$tagHtml = $tagHtml !== null ? $tagHtml : '';
390+
$tagName = $tagName !== null ? $tagName : '';
389391
$simpleTags = substr(
390392
$tagHtml,
391393
0,
@@ -568,6 +570,7 @@ function ($tagHtml, $tagName, $trArr) {
568570
* @param callable $formatCallback
569571
*
570572
* @return void
573+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
571574
*/
572575
private function _translateTags(string &$content, array $tagsList, callable $formatCallback)
573576
{
@@ -621,7 +624,7 @@ private function _translateTags(string &$content, array $tagsList, callable $for
621624
&& $tagBodyOpenStartPosition > $tagMatch[0][1]
622625
) {
623626
$tagHtmlHead = $formatCallback($tagHtml, $tagName, $trArr);
624-
$headTranslateTags .= substr($tagHtmlHead, strlen($tagHtml));
627+
$headTranslateTags .= $tagHtmlHead !== null ? substr($tagHtmlHead, strlen($tagHtml)) : '';
625628
} else {
626629
$tagHtml = $formatCallback($tagHtml, $tagName, $trArr);
627630
}
@@ -654,13 +657,14 @@ private function _translateTags(string &$content, array $tagsList, callable $for
654657
*/
655658
private function _findEndOfTag($body, $tagName, $from)
656659
{
660+
$body = $body !== null ? $body : '';
657661
$openTag = '<' . $tagName;
658662
$closeTag = ($this->_isJson ? '<\\/' : '</') . $tagName;
659663
$tagLength = strlen($tagName);
660664
$length = $tagLength + 1;
661665
$end = $from + 1;
662666
while (substr_count($body, $openTag, $from, $length) !== substr_count($body, $closeTag, $from, $length)) {
663-
$end = strpos($body, (string) $closeTag, $end + $tagLength + 1);
667+
$end = strpos($body, $closeTag, $end + $tagLength + 1);
664668
if ($end === false) {
665669
return false;
666670
}

app/code/Magento/Translation/Model/Js/DataProvider.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class DataProvider implements DataProviderInterface
3030
protected $config;
3131

3232
/**
33-
* Files utility
34-
*
3533
* @var \Magento\Framework\App\Utility\Files
3634
*/
3735
protected $filesUtility;
@@ -142,7 +140,7 @@ protected function getPhrases($content)
142140
if ($result) {
143141
if (isset($matches[2])) {
144142
foreach ($matches[2] as $match) {
145-
$phrases[] = str_replace(["\'", '\"'], ["'", '"'], $match);
143+
$phrases[] = $match !== null ? str_replace(["\'", '\"'], ["'", '"'], $match) : '';
146144
}
147145
}
148146
}

app/code/Magento/Translation/Model/Json/PreProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,6 @@ public function process(Chain $chain)
116116
*/
117117
protected function isDictionaryPath($path)
118118
{
119-
return (strpos($path, (string) $this->config->getDictionaryFileName()) !== false);
119+
return $path !== null && strpos($path, (string) $this->config->getDictionaryFileName()) !== false;
120120
}
121121
}

app/code/Magento/Ui/Config/Argument/Parser/ConverterType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function parse(array $data, \DOMNode $node)
3434
{
3535
$result = [];
3636
$domXPath = new \DOMXPath($node->ownerDocument);
37-
$nodeList = $domXPath->query(trim($data['value']), $node);
37+
$nodeList = $domXPath->query(trim($data['value'] ?? ''), $node);
3838
foreach ($nodeList as $itemNode) {
3939
$result = $this->converter->convert($itemNode, $data);
4040
}

app/code/Magento/Ui/Config/Argument/Parser/XpathType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function parse(array $data, \DOMNode $node)
2525
}
2626
unset($data['type']);
2727
$domXPath = new \DOMXPath($node->ownerDocument);
28-
$nodeList = $domXPath->query(trim($data['value']), $node);
28+
$nodeList = $domXPath->query(trim($data['value'] ?? ''), $node);
2929
if ($nodeList->length == 1) {
3030
$nodeItem = $nodeList->item(0);
3131
$data['xsi:type'] = $type;

app/code/Magento/Ui/Config/Reader/Dom.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Dom extends ConfigDom
4646
* @param ValidationStateInterface $validationState
4747
* @param SchemaLocatorInterface $schemaLocator
4848
* @param array $idAttributes
49-
* @param null $typeAttributeName
49+
* @param string|null $typeAttributeName
5050
* @param string $errorFormat
5151
*/
5252
public function __construct(
@@ -142,7 +142,7 @@ private function processMatchedNodes(\DOMNodeList $rootMatchList, \DOMElement $i
142142
private function createXPath(\DOMNode $node)
143143
{
144144
$parentXPath = '';
145-
$currentXPath = $node->getNodePath();
145+
$currentXPath = $node->getNodePath() ?? '';
146146
if ($node->parentNode !== null && !$node->isSameNode($node->parentNode)) {
147147
$parentXPath = $this->createXPath($node->parentNode);
148148
$pathParts = explode('/', $currentXPath);

app/code/Magento/Ui/Controller/Adminhtml/Bookmark/Delete.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
/**
1515
* Class Delete action
16+
*
17+
* @SuppressWarnings(PHPMD.AllPurposeAction)
1618
*/
1719
class Delete extends AbstractAction
1820
{
@@ -50,7 +52,7 @@ public function __construct(
5052
*/
5153
public function execute()
5254
{
53-
$viewIds = explode('.', $this->_request->getParam('data'));
55+
$viewIds = explode('.', $this->_request->getParam('data', ''));
5456
$bookmark = $this->bookmarkManagement->getByIdentifierNamespace(
5557
array_pop($viewIds),
5658
$this->_request->getParam('namespace')

0 commit comments

Comments
 (0)