Skip to content

Commit abb854b

Browse files
committed
Declare more types in method signatures
1 parent 6951a3f commit abb854b

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

src/Codeception/Module/Sequence.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,14 @@
100100
*/
101101
class Sequence extends Module
102102
{
103+
/**
104+
* @var array<int|string,string>
105+
*/
103106
public static array $hash = [];
104107

108+
/**
109+
* @var array<int|string,string>
110+
*/
105111
public static array $suiteHash = [];
106112

107113
public static string $prefix = '';
@@ -111,17 +117,17 @@ class Sequence extends Module
111117
*/
112118
protected array $config = ['prefix' => '{id}_'];
113119

114-
public function _initialize()
120+
public function _initialize(): void
115121
{
116122
static::$prefix = $this->config['prefix'];
117123
}
118124

119-
public function _after(TestInterface $t)
125+
public function _after(TestInterface $test): void
120126
{
121127
self::$hash = [];
122128
}
123129

124-
public function _afterSuite()
130+
public function _afterSuite(): void
125131
{
126132
self::$suiteHash = [];
127133
}

src/Codeception/Util/sq.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
use Codeception\Module\Sequence;
66

77
if (!function_exists('sq')) {
8-
function sq($id = null)
8+
function sq(int|string $id = null): string
99
{
1010
if ($id && isset(Sequence::$hash[$id])) {
1111
return Sequence::$hash[$id];
1212
}
1313

14-
$prefix = str_replace('{id}', $id, Sequence::$prefix);
15-
$sequence = $prefix . uniqid($id);
14+
$prefix = str_replace('{id}', (string)$id, Sequence::$prefix);
15+
$sequence = $prefix . uniqid((string)$id);
1616
if ($id) {
1717
Sequence::$hash[$id] = $sequence;
1818
}
@@ -22,14 +22,14 @@ function sq($id = null)
2222
}
2323

2424
if (!function_exists('sqs')) {
25-
function sqs($id = null)
25+
function sqs(int|string $id = null): string
2626
{
2727
if ($id && isset(Sequence::$suiteHash[$id])) {
2828
return Sequence::$suiteHash[$id];
2929
}
3030

31-
$prefix = str_replace('{id}', $id, Sequence::$prefix);
32-
$sequence = $prefix . uniqid($id);
31+
$prefix = str_replace('{id}', (string)$id, Sequence::$prefix);
32+
$sequence = $prefix . uniqid((string)$id);
3333
if ($id) {
3434
Sequence::$suiteHash[$id] = $sequence;
3535
}

0 commit comments

Comments
 (0)