Skip to content

Commit cf3f712

Browse files
committed
Apply fixed Coderabbitai review.
1 parent fcd4ae7 commit cf3f712

4 files changed

Lines changed: 25 additions & 3 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## 0.1.0 Under development
99

10-
- feat: add framework agnostic debug snapshot contracts, strict JSON hydration, and filesystem persistence.
10+
- feat: add framework-agnostic debug snapshot contracts, strict JSON hydration, and filesystem persistence.

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ instead of requiring this package directly.
77

88
## Installation
99

10+
Adapter packages install Debug Core transitively. If you develop an adapter, run:
11+
1012
```shell
1113
composer require php-forge/debug-core
1214
```

‎src/Storage/SnapshotStore.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ private function initialize(): void
383383
*/
384384
private static function isValidTag(string $tag): bool
385385
{
386-
return $tag !== 'index' && $tag !== '' && preg_match('/\A[A-Za-z0-9._-]+\z/D', $tag) === 1;
386+
return $tag !== 'index' && preg_match('/\A(?!-?(?:0|[1-9][0-9]*)\z)[A-Za-z0-9._-]+\z/D', $tag) === 1;
387387
}
388388

389389
/**

‎tests/Storage/SnapshotStoreTest.php‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace PHPForge\Debug\Tests\Storage;
66

77
use PHPForge\Debug\Storage\{DebugSnapshot, RequestSummary, SnapshotStore, StorageException};
8-
use PHPUnit\Framework\Attributes\Group;
8+
use PHPUnit\Framework\Attributes\{Group, TestWith};
99
use PHPUnit\Framework\TestCase;
1010
use Xepozz\InternalMocker\MockerState;
1111

@@ -269,6 +269,26 @@ public function testThrowStorageExceptionForNegativeHistorySize(): void
269269
}
270270
}
271271

272+
/**
273+
* @param string $tag Numeric tag.
274+
*/
275+
#[TestWith(['0'])]
276+
#[TestWith(['7'])]
277+
public function testThrowStorageExceptionForNumericTag(string $tag): void
278+
{
279+
$summary = $this->summary($tag, 1_700_000_000.0);
280+
281+
$this->expectException(StorageException::class);
282+
$this->expectExceptionMessage(
283+
"Invalid debug snapshot tag: {$tag}",
284+
);
285+
286+
$this->store()->writeSnapshot(
287+
new DebugSnapshot($summary, [], []),
288+
10,
289+
);
290+
}
291+
272292
public function testThrowStorageExceptionForReservedManifestTag(): void
273293
{
274294
$summary = $this->summary('index', 1_700_000_000.0);

0 commit comments

Comments
 (0)