Skip to content

Commit 4ff432c

Browse files
committed
AC-3162 fixed logic affected by "RFC: Deprecate passing null" issue
1 parent e897727 commit 4ff432c

File tree

13 files changed

+56
-29
lines changed

13 files changed

+56
-29
lines changed

lib/internal/Magento/Framework/View/Layout/ScheduledStructure/Helper.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@
1010

1111
class Helper
1212
{
13-
/**#@+
13+
/**
1414
* Scheduled structure array indexes
1515
*/
16-
const SCHEDULED_STRUCTURE_INDEX_TYPE = 0;
17-
const SCHEDULED_STRUCTURE_INDEX_ALIAS = 1;
18-
const SCHEDULED_STRUCTURE_INDEX_PARENT_NAME = 2;
19-
const SCHEDULED_STRUCTURE_INDEX_SIBLING_NAME = 3;
20-
const SCHEDULED_STRUCTURE_INDEX_IS_AFTER = 4;
21-
/**#@-*/
22-
23-
/**#@-*/
16+
public const SCHEDULED_STRUCTURE_INDEX_TYPE = 0;
17+
public const SCHEDULED_STRUCTURE_INDEX_ALIAS = 1;
18+
public const SCHEDULED_STRUCTURE_INDEX_PARENT_NAME = 2;
19+
public const SCHEDULED_STRUCTURE_INDEX_SIBLING_NAME = 3;
20+
public const SCHEDULED_STRUCTURE_INDEX_IS_AFTER = 4;
21+
22+
/**
23+
* @var int
24+
*/
2425
protected $counter = 0;
2526

2627
/**
@@ -126,7 +127,7 @@ protected function _overrideElementWorkaround(Layout\ScheduledStructure $schedul
126127
if ($scheduledStructure->hasStructureElement($name)) {
127128
$scheduledStructure->setStructureElementData($name, []);
128129
foreach ($scheduledStructure->getPaths() as $potentialChild => $childPath) {
129-
if (0 === strpos($childPath, "{$path}/")) {
130+
if (0 === strpos($childPath ?? '', "{$path}/")) {
130131
$scheduledStructure->unsetPathElement($potentialChild);
131132
$scheduledStructure->unsetStructureElement($potentialChild);
132133
}

lib/internal/Magento/Framework/View/Page/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ public function addRss($title, $href)
545545
*/
546546
public function addBodyClass($className)
547547
{
548-
$className = preg_replace('#[^a-z0-9-_]+#', '-', strtolower($className));
548+
$className = preg_replace('#[^a-z0-9-_]+#', '-', strtolower((string)$className));
549549
$bodyClasses = $this->getElementAttribute(self::ELEMENT_TYPE_BODY, self::BODY_ATTRIBUTE_CLASS);
550550
$bodyClasses = $bodyClasses ? explode(' ', $bodyClasses) : [];
551551
$bodyClasses[] = $className;

lib/internal/Magento/Framework/View/PageLayout/Config.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ public function getOptions()
7878
}
7979

8080
/**
81+
* Get options
82+
*
8183
* @param bool $withEmpty
8284
* @return array
8385
*/
@@ -109,7 +111,7 @@ protected function _extractData(\DOMDocument $dom)
109111

110112
/** @var \DOMElement $layout */
111113
foreach ($dom->getElementsByTagName('layout') as $layout) {
112-
$result[$layout->getAttribute('id')] = trim($layout->nodeValue);
114+
$result[$layout->getAttribute('id')] = $layout->nodeValue !== null ? trim($layout->nodeValue) : '';
113115
}
114116
return $result;
115117
}

lib/internal/Magento/Framework/View/PageLayout/File/Collector/Aggregated.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
class Aggregated extends \Magento\Framework\View\Layout\File\Collector\Aggregated
1515
{
1616
/**
17+
* Get files content
18+
*
1719
* @param ThemeInterface $theme
1820
* @param string $filePath
1921
* @return array
@@ -22,7 +24,7 @@ public function getFilesContent(ThemeInterface $theme, $filePath)
2224
{
2325
$result = [];
2426
foreach ($this->getFiles($theme, $filePath) as $file) {
25-
$result[$file->getFilename()] = file_get_contents($file->getFilename());
27+
$result[$file->getFilename()] = file_get_contents($file->getFilename() ?? '');
2628
}
2729

2830
return $result;

lib/internal/Magento/Framework/View/Template/Html/Minifier.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ function ($match) use (&$heredocs) {
125125

126126
return '__MINIFIED_HEREDOC__' .(count($heredocs) - 1);
127127
},
128+
// phpstan:ignore
128129
($content ?? '')
129130
);
130131
$content = preg_replace(
@@ -170,7 +171,10 @@ function ($match) use ($heredocs) {
170171
if (!$this->htmlDirectory->isExist()) {
171172
$this->htmlDirectory->create();
172173
}
173-
$this->htmlDirectory->writeFile($this->getRelativeGeneratedPath($file), rtrim($content));
174+
$this->htmlDirectory->writeFile(
175+
$this->getRelativeGeneratedPath($file),
176+
$content !== null ? rtrim($content) : ''
177+
);
174178
}
175179

176180
/**

lib/internal/Magento/Framework/View/TemplateEngine/Xhtml/Compiler/Directive/CallableMethod.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
use Magento\Framework\DataObject;
99

10-
/**
11-
* Class CallableMethod
12-
*/
1310
class CallableMethod implements DirectiveInterface
1411
{
1512
/**
@@ -23,7 +20,8 @@ public function execute($directive, DataObject $processedObject)
2320
{
2421
$object = $processedObject;
2522
$result = '';
26-
foreach (explode('.', $directive[1]) as $method) {
23+
foreach (explode('.', $directive[1] ?? '') as $method) {
24+
$method = (string)$method;
2725
$methodName = substr($method, 0, strpos($method, '('));
2826
if (is_callable([$object, $methodName])) {
2927
$result = $object->$methodName();

lib/internal/Magento/Framework/View/Url/CssResolver.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CssResolver
1818
/**
1919
* PCRE that matches non-absolute URLs in CSS content
2020
*/
21-
const REGEX_CSS_RELATIVE_URLS =
21+
public const REGEX_CSS_RELATIVE_URLS =
2222
'#url\s*\(\s*(?(?=\'|").)(?!http\://|https\://|/|data\:)(.+?)(?:[\#\?].*?|[\'"])?\s*\)#';
2323

2424
/**
@@ -50,13 +50,18 @@ public function relocateRelativeUrls($cssContent, $relatedPath, $filePath)
5050
*/
5151
public function replaceRelativeUrls($cssContent, $inlineCallback)
5252
{
53+
$cssContent = $cssContent !== null ? $cssContent : '';
5354
$patterns = self::extractRelativeUrls($cssContent);
5455
if ($patterns) {
5556
$replace = [];
5657
foreach ($patterns as $pattern => $path) {
5758
if (!isset($replace[$pattern])) {
5859
$newPath = call_user_func($inlineCallback, $path);
59-
$newPattern = str_replace($path, $newPath, $pattern);
60+
$newPattern = str_replace(
61+
$path !== null ? $path : '',
62+
$newPath !== null ? $newPath : '',
63+
$pattern
64+
);
6065
$replace[$pattern] = $newPattern;
6166
}
6267
}
@@ -75,7 +80,7 @@ public function replaceRelativeUrls($cssContent, $inlineCallback)
7580
*/
7681
public function aggregateImportDirectives($cssContent)
7782
{
78-
$parts = preg_split('/(@import\s.+?;\s*)/', $cssContent, -1, PREG_SPLIT_DELIM_CAPTURE);
83+
$parts = preg_split('/(@import\s.+?;\s*)/', (string)$cssContent, -1, PREG_SPLIT_DELIM_CAPTURE);
7984
$imports = [];
8085
$css = [];
8186
foreach ($parts as $part) {

lib/internal/Magento/Framework/Webapi/Rest/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function getAcceptTypes()
103103
$qualityToTypes = [];
104104
$orderedTypes = [];
105105

106-
foreach (preg_split('/,\s*/', $this->getHeader('Accept')) as $definition) {
106+
foreach (preg_split('/,\s*/', $this->getHeader('Accept') ?? '') as $definition) {
107107
$typeWithQ = explode(';', $definition);
108108
$mimeType = trim(array_shift($typeWithQ));
109109

lib/internal/Magento/Framework/Webapi/Rest/Response/RendererFactory.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?php
22
/**
3-
* Factory of REST renders
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
86
namespace Magento\Framework\Webapi\Rest\Response;
97

108
use Magento\Framework\Phrase;
119

10+
/**
11+
* Factory of REST renders
12+
*/
1213
class RendererFactory
1314
{
1415
/**
@@ -75,7 +76,7 @@ protected function _getRendererClass()
7576
foreach ($this->_renders as $rendererConfig) {
7677
$rendererType = $rendererConfig['type'];
7778
if ($acceptType == $rendererType || $acceptType == current(
78-
explode('/', $rendererType)
79+
explode('/', $rendererType ?? '')
7980
) . '/*' || $acceptType == '*/*'
8081
) {
8182
return $rendererConfig['model'];

lib/internal/Magento/Framework/Webapi/ServiceInputProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ private function processCustomAttribute($customAttribute)
469469
*/
470470
protected function _createDataObjectForTypeAndArrayValue($type, $customAttributeValue)
471471
{
472-
if (substr($type, -2) === "[]") {
472+
if ($type !== null && substr($type, -2) === "[]") {
473473
$type = substr($type, 0, -2);
474474
$attributeValue = [];
475475
foreach ($customAttributeValue as $value) {

0 commit comments

Comments
 (0)