Skip to content

Commit 3d256cf

Browse files
author
github-ci
committed
daily
1 parent b93f094 commit 3d256cf

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

src/Service/Snowflake.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ class Snowflake
2727
public static function getGenerator(int $datacenter = -1, int $workerId = -1, ?SequenceResolver $resolver = null): BaseSnowflake
2828
{
2929
$key = "{$datacenter}-{$workerId}";
30-
if (!isset(static::$generators[$key])) {
30+
if (!isset(self::$generators[$key])) {
3131
$generator = new BaseSnowflake(
3232
$datacenter,
3333
$workerId,
3434
);
3535
$generator->setSequenceResolver($resolver ?: new RandomSequenceResolver());
36-
static::$generators[$key] = $generator;
36+
self::$generators[$key] = $generator;
3737
}
38-
return static::$generators[$key];
38+
return self::$generators[$key];
3939
}
4040

4141
private BaseSnowflake $generator;

tests/Integration/SnowflakeIntegrationTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ public function test_snowflakeService_generatesValidIds(): void
6363
$id2 = $snowflake->id();
6464

6565
// 验证生成的ID是字符串
66-
$this->assertIsString($id1);
67-
$this->assertIsString($id2);
6866

6967
// 验证ID是数字字符串
7068
$this->assertIsNumeric($id1);
@@ -140,7 +138,6 @@ public function test_services_lifecycle(): void
140138

141139
// 验证服务可以正常工作
142140
$id1 = $snowflake->id();
143-
$this->assertIsString($id1);
144141
$this->assertIsNumeric($id1);
145142

146143
// 再次获取服务,应该是同一个实例
@@ -177,7 +174,6 @@ public function test_snowflakeService_largeBatchGeneration(): void
177174

178175
// 验证ID的格式
179176
foreach ($ids as $id) {
180-
$this->assertIsString($id);
181177
$this->assertIsNumeric($id);
182178
$this->assertGreaterThan(0, intval($id));
183179
}
@@ -198,7 +194,6 @@ public function test_services_workInDifferentContainerStates(): void
198194
$id1 = $snowflake->id();
199195

200196
// 验证初始ID
201-
$this->assertIsString($id1);
202197
$this->assertIsNumeric($id1);
203198

204199
// 再次使用服务
@@ -239,7 +234,6 @@ public function test_bundle_configurationLoaded(): void
239234

240235
// 验证服务功能
241236
$id = $snowflake->id();
242-
$this->assertIsString($id);
243237
$this->assertIsNumeric($id);
244238
}
245239

tests/Service/SnowflakeTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public function test_generateWorkerId_handlesVariousInputs(string $hostname, int
5050
// 验证workerId在预期范围内
5151
$this->assertGreaterThanOrEqual(0, $workerId);
5252
$this->assertLessThanOrEqual($expectedInRange, $workerId);
53-
$this->assertIsInt($workerId);
5453
}
5554

5655
/**
@@ -129,7 +128,6 @@ public function test_id_returnsValidSnowflakeId(): void
129128
$id = $snowflake->id();
130129

131130
// 验证ID是一个非空字符串
132-
$this->assertIsString($id);
133131
$this->assertNotEmpty($id);
134132

135133
// 验证ID是一个数字字符串
@@ -222,8 +220,7 @@ public function test_multipleInstances_operateIndependently(): void
222220
$this->assertNotEquals($id1, $id2);
223221

224222
// 都应该是有效的ID
225-
$this->assertIsString($id1);
226-
$this->assertIsString($id2);
223+
227224
$this->assertIsNumeric($id1);
228225
$this->assertIsNumeric($id2);
229226
}

0 commit comments

Comments
 (0)