샘플
ramsey/uuid 4.9.3: Choose between UUID v4 and v7, store and parse them, and compare two UUID objects without == lying
검증된 샘플 — composer ramsey/uuid 4.9.3: Choose between UUID v4 and v7, store and parse them, and compare two UUID objects without == lying. php 8 · linux…
sha256:cb72d4e173a50eea0fa041bc7cd6aef4a9a8ee7ed38e381f613e71c9c6d7b152
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
php 8 linux x64 php 8 php composer
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| php 8 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · composer@1 |
2026-08-14 |
케이스
HOW- 목표
- Choose between UUID v4 and v7, store and parse them, and compare two UUID objects without == lying
- 심벌
-
- Ramsey.Uuid.Uuid
- Uuid::uuid4
- Uuid::uuid7
- Uuid::fromString
- Uuid::fromBytes
- Uuid::isValid
- Uuid::NIL
- Uuid::MAX
- UuidInterface::toString
- UuidInterface::getBytes
- UuidInterface::getVersion
- UuidInterface::equals
- UuidInterface::compareTo
- Ramsey.Uuid.Lazy.LazyUuidFromString
- Ramsey.Uuid.Rfc4122.FieldsInterface
- Ramsey.Uuid.Exception.InvalidUuidStringException
- Ramsey.Uuid.Exception.UnsupportedOperationException
- 환경
- php 8
- 생성일
- 2026-08-14T20:28:25Z
컨트랙트
- assert a bare loop of 32 uuid7 values sorts into creation order both as canonical strings and as the 16 raw bytes, and that the whole burst shares its leading 8 hex digits
- assert a uuid4 batch of the same size does not come back sorted and shares no leading digits, while both versions still pin the version nibble at position 14 and the variant nibble at position 19
- assert uuid7 accepts an instant and writes the Unix time in milliseconds into the first 12 hex digits, so two values built from known instants order by plain string comparison
- assert getDateTime on a uuid4 throws UnsupportedOperationException with the message Not a time-based UUID rather than returning null
- assert toString is 36 characters while getBytes is 16, that getBytes is raw binary rather than the hex digits, and that bin2hex of it equals getHex which is 32 characters
- assert a UUID round trips through fromBytes of its own getBytes
- assert fromString on a malformed string throws InvalidUuidStringException whose message echoes the input, and that the exception is both an SPL InvalidArgumentException and a UuidExceptionInterface
- assert isValid and fromString are different predicates: the hyphenless 32-character hex form is rejected by isValid and parses fine through fromString
- assert the plain, braced, urn and uppercase spellings all pass isValid and all normalise to the same lowercase canonical string
- assert Uuid::NIL is 16 zero bytes with integer 0 and Uuid::MAX is 16 0xff bytes with integer 2**128-1, and that isValid accepts both
- assert getVersion returns null for the nil and max UUIDs rather than 0 and 15, and that their variants are RESERVED_NCS and RESERVED_FUTURE rather than RFC_4122
- assert isNil is declared on the Rfc4122 fields interface while isMax exists only on the concrete Fields class, so interface-typed code can detect nil and not max
- assert a generated UUID compares strictly between the nil and the max UUID
- assert Uuid::uuid4 and Uuid::uuid7 return LazyUuidFromString proxies that are not instances of UuidV4, UuidV7 or Ramsey\Uuid\Uuid while still reporting version 4 and 7
- assert == is true for two freshly parsed UUIDs of the same value, turns false once a read unwraps one side, and turns true again once the other is unwrapped, while equals and compareTo stay stable throughout
- assert the braced spelling decodes to a concrete UuidV7 that is == false and equals true against the proxy built from the same string, so in_array misses it at either strictness
- assert equals with a string argument is a TypeError while equals with null or a plain object returns false
파일
- composer.json
- composer.lock
- csx.json
- phpunit.xml
- src/UuidVersions.php
- test/UuidVersionsTest.php