Skip to content

Commit 18b5b23

Browse files
committed
Merge remote-tracking branch 'trigger/imported-karyna-tsymbal-atwix-magento2-34641' into ph-delivery
2 parents 7431f26 + 71f9114 commit 18b5b23

File tree

10 files changed

+86
-69
lines changed

10 files changed

+86
-69
lines changed

app/code/Magento/Backend/App/DefaultPath.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
3-
* Default application path for backend area
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
86
namespace Magento\Backend\App;
97

108
/**
9+
* Default application path for backend area
10+
*
1111
* @api
1212
* @since 100.0.2
1313
*/
@@ -24,7 +24,11 @@ class DefaultPath implements \Magento\Framework\App\DefaultPathInterface
2424
*/
2525
public function __construct(\Magento\Backend\App\ConfigInterface $config)
2626
{
27-
$pathParts = explode('/', $config->getValue('web/default/admin'));
27+
$pathConfigValue = $config->getValue('web/default/admin') ?? '';
28+
$pathParts = [];
29+
if ($pathConfigValue) {
30+
$pathParts = explode('/', $pathConfigValue);
31+
}
2832

2933
$this->_parts = [
3034
'area' => isset($pathParts[0]) ? $pathParts[0] : '',

app/code/Magento/Backend/view/adminhtml/templates/widget/tabshoriz.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use Magento\Framework\View\Helper\SecureHtmlRenderer;
1919
<?php foreach ($tabs as $_tab): ?>
2020
<?php $tabId = $block->getTabId($_tab) ?>
2121
<?php $_tabClass = 'tab-item-link ' . $block->getTabClass($_tab) . ' ' .
22-
(preg_match('/\s?ajax\s?/', $_tab->getClass()) ? 'notloaded' : '') ?>
22+
($_tab->getClass() !== null ? (preg_match('/\s?ajax\s?/', $_tab->getClass()) ? 'notloaded' : '') : '') ?>
2323
<?php $_tabType = (!preg_match('/\s?ajax\s?/', $_tabClass) && $block->getTabUrl($_tab) != '#') ? 'link' : '' ?>
2424
<?php $_tabHref = $block->getTabUrl($_tab) == '#' ?
2525
'#' . $tabId . '_content' :

app/code/Magento/Eav/Model/Entity/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public function getValueTablePrefix()
303303
*/
304304
public function getEntityTablePrefix()
305305
{
306-
$tablePrefix = trim($this->_data['value_table_prefix']);
306+
$tablePrefix = isset($this->_data['value_table_prefix']) ? trim($this->_data['value_table_prefix']) : '';
307307

308308
if (empty($tablePrefix)) {
309309
$tablePrefix = $this->getEntityTable();

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,10 +1760,10 @@ public function getColumnCreateByDescribe($columnData)
17601760
if ($columnData['DEFAULT'] !== null && $type != Table::TYPE_TEXT) {
17611761
$options['default'] = $this->quote($columnData['DEFAULT']);
17621762
}
1763-
if (strlen($columnData['SCALE']) > 0) {
1763+
if (isset($columnData['SCALE']) && strlen($columnData['SCALE']) > 0) {
17641764
$options['scale'] = $columnData['SCALE'];
17651765
}
1766-
if (strlen($columnData['PRECISION']) > 0) {
1766+
if (isset($columnData['PRECISION']) && strlen($columnData['PRECISION']) > 0) {
17671767
$options['precision'] = $columnData['PRECISION'];
17681768
}
17691769

lib/internal/Magento/Framework/DB/Ddl/Table.php

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,129 +18,129 @@ class Table
1818
/**
1919
* Types of columns
2020
*/
21-
const TYPE_BOOLEAN = 'boolean';
21+
public const TYPE_BOOLEAN = 'boolean';
2222

23-
const TYPE_SMALLINT = 'smallint';
23+
public const TYPE_SMALLINT = 'smallint';
2424

25-
const TYPE_INTEGER = 'integer';
25+
public const TYPE_INTEGER = 'integer';
2626

27-
const TYPE_BIGINT = 'bigint';
27+
public const TYPE_BIGINT = 'bigint';
2828

29-
const TYPE_FLOAT = 'float';
29+
public const TYPE_FLOAT = 'float';
3030

31-
const TYPE_NUMERIC = 'numeric';
31+
public const TYPE_NUMERIC = 'numeric';
3232

33-
const TYPE_DECIMAL = 'decimal';
33+
public const TYPE_DECIMAL = 'decimal';
3434

35-
const TYPE_DATE = 'date';
35+
public const TYPE_DATE = 'date';
3636

37-
const TYPE_TIMESTAMP = 'timestamp';
37+
public const TYPE_TIMESTAMP = 'timestamp';
3838

3939
// Capable to support date-time from 1970 + auto-triggers in some RDBMS
40-
const TYPE_DATETIME = 'datetime';
40+
public const TYPE_DATETIME = 'datetime';
4141

4242
// Capable to support long date-time before 1970
43-
const TYPE_TEXT = 'text';
43+
public const TYPE_TEXT = 'text';
4444

4545
// A real blob, stored as binary inside DB
46-
const TYPE_BLOB = 'blob';
46+
public const TYPE_BLOB = 'blob';
4747

4848
// Used for back compatibility, when query param can't use statement options
49-
const TYPE_VARBINARY = 'varbinary';
49+
public const TYPE_VARBINARY = 'varbinary';
5050

5151
/**
5252
* Default and maximal TEXT and BLOB columns sizes we can support for different DB systems.
5353
*/
54-
const DEFAULT_TEXT_SIZE = 1024;
54+
public const DEFAULT_TEXT_SIZE = 1024;
5555

56-
const MAX_TEXT_SIZE = 2147483648;
56+
public const MAX_TEXT_SIZE = 2147483648;
5757

58-
const MAX_VARBINARY_SIZE = 2147483648;
58+
public const MAX_VARBINARY_SIZE = 2147483648;
5959

6060
/**
6161
* Default values for timestamps - fill with current timestamp on inserting record, on changing and both cases
6262
*/
63-
const TIMESTAMP_INIT_UPDATE = 'TIMESTAMP_INIT_UPDATE';
63+
public const TIMESTAMP_INIT_UPDATE = 'TIMESTAMP_INIT_UPDATE';
6464

65-
const TIMESTAMP_INIT = 'TIMESTAMP_INIT';
65+
public const TIMESTAMP_INIT = 'TIMESTAMP_INIT';
6666

67-
const TIMESTAMP_UPDATE = 'TIMESTAMP_UPDATE';
67+
public const TIMESTAMP_UPDATE = 'TIMESTAMP_UPDATE';
6868

6969
/**
7070
* Actions used for foreign keys
7171
*/
72-
const ACTION_CASCADE = 'CASCADE';
72+
public const ACTION_CASCADE = 'CASCADE';
7373

74-
const ACTION_SET_NULL = 'SET NULL';
74+
public const ACTION_SET_NULL = 'SET NULL';
7575

76-
const ACTION_NO_ACTION = 'NO ACTION';
76+
public const ACTION_NO_ACTION = 'NO ACTION';
7777

78-
const ACTION_RESTRICT = 'RESTRICT';
78+
public const ACTION_RESTRICT = 'RESTRICT';
7979

80-
const ACTION_SET_DEFAULT = 'SET DEFAULT';
80+
public const ACTION_SET_DEFAULT = 'SET DEFAULT';
8181

8282
/**
8383
* Column option 'default'
8484
*
8585
* @var string
8686
*/
87-
const OPTION_DEFAULT = 'default';
87+
public const OPTION_DEFAULT = 'default';
8888

8989
/**
9090
* Column option 'identity'
9191
*
9292
* @var string
9393
*/
94-
const OPTION_IDENTITY = 'identity';
94+
public const OPTION_IDENTITY = 'identity';
9595

9696
/**
9797
* Column option 'length'
9898
*
9999
* @var string
100100
*/
101-
const OPTION_LENGTH = 'length';
101+
public const OPTION_LENGTH = 'length';
102102

103103
/**
104104
* Column option 'nullable'
105105
*
106106
* @var string
107107
*/
108-
const OPTION_NULLABLE = 'nullable';
108+
public const OPTION_NULLABLE = 'nullable';
109109

110110
/**
111111
* Column option 'precision'
112112
*
113113
* @var string
114114
*/
115-
const OPTION_PRECISION = 'precision';
115+
public const OPTION_PRECISION = 'precision';
116116

117117
/**
118118
* Column option 'primary'
119119
*
120120
* @var string
121121
*/
122-
const OPTION_PRIMARY = 'primary';
122+
public const OPTION_PRIMARY = 'primary';
123123

124124
/**
125125
* Column option 'scale'
126126
*
127127
* @var string
128128
*/
129-
const OPTION_SCALE = 'scale';
129+
public const OPTION_SCALE = 'scale';
130130

131131
/**
132132
* Column option 'type'
133133
*
134134
* @var string
135135
*/
136-
const OPTION_TYPE = 'type';
136+
public const OPTION_TYPE = 'type';
137137

138138
/**
139139
* Column option 'unsigned'
140140
*
141141
* @var string
142142
*/
143-
const OPTION_UNSIGNED = 'unsigned';
143+
public const OPTION_UNSIGNED = 'unsigned';
144144

145145
/**
146146
* Name of table
@@ -150,8 +150,6 @@ class Table
150150
protected $_tableName;
151151

152152
/**
153-
* Schema name
154-
*
155153
* @var string
156154
*/
157155
protected $_schemaName;
@@ -381,7 +379,7 @@ public function addColumn($name, $type, $size = null, $options = [], $comment =
381379
$precision = $size[0];
382380
$scale = $size[1];
383381
}
384-
} elseif (preg_match('#^(\d+),(\d+)$#', $size, $match)) {
382+
} elseif ($size && preg_match('#^(\d+),(\d+)$#', $size, $match)) {
385383
$precision = $match[1];
386384
$scale = $match[2];
387385
}
@@ -637,6 +635,7 @@ public function setOption($key, $value)
637635

638636
/**
639637
* Retrieve table option value by option name
638+
*
640639
* Return null if option does not exits
641640
*
642641
* @param string $key
@@ -673,7 +672,7 @@ protected function _sortIndexColumnPosition($a, $b)
673672
}
674673

675674
/**
676-
* table column position comparison function
675+
* Table column position comparison function
677676
*
678677
* @param array $a
679678
* @param array $b

lib/internal/Magento/Framework/Filesystem/Driver/File.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22
/**
3-
* Origin filesystem driver
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
@@ -38,7 +36,7 @@ class File implements DriverInterface
3836
*/
3937
public function __construct(bool $stateful = false)
4038
{
41-
$this->stateful = $stateful ?? false;
39+
$this->stateful = $stateful;
4240
}
4341

4442
/**
@@ -962,7 +960,8 @@ public function getAbsolutePath($basePath, $path, $scheme = null)
962960
// check if the path given is already an absolute path containing the
963961
// basepath. so if the basepath starts at position 0 in the path, we
964962
// must not concatinate them again because path is already absolute.
965-
if (0 === strpos($path, $basePath)) {
963+
$path = $path !== null ? $path : '';
964+
if ('' !== $basePath && strpos($path, $basePath) === 0) {
966965
return $this->getScheme($scheme) . $path;
967966
}
968967

@@ -978,7 +977,7 @@ public function getAbsolutePath($basePath, $path, $scheme = null)
978977
*/
979978
public function getRelativePath($basePath, $path = null)
980979
{
981-
$path = $this->fixSeparator($path);
980+
$path = $path !== null ? $this->fixSeparator($path) : '';
982981
if (strpos($path, $basePath) === 0 || $basePath == $path . '/') {
983982
$result = substr($path, strlen($basePath));
984983
} else {
@@ -1060,6 +1059,10 @@ public function getRealPath($path)
10601059
*/
10611060
public function getRealPathSafety($path)
10621061
{
1062+
if ($path === null) {
1063+
return '';
1064+
}
1065+
10631066
//Check backslashes
10641067
$path = preg_replace(
10651068
'/\\\\+/',

lib/internal/Magento/Framework/Filesystem/Test/Unit/Driver/FileTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public function dataProviderForTestGetAbsolutePath(): array
5353
['/root/path/', '/sub', '/root/path/sub'],
5454
['/root/path/', '../sub', '/root/path/../sub'],
5555
['/root/path/', '/root/path/sub', '/root/path/sub'],
56+
['', '', ''],
57+
['0', '0', '0']
5658
];
5759
}
5860

@@ -82,6 +84,8 @@ public function dataProviderForTestGetRelativePath(): array
8284
['/root/path/', '/sub', '/sub'],
8385
['/root/path/', '/root/path/sub', 'sub'],
8486
['/root/path/sub', '/root/path/other', '/root/path/other'],
87+
['/root/path/', '', ''],
88+
['0', '0', '']
8589
];
8690
}
8791

lib/internal/Magento/Framework/Stdlib/DateTime.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@ class DateTime
1717
/**#@+
1818
* Date format, used as default. Compatible with \DateTime
1919
*/
20-
const DATETIME_INTERNAL_FORMAT = 'yyyy-MM-dd HH:mm:ss';
20+
public const DATETIME_INTERNAL_FORMAT = 'yyyy-MM-dd HH:mm:ss';
2121

22-
const DATE_INTERNAL_FORMAT = 'yyyy-MM-dd';
22+
public const DATE_INTERNAL_FORMAT = 'yyyy-MM-dd';
2323

24-
const DATETIME_PHP_FORMAT = 'Y-m-d H:i:s';
24+
public const DATETIME_PHP_FORMAT = 'Y-m-d H:i:s';
2525

26-
const DATE_PHP_FORMAT = 'Y-m-d';
26+
public const DATE_PHP_FORMAT = 'Y-m-d';
2727

2828
/**#@-*/
2929

3030
/**
3131
* Minimum allowed year value
3232
*/
33-
const YEAR_MIN_VALUE = -10000;
33+
public const YEAR_MIN_VALUE = -10000;
3434

3535
/**
3636
* Maximum allowed year value
3737
*/
38-
const YEAR_MAX_VALUE = 10000;
38+
public const YEAR_MAX_VALUE = 10000;
3939

4040
/**
4141
* Format date to internal format
@@ -70,7 +70,7 @@ public function formatDate($date, $includeTime = true)
7070
*/
7171
public function isEmptyDate($date)
7272
{
73-
return preg_replace('#[ 0:-]#', '', $date) === '';
73+
return !$date || preg_replace('#[ 0:-]#', '', $date) === '';
7474
}
7575

7676
/**

lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ public function scopeTimeStamp($scope = null)
264264
*/
265265
public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null)
266266
{
267+
$dateFrom = $dateFrom ?? '';
268+
$dateTo = $dateTo ?? '';
267269
if (!$scope instanceof ScopeInterface) {
268270
$scope = $this->_scopeResolver->getScope($scope);
269271
}
@@ -282,6 +284,9 @@ public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null)
282284

283285
/**
284286
* @inheritdoc
287+
*
288+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
289+
* @SuppressWarnings(PHPMD.NPathComplexity)
285290
*/
286291
public function formatDateTime(
287292
$date,
@@ -305,9 +310,11 @@ public function formatDateTime(
305310
}
306311

307312
$formatter = $this->dateFormatterFactory->create(
308-
(string)($locale ?: $this->_localeResolver->getLocale()),
309-
(int)($dateType ?? \IntlDateFormatter::SHORT),
310-
(int)($timeType ?? \IntlDateFormatter::SHORT),
313+
(string) ($locale ?: $this->_localeResolver->getLocale()),
314+
// @phpstan-ignore-next-line
315+
(int) ($dateType ?? \IntlDateFormatter::SHORT),
316+
// @phpstan-ignore-next-line
317+
(int) ($timeType ?? \IntlDateFormatter::SHORT),
311318
null,
312319
false
313320
);

0 commit comments

Comments
 (0)