Skip to content

Commit 2f5f1e7

Browse files
committed
Merge remote-tracking branch 'origin/AC-3160-fix-deprecation-issues-part9' into delivery-bunch-w22
2 parents c3965c3 + cb8c14c commit 2f5f1e7

File tree

18 files changed

+64
-55
lines changed

18 files changed

+64
-55
lines changed

lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ protected function _prepareDataForTable(DataObject $object, $table)
199199
*/
200200
protected function _prepareTableValueForSave($value, $type)
201201
{
202-
$type = strtolower($type);
202+
$type = $value !== null ? strtolower($type) : '';
203203
if ($type == 'decimal' || $type == 'numeric' || $type == 'float') {
204204
$value = \Magento\Framework\App\ObjectManager::getInstance()->get(
205205
\Magento\Framework\Locale\FormatInterface::class

lib/internal/Magento/Framework/Model/ResourceModel/Db/Profiler.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
<?php
22
/**
3-
* Magento profiler for requests to database
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
86
namespace Magento\Framework\Model\ResourceModel\Db;
97

8+
/**
9+
* Magento profiler for requests to database
10+
*/
1011
class Profiler extends \Magento\Framework\DB\Profiler
1112
{
1213
/**
1314
* Default connection type for timer name creation
1415
*/
15-
const TIMER_PREFIX = 'DB_QUERY';
16+
public const TIMER_PREFIX = 'DB_QUERY';
1617

1718
/**
1819
* Default connection type for timer name creation
1920
*/
20-
const DEFAULT_CONNECTION_TYPE = 'database';
21+
public const DEFAULT_CONNECTION_TYPE = 'database';
2122

2223
/**
2324
* @var array Allowed query types
@@ -59,7 +60,7 @@ protected function _getTimerName($operation)
5960
*/
6061
protected function _parseQueryType($queryText)
6162
{
62-
$queryTypeParsed = strtolower(substr(ltrim($queryText), 0, 6));
63+
$queryTypeParsed = $queryText !== null ? strtolower(substr(ltrim($queryText), 0, 6)) : '';
6364

6465
if (!in_array($queryTypeParsed, $this->_queryTypes)) {
6566
$queryTypeParsed = 'query';

lib/internal/Magento/Framework/Module/Dir/ReverseResolver.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* Resolves file/directory paths to modules they belong to
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
@@ -10,6 +8,9 @@
108
use Magento\Framework\Module\Dir;
119
use Magento\Framework\Module\ModuleListInterface;
1210

11+
/**
12+
* Resolves file/directory paths to modules they belong to
13+
*/
1314
class ReverseResolver
1415
{
1516
/**
@@ -40,7 +41,7 @@ public function __construct(ModuleListInterface $moduleList, Dir $moduleDirs)
4041
*/
4142
public function getModuleName($path)
4243
{
43-
$path = str_replace('\\', '/', $path);
44+
$path = $path !== null ? str_replace('\\', '/', $path) : '';
4445
foreach ($this->_moduleList->getNames() as $moduleName) {
4546
$moduleDir = $this->_moduleDirs->getDir($moduleName);
4647
$moduleDir = str_replace('\\', '/', $moduleDir);

lib/internal/Magento/Framework/Module/PackageInfo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ protected function convertPackageNameToModuleName($packageName)
190190
*/
191191
protected function isMagentoPackage($packageName)
192192
{
193-
return strpos($packageName, 'magento/module-') === 0;
193+
return $packageName !== null && strpos($packageName, 'magento/module-') === 0;
194194
}
195195

196196
/**

lib/internal/Magento/Framework/ObjectManager/Config/Compiled.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function __construct($data)
5050
* @return void
5151
*
5252
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
53+
* phpcs:disable Magento2.CodeAnalysis.EmptyBlock
5354
*/
5455
public function setRelations(RelationsInterface $relations)
5556
{
@@ -67,6 +68,7 @@ public function setRelations(RelationsInterface $relations)
6768
public function setCache(ConfigCacheInterface $cache)
6869
{
6970
}
71+
// phpcs:enable Magento2.CodeAnalysis.EmptyBlock
7072

7173
/**
7274
* Retrieve list of arguments per type
@@ -121,7 +123,7 @@ public function getInstanceType($instanceName)
121123
*/
122124
public function getPreference($type)
123125
{
124-
$type = ltrim($type, '\\');
126+
$type = $type !== null ? ltrim($type, '\\') : '';
125127
if (isset($this->preferences[$type])) {
126128
return $this->preferences[$type];
127129
}

lib/internal/Magento/Framework/ObjectManager/Config/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function getInstanceType($instanceName)
170170
*/
171171
public function getPreference($type)
172172
{
173-
$type = ltrim($type, '\\');
173+
$type = $type !== null ? ltrim($type, '\\') : '';
174174
$preferencePath = [];
175175
while (isset($this->_preferences[$type])) {
176176
if (isset($preferencePath[$this->_preferences[$type]])) {

lib/internal/Magento/Framework/Parse/Zip.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static function parseRegions($state, $zip)
3232
*/
3333
public static function parseZip($zip)
3434
{
35-
if (strpos($zip, '-') === false) {
35+
if ($zip === null || strpos($zip, '-') === false) {
3636
return [$zip];
3737
} else {
3838
return self::zipRangeToZipPattern($zip);

lib/internal/Magento/Framework/Phrase/Renderer/Inline.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ public function render(array $source, array $arguments)
6363
return $text;
6464
}
6565

66-
if (strpos($text, '{{{') === false
66+
if ($text === null
67+
|| strpos($text, '{{{') === false
6768
|| strpos($text, '}}}') === false
6869
|| strpos($text, '}}{{') === false
6970
) {

lib/internal/Magento/Framework/Profiler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Profiler
1919
/**
2020
* Separator literal to assemble timer identifier from timer names
2121
*/
22-
const NESTING_SEPARATOR = '->';
22+
public const NESTING_SEPARATOR = '->';
2323

2424
/**
2525
* Whether profiling is active or not
@@ -262,7 +262,7 @@ public static function start($timerName, array $tags = null)
262262
return;
263263
}
264264

265-
if (strpos($timerName, self::NESTING_SEPARATOR) !== false) {
265+
if ($timerName !== null && strpos($timerName, self::NESTING_SEPARATOR) !== false) {
266266
throw new \InvalidArgumentException('Timer name must not contain a nesting separator.');
267267
}
268268

lib/internal/Magento/Framework/Profiler/Driver/Standard/Stat.php

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* Storage for timers statistics
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
@@ -12,25 +10,29 @@
1210
use Magento\Framework\Profiler;
1311

1412
/**
13+
* Storage for timers statistics
14+
*
1515
* @api
1616
*/
1717
class Stat
1818
{
1919
/**
2020
* #@+ Timer statistics data keys
2121
*/
22-
const ID = 'id';
23-
const START = 'start';
24-
const TIME = 'sum';
25-
const COUNT = 'count';
26-
const AVG = 'avg';
27-
const REALMEM = 'realmem';
28-
const REALMEM_START = 'realmem_start';
29-
const EMALLOC = 'emalloc';
30-
const EMALLOC_START = 'emalloc_start';
22+
public const ID = 'id';
23+
public const START = 'start';
24+
public const TIME = 'sum';
25+
public const COUNT = 'count';
26+
public const AVG = 'avg';
27+
public const REALMEM = 'realmem';
28+
public const REALMEM_START = 'realmem_start';
29+
public const EMALLOC = 'emalloc';
30+
public const EMALLOC_START = 'emalloc_start';
3131
/**#@-*/
3232

33-
/**#@-*/
33+
/**
34+
* @var array
35+
*/
3436
protected $_timers = [];
3537

3638
/**
@@ -205,7 +207,8 @@ protected function _getOrderedTimerIds()
205207

206208
$prevTimerId = $timerIds[0];
207209
$result = [$prevTimerId];
208-
for ($i = 1; $i < count($timerIds); $i++) {
210+
$numberTimerIds = count($timerIds);
211+
for ($i = 1; $i < $numberTimerIds; $i++) {
209212
$timerId = $timerIds[$i];
210213
/* Skip already added timer */
211214
if (!$timerId) {
@@ -214,8 +217,9 @@ protected function _getOrderedTimerIds()
214217
/* Loop over all timers that need to be closed under previous timer */
215218
while (strpos($timerId, $prevTimerId . Profiler::NESTING_SEPARATOR) !== 0) {
216219
/* Add to result all timers nested in the previous timer */
217-
for ($j = $i + 1; $j < count($timerIds); $j++) {
218-
if (strpos($timerIds[$j], $prevTimerId . Profiler::NESTING_SEPARATOR) === 0) {
220+
for ($j = $i + 1; $j < $numberTimerIds; $j++) {
221+
if (isset($timerIds[$j]) &&
222+
strpos($timerIds[$j], $prevTimerId . Profiler::NESTING_SEPARATOR) === 0) {
219223
$result[] = $timerIds[$j];
220224
/* Mark timer as already added */
221225
$timerIds[$j] = null;

0 commit comments

Comments
 (0)