Skip to content

Commit becb0e0

Browse files
#24036: Static tests fix.
1 parent a62fdba commit becb0e0

File tree

7 files changed

+58
-34
lines changed

7 files changed

+58
-34
lines changed

app/code/Magento/Deploy/Model/Filesystem.php

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -285,22 +285,7 @@ public function cleanupFilesystem($directoryCodeList)
285285
$excludePatterns = ['#.htaccess#', '#deployed_version.txt#'];
286286
foreach ($directoryCodeList as $code) {
287287
if ($code == DirectoryList::STATIC_VIEW) {
288-
$directoryPath = $this->directoryList->getPath(DirectoryList::STATIC_VIEW);
289-
if ($this->driverFile->isExists($directoryPath)) {
290-
$files = $this->driverFile->readDirectory($directoryPath);
291-
foreach ($files as $file) {
292-
foreach ($excludePatterns as $pattern) {
293-
if (preg_match($pattern, $file)) {
294-
continue 2;
295-
}
296-
}
297-
if ($this->driverFile->isFile($file)) {
298-
$this->driverFile->deleteFile($file);
299-
} else {
300-
$this->driverFile->deleteDirectory($file);
301-
}
302-
}
303-
}
288+
$this->cleanupStaticDirectory($excludePatterns);
304289
} else {
305290
$this->filesystem->getDirectoryWrite($code)
306291
->delete();
@@ -374,4 +359,30 @@ private function reinitCacheDirectories()
374359
$command = $this->functionCallPath . 'cache:flush';
375360
$this->shell->execute($command);
376361
}
362+
363+
/**
364+
* Cleanup directory with static view files.
365+
*
366+
* @param array $excludePatterns
367+
* @throws \Magento\Framework\Exception\FileSystemException
368+
*/
369+
private function cleanupStaticDirectory(array $excludePatterns): void
370+
{
371+
$directoryPath = $this->directoryList->getPath(DirectoryList::STATIC_VIEW);
372+
if ($this->driverFile->isExists($directoryPath)) {
373+
$files = $this->driverFile->readDirectory($directoryPath);
374+
foreach ($files as $file) {
375+
foreach ($excludePatterns as $pattern) {
376+
if (preg_match($pattern, $file)) {
377+
continue 2;
378+
}
379+
}
380+
if ($this->driverFile->isFile($file)) {
381+
$this->driverFile->deleteFile($file);
382+
} else {
383+
$this->driverFile->deleteDirectory($file);
384+
}
385+
}
386+
}
387+
}
377388
}

app/code/Magento/Indexer/Model/Message/Invalid.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public function isDisplayed()
5959
*/
6060
public function getIdentity()
6161
{
62+
// phpcs:ignore Magento2.Security.InsecureFunction
6263
return md5('INDEX_INVALID');
6364
}
6465

app/code/Magento/Payment/Model/Method/AbstractMethod.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
/**
1919
* Payment method abstract model
2020
*
21+
* phpcs:disable Magento2.Classes.AbstractApi
2122
* @api
2223
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
2324
* @SuppressWarnings(PHPMD.TooManyFields)

dev/tests/static/framework/Magento/Sniffs/Less/ClassNamingSniff.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ public function process(File $phpcsFile, $stackPtr)
4949
$tokens = $phpcsFile->getTokens();
5050

5151
if (T_WHITESPACE !== $tokens[$stackPtr - 1]['code']
52-
&& !in_array($tokens[$stackPtr - 1]['content'], [
53-
TokenizerSymbolsInterface::INDENT_SPACES,
54-
TokenizerSymbolsInterface::NEW_LINE,
55-
])
52+
&& !in_array(
53+
$tokens[$stackPtr - 1]['content'],
54+
[
55+
TokenizerSymbolsInterface::INDENT_SPACES,
56+
TokenizerSymbolsInterface::NEW_LINE,
57+
]
58+
)
5659
) {
5760
return;
5861
}

dev/tests/static/framework/Magento/Sniffs/Less/IndentationSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public function process(File $phpcsFile, $stackPtr)
9797
$phpcsFile->addError($error, $i, 'Incorrect', [$expectedIndent, $foundIndent]);
9898
}
9999

100+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
100101
if ($indentLevel > $this->maxIndentLevel) {
101102
// Will be implemented in MAGETWO-49778
102103
// $phpcsFile->addWarning('Avoid using more than three levels of nesting', $i, 'IncorrectNestingLevel');

dev/tests/static/framework/Magento/Sniffs/Less/TypeSelectorsSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function process(File $phpcsFile, $stackPtr)
8181
return;
8282
}
8383

84+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
8485
if ((T_STRING === $tokens[$stackPtr - 1]['code'])
8586
&& in_array($tokens[$stackPtr - 1]['content'], $this->tags)
8687
) {

setup/src/Magento/Setup/Model/SystemPackage.php

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public function __construct(
5353
/**
5454
* Returns system package and available versions
5555
*
56-
* @throws \RuntimeException
5756
* @return array
57+
* @throws \RuntimeException
5858
*/
5959
public function getPackageVersions()
6060
{
@@ -150,7 +150,7 @@ public function getSystemPackageVersions($systemPackageInfo)
150150
'current' => true,
151151
];
152152
}
153-
return $versions;
153+
return $versions;
154154
}
155155

156156
/**
@@ -196,12 +196,15 @@ public function getInstalledSystemPackages()
196196
*/
197197
public function sortVersions($enterpriseVersions)
198198
{
199-
usort($enterpriseVersions[InfoCommand::AVAILABLE_VERSIONS], function ($versionOne, $versionTwo) {
200-
if (version_compare($versionOne, $versionTwo, '==')) {
201-
return 0;
199+
usort(
200+
$enterpriseVersions[InfoCommand::AVAILABLE_VERSIONS],
201+
function ($versionOne, $versionTwo) {
202+
if (version_compare($versionOne, $versionTwo, '==')) {
203+
return 0;
204+
}
205+
return (version_compare($versionOne, $versionTwo, '<')) ? 1 : -1;
202206
}
203-
return (version_compare($versionOne, $versionTwo, '<')) ? 1 : -1;
204-
});
207+
);
205208

206209
return $enterpriseVersions;
207210
}
@@ -231,15 +234,18 @@ private function formatPackages($packages)
231234
}
232235
}
233236

234-
usort($versions, function ($versionOne, $versionTwo) {
235-
if (version_compare($versionOne['id'], $versionTwo['id'], '==')) {
236-
if ($versionOne['package'] === static::EDITION_COMMUNITY) {
237-
return 1;
237+
usort(
238+
$versions,
239+
function ($versionOne, $versionTwo) {
240+
if (version_compare($versionOne['id'], $versionTwo['id'], '==')) {
241+
if ($versionOne['package'] === static::EDITION_COMMUNITY) {
242+
return 1;
243+
}
244+
return 0;
238245
}
239-
return 0;
246+
return (version_compare($versionOne['id'], $versionTwo['id'], '<')) ? 1 : -1;
240247
}
241-
return (version_compare($versionOne['id'], $versionTwo['id'], '<')) ? 1 : -1;
242-
});
248+
);
243249

244250
return $versions;
245251
}

0 commit comments

Comments
 (0)