Skip to content

Commit 71f9114

Browse files
committed
#34505: fixes after CR
1 parent c0a2ca5 commit 71f9114

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,8 @@ public function getAbsolutePath($basePath, $path, $scheme = null)
960960
// check if the path given is already an absolute path containing the
961961
// basepath. so if the basepath starts at position 0 in the path, we
962962
// must not concatinate them again because path is already absolute.
963-
if ($path && strpos($path, $basePath) === 0) {
963+
$path = $path !== null ? $path : '';
964+
if ('' !== $basePath && strpos($path, $basePath) === 0) {
964965
return $this->getScheme($scheme) . $path;
965966
}
966967

@@ -976,7 +977,7 @@ public function getAbsolutePath($basePath, $path, $scheme = null)
976977
*/
977978
public function getRelativePath($basePath, $path = null)
978979
{
979-
$path = $this->fixSeparator($path);
980+
$path = $path !== null ? $this->fixSeparator($path) : '';
980981
if (strpos($path, $basePath) === 0 || $basePath == $path . '/') {
981982
$result = substr($path, strlen($basePath));
982983
} else {
@@ -995,7 +996,7 @@ public function getRelativePath($basePath, $path = null)
995996
*/
996997
protected function fixSeparator($path)
997998
{
998-
return $path ? str_replace('\\', '/', $path) : '';
999+
return str_replace('\\', '/', $path);
9991000
}
10001001

10011002
/**

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/Timezone.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,11 @@ public function formatDateTime(
310310
}
311311

312312
$formatter = $this->dateFormatterFactory->create(
313-
(string) $locale ?: $this->_localeResolver->getLocale(),
314-
(int) $dateType ?: \IntlDateFormatter::SHORT,
315-
(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),
316318
null,
317319
false
318320
);

0 commit comments

Comments
 (0)