Skip to content

Commit fc97172

Browse files
authored
Update msq.php
1 parent 60d3678 commit fc97172

File tree

1 file changed

+17
-26
lines changed
  • src/Magento/FunctionalTestingFramework/Util

1 file changed

+17
-26
lines changed
Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,28 @@
11
<?php
2-
3-
declare(strict_types=1);
4-
52
/**
63
* Copyright © Magento, Inc. All rights reserved.
74
* See COPYING.txt for license details.
85
*/
9-
6+
107
use Magento\FunctionalTestingFramework\Module\MagentoSequence;
118

129
if (!function_exists('msq')) {
1310
/**
1411
* Return unique sequence within test.
1512
*
16-
* @param int|string|null $id Optional identifier for the sequence.
17-
* @return string The generated unique sequence.
13+
* @param null $id
14+
* @return string
1815
*/
19-
function msq(int|string|null $id = null): string
16+
function msq(int|string|null $id = null)
2017
{
21-
if ($id !== null && isset(MagentoSequence::$hash[$id])) {
18+
if ($id and isset(MagentoSequence::$hash[$id])) {
2219
return MagentoSequence::$hash[$id];
2320
}
24-
25-
$prefix = MagentoSequence::$prefix ?? '';
26-
$sequence = $prefix . uniqid('', true); // Use true for high-entropy ID
27-
28-
if ($id !== null) {
29-
MagentoSequence::$hash[$id] = $sequence; // Avoid dynamic properties
21+
$prefix = MagentoSequence::$prefix;
22+
$sequence = $prefix . uniqid();
23+
if ($id) {
24+
MagentoSequence::$hash[$id] = $sequence;
3025
}
31-
3226
return $sequence;
3327
}
3428
}
@@ -37,22 +31,19 @@ function msq(int|string|null $id = null): string
3731
/**
3832
* Return unique sequence within suite.
3933
*
40-
* @param int|string|null $id Optional identifier for the suite sequence.
41-
* @return string The generated unique suite sequence.
34+
* @param null $id
35+
* @return string
4236
*/
43-
function msqs(int|string|null $id = null): string
37+
function msqs(int|string|null $id = null)
4438
{
45-
if ($id !== null && isset(MagentoSequence::$suiteHash[$id])) {
39+
if ($id and isset(MagentoSequence::$suiteHash[$id])) {
4640
return MagentoSequence::$suiteHash[$id];
4741
}
48-
49-
$prefix = MagentoSequence::$prefix ?? '';
50-
$sequence = $prefix . uniqid('', true); // Use true for high-entropy ID
51-
52-
if ($id !== null) {
53-
MagentoSequence::$suiteHash[$id] = $sequence; // Avoid dynamic properties
42+
$prefix = MagentoSequence::$prefix;
43+
$sequence = $prefix . uniqid();
44+
if ($id) {
45+
MagentoSequence::$suiteHash[$id] = $sequence;
5446
}
55-
5647
return $sequence;
5748
}
5849
}

0 commit comments

Comments
 (0)