Skip to content

Commit 00d9a6b

Browse files
33667 Merged 2.4-develop and resolved conflicts
2 parents 550115b + 5f76c92 commit 00d9a6b

File tree

546 files changed

+49964
-50141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

546 files changed

+49964
-50141
lines changed

app/code/Magento/AwsS3/Driver/AwsS3.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* Driver for AWS S3 IO operations.
2626
*
2727
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
28+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2829
*/
2930
class AwsS3 implements RemoteDriverInterface
3031
{
@@ -258,6 +259,7 @@ public function filePutContents($path, $content, $mode = null): int
258259
$path = $this->normalizeRelativePath($path, true);
259260
$config = self::CONFIG;
260261

262+
// phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
261263
if (false !== ($imageSize = @getimagesizefromstring($content))) {
262264
$config['Metadata'] = [
263265
'image-width' => $imageSize[0],
@@ -295,19 +297,20 @@ public function readDirectory($path): array
295297
*/
296298
public function getRealPathSafety($path)
297299
{
300+
//Removing redundant directory separators
301+
$path = preg_replace(
302+
'~(?<!:)\/\/+~',
303+
'/',
304+
$path
305+
);
306+
298307
if (strpos($path, '/.') === false) {
299308
return $path;
300309
}
301310

302311
$isAbsolute = strpos($path, $this->normalizeAbsolutePath('')) === 0;
303312
$path = $this->normalizeRelativePath($path);
304313

305-
//Removing redundant directory separators.
306-
$path = preg_replace(
307-
'/\\/\\/+/',
308-
'/',
309-
$path
310-
);
311314
$pathParts = explode('/', $path);
312315
if (end($pathParts) === '.') {
313316
$pathParts[count($pathParts) - 1] = '';
@@ -488,8 +491,7 @@ public function getRelativePath($basePath, $path = null): string
488491
$basePath = (string)$basePath;
489492
$path = (string)$path;
490493

491-
if (
492-
($basePath && $path)
494+
if ($basePath && $path
493495
&& ($basePath === $path . '/' || strpos($path, $basePath) === 0)
494496
) {
495497
$result = substr($path, strlen($basePath));
@@ -722,6 +724,7 @@ public function fileGetCsv($resource, $length = 0, $delimiter = ',', $enclosure
722724
*/
723725
public function fileTell($resource): int
724726
{
727+
// phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
725728
$result = @ftell($resource);
726729
if ($result === null) {
727730
throw new FileSystemException(
@@ -737,6 +740,7 @@ public function fileTell($resource): int
737740
*/
738741
public function fileSeek($resource, $offset, $whence = SEEK_SET): int
739742
{
743+
// phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
740744
$result = @fseek($resource, $offset, $whence);
741745
if ($result === -1) {
742746
throw new FileSystemException(
@@ -755,6 +759,7 @@ public function fileSeek($resource, $offset, $whence = SEEK_SET): int
755759
*/
756760
public function endOfFile($resource): bool
757761
{
762+
// phpcs:ignore Magento2.Functions.DiscouragedFunction.DiscouragedWithAlternative
758763
return feof($resource);
759764
}
760765

@@ -772,6 +777,7 @@ public function filePutCsv($resource, array $data, $delimiter = ',', $enclosure
772777
*/
773778
public function fileFlush($resource): bool
774779
{
780+
// phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
775781
$result = @fflush($resource);
776782
if (!$result) {
777783
throw new FileSystemException(
@@ -790,6 +796,7 @@ public function fileFlush($resource): bool
790796
*/
791797
public function fileLock($resource, $lockMode = LOCK_EX): bool
792798
{
799+
// phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
793800
$result = @flock($resource, $lockMode);
794801
if (!$result) {
795802
throw new FileSystemException(
@@ -808,6 +815,7 @@ public function fileLock($resource, $lockMode = LOCK_EX): bool
808815
*/
809816
public function fileUnlock($resource): bool
810817
{
818+
// phpcs:ignore Magento2.Functions.DiscouragedFunction, Generic.PHP.NoSilencedErrors.Discouraged
811819
$result = @flock($resource, LOCK_UN);
812820
if (!$result) {
813821
throw new FileSystemException(
@@ -851,13 +859,14 @@ public function fileClose($resource): bool
851859
//phpcs:enable
852860

853861
foreach ($this->streams as $path => $stream) {
854-
// phpcs:ignore Magento2.Functions.DiscouragedFunction
862+
// phpcs:ignore
855863
if (stream_get_meta_data($stream)['uri'] === $resourcePath) {
856864
$this->adapter->writeStream($path, $resource, new Config(self::CONFIG));
857865

858866
// Remove path from streams after
859867
unset($this->streams[$path]);
860868

869+
// phpcs:ignore Magento2.Functions.DiscouragedFunction.DiscouragedWithAlternative
861870
return fclose($stream);
862871
}
863872
}
@@ -931,6 +940,7 @@ private function readPath(string $path, $isRecursive = false): array
931940
if (!empty($path)
932941
&& $path !== $relativePath
933942
&& (!$relativePath || strpos($path, $relativePath) === 0)) {
943+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
934944
$itemsList[] = $this->getAbsolutePath(dirname($path), $path);
935945
}
936946
}

app/code/Magento/AwsS3/Test/Unit/Driver/AwsS3Test.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function testGetAbsolutePath($basePath, $path, string $expected): void
6464

6565
/**
6666
* @return array
67+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
6768
*/
6869
public function getAbsolutePathDataProvider(): array
6970
{
@@ -407,6 +408,18 @@ public function getRealPathSafetyDataProvider(): array
407408
[
408409
'test/test/../test.txt',
409410
'test/test.txt'
411+
],
412+
[
413+
'test//test/../test.txt',
414+
'test/test.txt'
415+
],
416+
[
417+
'test1///test2/..//test3//test.txt',
418+
'test1/test3/test.txt'
419+
],
420+
[
421+
self::URL . '/test1///test2/..//test3//test.txt',
422+
self::URL . 'test1/test3/test.txt'
410423
]
411424
];
412425
}

app/code/Magento/Backend/Block/Widget/Grid/Column.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Backend\Block\Widget\Grid;
78

89
use Magento\Backend\Block\Widget;
@@ -46,7 +47,7 @@ class Column extends Widget
4647
protected $_cssClass = null;
4748

4849
/**
49-
* Renderer types
50+
* The renderer types
5051
*
5152
* @var array
5253
*/
@@ -74,7 +75,7 @@ class Column extends Widget
7475
];
7576

7677
/**
77-
* Filter types
78+
* The filter types
7879
*
7980
* @var array
8081
*/
@@ -103,6 +104,8 @@ class Column extends Widget
103104
protected $_isGrouped = false;
104105

105106
/**
107+
* Set property is grouped.
108+
*
106109
* @return void
107110
*/
108111
public function _construct()
@@ -169,7 +172,8 @@ public function getHtmlProperty()
169172
}
170173

171174
/**
172-
* Get Header html
175+
* This method get Header html.
176+
*
173177
* @return string
174178
*/
175179
public function getHeaderHtml()
@@ -222,7 +226,8 @@ public function setSortable($value)
222226
}
223227

224228
/**
225-
* Get header css class name
229+
* Get header css class name.
230+
*
226231
* @return string
227232
*/
228233
public function getHeaderCssClass()
@@ -234,6 +239,8 @@ public function getHeaderCssClass()
234239
}
235240

236241
/**
242+
* This method check if is sortable.
243+
*
237244
* @return bool
238245
* @SuppressWarnings(PHPMD.BooleanGetMethodName)
239246
*/
@@ -256,6 +263,7 @@ public function addHeaderCssClass($className)
256263

257264
/**
258265
* Get header class names
266+
*
259267
* @return string
260268
*/
261269
public function getHeaderHtmlProperty()
@@ -291,6 +299,7 @@ public function getRowField(\Magento\Framework\DataObject $row)
291299
$frameCallback = $this->getFrameCallback();
292300
if (is_array($frameCallback)) {
293301
$this->validateFrameCallback($frameCallback);
302+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
294303
$renderedValue = call_user_func($frameCallback, $renderedValue, $row, $this, false);
295304
}
296305

@@ -334,6 +343,7 @@ public function getRowFieldExport(\Magento\Framework\DataObject $row)
334343
$frameCallback = $this->getFrameCallback();
335344
if (is_array($frameCallback)) {
336345
$this->validateFrameCallback($frameCallback);
346+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
337347
$renderedValue = call_user_func($frameCallback, $renderedValue, $row, $this, true);
338348
}
339349

@@ -412,12 +422,8 @@ public function setRendererType($type, $className)
412422
*/
413423
protected function _getRendererByType()
414424
{
415-
$type = strtolower($this->getType());
416-
$rendererClass = isset(
417-
$this->_rendererTypes[$type]
418-
) ? $this->_rendererTypes[$type] : $this->_rendererTypes['default'];
419-
420-
return $rendererClass;
425+
$type = strtolower((string) $this->getType());
426+
return $this->_rendererTypes[$type] ?? $this->_rendererTypes['default'];
421427
}
422428

423429
/**
@@ -469,10 +475,8 @@ public function setFilterType($type, $className)
469475
*/
470476
protected function _getFilterByType()
471477
{
472-
$type = $this->getFilterType() ? strtolower($this->getFilterType()) : strtolower($this->getType());
473-
$filterClass = isset($this->_filterTypes[$type]) ? $this->_filterTypes[$type] : $this->_filterTypes['default'];
474-
475-
return $filterClass;
478+
$type = $this->getFilterType() ? strtolower($this->getFilterType()) : strtolower((string) $this->getType());
479+
return $this->_filterTypes[$type] ?? $this->_filterTypes['default'];
476480
}
477481

478482
/**

app/code/Magento/Backend/Block/Widget/Grid/Column/Filter/Date.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ protected function _convertDate($date)
233233
\IntlDateFormatter::NONE,
234234
$adminTimeZone
235235
);
236-
$simpleRes = new \DateTime(null, $adminTimeZone);
236+
$simpleRes = new \DateTime('now', $adminTimeZone);
237237
$simpleRes->setTimestamp($formatter->parse($date));
238238
$simpleRes->setTime(0, 0, 0);
239239
$simpleRes->setTimezone(new \DateTimeZone('UTC'));

app/code/Magento/Backend/Block/Widget/Grid/Column/Renderer/Concat.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ public function render(\Magento\Framework\DataObject $row)
3030
&& is_callable([$row, $method])
3131
&& substr_compare('get', $method, 1, 3) !== 0
3232
) {
33+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
3334
$data = call_user_func([$row, $method]);
3435
} else {
3536
$data = $row->getData($method);
3637
}
37-
if (strlen($data) > 0) {
38+
if (strlen((string) $data) > 0) {
3839
$dataArr[] = $data;
3940
}
4041
}

app/code/Magento/Bundle/Model/Option/Validator.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ public function __construct(NotEmptyFactory $notEmptyFactory)
2626
}
2727

2828
/**
29+
* This method check is valid value.
30+
*
2931
* @param \Magento\Bundle\Model\Option $value
32+
*
3033
* @return boolean
3134
* @throws Zend_Validate_Exception If validation of $value is impossible
3235
*/
@@ -38,10 +41,12 @@ public function isValid($value)
3841
}
3942

4043
/**
44+
* This method validate required fields.
45+
*
4146
* @param \Magento\Bundle\Model\Option $value
47+
*
4248
* @return void
43-
* @throws Zend_Validate_Exception
44-
* @throws \Exception
49+
* @throws \Exception|Zend_Validate_Exception
4550
*/
4651
protected function validateRequiredFields($value)
4752
{
@@ -51,7 +56,7 @@ protected function validateRequiredFields($value)
5156
'type' => $value->getType()
5257
];
5358
foreach ($requiredFields as $requiredField => $requiredValue) {
54-
if (!$this->notEmpty->isValid(trim($requiredValue))) {
59+
if (!$this->notEmpty->isValid(trim((string) $requiredValue))) {
5560
$messages[$requiredField] =
5661
__('"%fieldName" is required. Enter and try again.', ['fieldName' => $requiredField]);
5762
}

0 commit comments

Comments
 (0)