From 8bbf4953a474747ac22dfeb3683a303b2045db03 Mon Sep 17 00:00:00 2001 From: GeorgII Date: Wed, 26 Nov 2025 23:14:20 +0100 Subject: [PATCH 1/2] Add examples to PHPdoc for typed values and introduce FloatType, IntType, and StrType alias classes - Enhanced PHPdoc comments across multiple classes with usage examples for clarity and better documentation. - Introduced alias classes (`FloatType`, `IntType`, `StrType`) for core types to improve extensibility and consistency. - Updated `psalmTest.php` with added alias usage demonstrations. --- src/DateTime/DateTimeAtom.php | 2 ++ src/DateTime/DateTimeRFC3339.php | 2 ++ src/DateTime/DateTimeRFC3339Extended.php | 4 +++- src/DateTime/DateTimeW3C.php | 2 ++ src/DateTime/Timestamp/TimestampMilliseconds.php | 4 +++- src/DateTime/Timestamp/TimestampSeconds.php | 4 +++- src/Float/Alias/FloatType.php | 14 ++++++++++++++ src/Float/Alias/NonNegativeFloat.php | 4 ++++ src/Float/FloatNonNegative.php | 4 ++++ src/Float/FloatStandard.php | 2 ++ src/Integer/Alias/Id.php | 4 ++++ src/Integer/Alias/IntType.php | 14 ++++++++++++++ src/Integer/Alias/NonNegativeInt.php | 4 ++++ src/Integer/Alias/PositiveInt.php | 4 ++++ src/Integer/IntegerNonNegative.php | 4 ++++ src/Integer/IntegerPositive.php | 4 ++++ src/Integer/IntegerStandard.php | 4 ++++ src/Integer/IntegerWeekDay.php | 4 ++++ src/String/Alias/NonEmptyStr.php | 4 ++++ src/String/Alias/StrType.php | 14 ++++++++++++++ src/String/DB/StringVarChar255.php | 4 ++++ src/String/StringNonEmpty.php | 4 ++++ src/String/StringStandard.php | 2 ++ src/String/StringUuidV4.php | 2 ++ src/String/StringUuidV7.php | 2 ++ src/psalmTest.php | 6 ++++++ 26 files changed, 119 insertions(+), 3 deletions(-) create mode 100755 src/Float/Alias/FloatType.php create mode 100755 src/Integer/Alias/IntType.php create mode 100755 src/String/Alias/StrType.php diff --git a/src/DateTime/DateTimeAtom.php b/src/DateTime/DateTimeAtom.php index c5dcec6..89af691 100755 --- a/src/DateTime/DateTimeAtom.php +++ b/src/DateTime/DateTimeAtom.php @@ -14,6 +14,8 @@ /** * ATOM RFC 3339 format based on ISO 8601. * + * Example "2025-01-02T03:04:05+00:00" + * * @psalm-immutable */ readonly class DateTimeAtom extends DateTimeType diff --git a/src/DateTime/DateTimeRFC3339.php b/src/DateTime/DateTimeRFC3339.php index 34053b2..7fae8f9 100755 --- a/src/DateTime/DateTimeRFC3339.php +++ b/src/DateTime/DateTimeRFC3339.php @@ -14,6 +14,8 @@ /** * RFC 3339 format based on ISO 8601. * + * Example "2025-01-02T03:04:05+00:00" + * * @psalm-immutable */ readonly class DateTimeRFC3339 extends DateTimeType diff --git a/src/DateTime/DateTimeRFC3339Extended.php b/src/DateTime/DateTimeRFC3339Extended.php index 7ab97c4..6970a2c 100755 --- a/src/DateTime/DateTimeRFC3339Extended.php +++ b/src/DateTime/DateTimeRFC3339Extended.php @@ -12,7 +12,9 @@ use PhpTypedValues\Code\Exception\DateTimeTypeException; /** - * RFC 3339 EXTENDED format based on ISO 8601. + * RFC 3339 EXTENDED format based on ISO 8601 (with microseconds). + * + * Example "2025-01-02T03:04:05.123456+00:00" * * @psalm-immutable */ diff --git a/src/DateTime/DateTimeW3C.php b/src/DateTime/DateTimeW3C.php index f9e0a5b..a176646 100755 --- a/src/DateTime/DateTimeW3C.php +++ b/src/DateTime/DateTimeW3C.php @@ -14,6 +14,8 @@ /** * W3C RFC 3339 format based on ISO 8601. * + * Example "2025-01-02T03:04:05+00:00" + * * @psalm-immutable */ readonly class DateTimeW3C extends DateTimeType diff --git a/src/DateTime/Timestamp/TimestampMilliseconds.php b/src/DateTime/Timestamp/TimestampMilliseconds.php index 65b360b..3f5222f 100755 --- a/src/DateTime/Timestamp/TimestampMilliseconds.php +++ b/src/DateTime/Timestamp/TimestampMilliseconds.php @@ -12,7 +12,9 @@ use function sprintf; /** - * Unix timestamp in milliseconds since Unix epoch (UTC), e.g. "1732445696123". + * Unix timestamp in milliseconds since Unix epoch (UTC). + * + * Example "1732445696123" * * @psalm-immutable */ diff --git a/src/DateTime/Timestamp/TimestampSeconds.php b/src/DateTime/Timestamp/TimestampSeconds.php index db7ca77..45eaf11 100755 --- a/src/DateTime/Timestamp/TimestampSeconds.php +++ b/src/DateTime/Timestamp/TimestampSeconds.php @@ -9,7 +9,9 @@ use PhpTypedValues\Code\Exception\DateTimeTypeException; /** - * Unix timestamp (seconds since Unix epoch, UTC), e.g. "1732445696". + * Unix timestamp (seconds since Unix epoch, UTC). + * + * Example "1732445696" * * @psalm-immutable */ diff --git a/src/Float/Alias/FloatType.php b/src/Float/Alias/FloatType.php new file mode 100755 index 0000000..d05d7b3 --- /dev/null +++ b/src/Float/Alias/FloatType.php @@ -0,0 +1,14 @@ += 0.0). + * + * Example "0.0" + * * @psalm-immutable */ readonly class NonNegativeFloat extends FloatNonNegative diff --git a/src/Float/FloatNonNegative.php b/src/Float/FloatNonNegative.php index 21ac733..5500c03 100755 --- a/src/Float/FloatNonNegative.php +++ b/src/Float/FloatNonNegative.php @@ -10,6 +10,10 @@ use function sprintf; /** + * Non-negative float (>= 0.0). + * + * Example "0.0" + * * @psalm-immutable */ readonly class FloatNonNegative extends FloatType diff --git a/src/Float/FloatStandard.php b/src/Float/FloatStandard.php index 5aea4f7..2c4d058 100755 --- a/src/Float/FloatStandard.php +++ b/src/Float/FloatStandard.php @@ -10,6 +10,8 @@ /** * Represents any PHP float (double). * + * Example "3.14" + * * @psalm-immutable */ readonly class FloatStandard extends FloatType diff --git a/src/Integer/Alias/Id.php b/src/Integer/Alias/Id.php index 1f280f1..d5c4855 100755 --- a/src/Integer/Alias/Id.php +++ b/src/Integer/Alias/Id.php @@ -7,6 +7,10 @@ use PhpTypedValues\Integer\IntegerPositive; /** + * Alias of Positive integer used as identifier. + * + * Example "42" + * * @psalm-immutable */ readonly class Id extends IntegerPositive diff --git a/src/Integer/Alias/IntType.php b/src/Integer/Alias/IntType.php new file mode 100755 index 0000000..9e56f57 --- /dev/null +++ b/src/Integer/Alias/IntType.php @@ -0,0 +1,14 @@ += 0). + * + * Example "0" + * * @psalm-immutable */ readonly class NonNegativeInt extends IntegerNonNegative diff --git a/src/Integer/Alias/PositiveInt.php b/src/Integer/Alias/PositiveInt.php index 7e62b13..eb1db1d 100755 --- a/src/Integer/Alias/PositiveInt.php +++ b/src/Integer/Alias/PositiveInt.php @@ -7,6 +7,10 @@ use PhpTypedValues\Integer\IntegerPositive; /** + * Alias of Positive integer (> 0). + * + * Example "1" + * * @psalm-immutable */ readonly class PositiveInt extends IntegerPositive diff --git a/src/Integer/IntegerNonNegative.php b/src/Integer/IntegerNonNegative.php index f8fcd65..95cb435 100755 --- a/src/Integer/IntegerNonNegative.php +++ b/src/Integer/IntegerNonNegative.php @@ -10,6 +10,10 @@ use function sprintf; /** + * Non-negative integer (>= 0). + * + * Example "0" + * * @psalm-immutable */ readonly class IntegerNonNegative extends IntType diff --git a/src/Integer/IntegerPositive.php b/src/Integer/IntegerPositive.php index 58d6a36..1ab2661 100755 --- a/src/Integer/IntegerPositive.php +++ b/src/Integer/IntegerPositive.php @@ -10,6 +10,10 @@ use function sprintf; /** + * Positive integer (> 0). + * + * Example "1" + * * @psalm-immutable */ readonly class IntegerPositive extends IntType diff --git a/src/Integer/IntegerStandard.php b/src/Integer/IntegerStandard.php index 3aa0cb5..d4a6320 100755 --- a/src/Integer/IntegerStandard.php +++ b/src/Integer/IntegerStandard.php @@ -8,6 +8,10 @@ use PhpTypedValues\Code\Integer\IntType; /** + * Represents any PHP integer. + * + * Example "-10" + * * @psalm-immutable */ readonly class IntegerStandard extends IntType diff --git a/src/Integer/IntegerWeekDay.php b/src/Integer/IntegerWeekDay.php index cfb93df..857fa45 100755 --- a/src/Integer/IntegerWeekDay.php +++ b/src/Integer/IntegerWeekDay.php @@ -10,6 +10,10 @@ use function sprintf; /** + * Week day number between 1 and 7. + * + * Example "5" + * * @psalm-immutable */ readonly class IntegerWeekDay extends IntType diff --git a/src/String/Alias/NonEmptyStr.php b/src/String/Alias/NonEmptyStr.php index 8308136..ac25ace 100755 --- a/src/String/Alias/NonEmptyStr.php +++ b/src/String/Alias/NonEmptyStr.php @@ -7,6 +7,10 @@ use PhpTypedValues\String\StringNonEmpty; /** + * Alias of Non-empty string value. + * + * Example "hello" + * * @psalm-immutable */ readonly class NonEmptyStr extends StringNonEmpty diff --git a/src/String/Alias/StrType.php b/src/String/Alias/StrType.php new file mode 100755 index 0000000..92fd9cd --- /dev/null +++ b/src/String/Alias/StrType.php @@ -0,0 +1,14 @@ +toString() . \PHP_EOL; echo IntegerStandard::fromString('10')->toString() . \PHP_EOL; echo Id::fromString('10')->toString() . \PHP_EOL; +echo IntType::fromString('10')->toString() . \PHP_EOL; /** * String. @@ -47,6 +51,7 @@ echo StringStandard::fromString('hi')->toString() . \PHP_EOL; echo NonEmptyStr::fromString('hi')->toString() . \PHP_EOL; +echo StrType::fromString('hi')->toString() . \PHP_EOL; /** * Float. @@ -55,6 +60,7 @@ echo FloatStandard::fromString('2.71828')->toString() . \PHP_EOL; echo NonNegativeFloat::fromString('2.71828')->toString() . \PHP_EOL; +echo FloatType::fromString('2.71828')->toString() . \PHP_EOL; // PositiveFloat usage testPositiveFloat(FloatNonNegative::fromFloat(0.5)->value()); From cbc557d48b88dce91280e128306975d5e6811669 Mon Sep 17 00:00:00 2001 From: GeorgII Date: Wed, 26 Nov 2025 23:35:24 +0100 Subject: [PATCH 2/2] Refactor namespaces for consistency: rename `Code` to `Abstract` and update exception paths. --- .junie/guidelines.md | 3 +-- docs/USAGE.md | 6 +++--- src/{Code => Abstract}/DateTime/DateTimeType.php | 6 +++--- .../DateTime/DateTimeTypeInterface.php | 2 +- src/{Code => Abstract}/Float/FloatType.php | 4 ++-- src/{Code => Abstract}/Float/FloatTypeInterface.php | 2 +- src/{Code => Abstract}/Integer/IntType.php | 4 ++-- src/{Code => Abstract}/Integer/IntTypeInterface.php | 2 +- src/{Code => Abstract}/String/StrType.php | 2 +- src/{Code => Abstract}/String/StrTypeInterface.php | 2 +- src/DateTime/DateTimeAtom.php | 4 ++-- src/DateTime/DateTimeRFC3339.php | 4 ++-- src/DateTime/DateTimeRFC3339Extended.php | 4 ++-- src/DateTime/DateTimeW3C.php | 4 ++-- src/DateTime/Timestamp/TimestampMilliseconds.php | 4 ++-- src/DateTime/Timestamp/TimestampSeconds.php | 4 ++-- src/{Code => }/Exception/DateTimeTypeException.php | 2 +- src/{Code => }/Exception/FloatTypeException.php | 2 +- src/{Code => }/Exception/IntegerTypeException.php | 2 +- .../ReasonableRangeDateTimeTypeException.php | 2 +- src/{Code => }/Exception/StringTypeException.php | 2 +- src/{Code => }/Exception/TypeException.php | 2 +- src/Float/FloatNonNegative.php | 4 ++-- src/Float/FloatStandard.php | 4 ++-- src/Integer/IntegerNonNegative.php | 4 ++-- src/Integer/IntegerPositive.php | 4 ++-- src/Integer/IntegerStandard.php | 4 ++-- src/Integer/IntegerWeekDay.php | 4 ++-- src/String/DB/StringVarChar255.php | 4 ++-- src/String/StringNonEmpty.php | 4 ++-- src/String/StringStandard.php | 2 +- src/String/StringUuidV4.php | 4 ++-- src/String/StringUuidV7.php | 4 ++-- tests/Arch/StructureTest.php | 10 +++++----- tests/Unit/Code/DateTime/DateTimeTypeTest.php | 4 ++-- tests/Unit/Code/Float/FloatTypeTest.php | 2 +- tests/Unit/Code/Integer/IntTypeTest.php | 2 +- tests/Unit/DateTime/DateTimeAtomTest.php | 12 ++++++------ tests/Unit/DateTime/DateTimeRFC3339ExtendedTest.php | 12 ++++++------ tests/Unit/DateTime/DateTimeRFC3339Test.php | 12 ++++++------ tests/Unit/DateTime/DateTimeW3CTest.php | 12 ++++++------ .../DateTime/Timestamp/TimestampMillisecondsTest.php | 6 +++--- .../Unit/DateTime/Timestamp/TimestampSecondsTest.php | 10 +++++----- tests/Unit/Float/FloatNonNegativeTypeTest.php | 2 +- tests/Unit/Integer/Alias/IdTypeTest.php | 2 +- tests/Unit/Integer/Alias/NonNegativeIntTypeTest.php | 2 +- tests/Unit/Integer/Alias/PositiveIntTypeTest.php | 2 +- tests/Unit/Integer/Alias/WeekDayIntTypeTest.php | 2 +- tests/Unit/Integer/IntegerNonNegativeTypeTest.php | 2 +- tests/Unit/Integer/IntegerPositiveTypeTest.php | 2 +- tests/Unit/Integer/IntegerStandartTypeTest.php | 2 +- tests/Unit/Integer/IntegerWeekDayTypeTest.php | 2 +- tests/Unit/String/DB/StringVarChar255Test.php | 2 +- tests/Unit/String/StringNonEmptyTypeTest.php | 2 +- tests/Unit/String/StringUuidV4Test.php | 2 +- tests/Unit/String/StringUuidV7Test.php | 2 +- 56 files changed, 109 insertions(+), 110 deletions(-) rename src/{Code => Abstract}/DateTime/DateTimeType.php (95%) rename src/{Code => Abstract}/DateTime/DateTimeTypeInterface.php (88%) rename src/{Code => Abstract}/Float/FloatType.php (85%) rename src/{Code => Abstract}/Float/FloatTypeInterface.php (87%) rename src/{Code => Abstract}/Integer/IntType.php (87%) rename src/{Code => Abstract}/Integer/IntTypeInterface.php (86%) rename src/{Code => Abstract}/String/StrType.php (83%) rename src/{Code => Abstract}/String/StrTypeInterface.php (84%) rename src/{Code => }/Exception/DateTimeTypeException.php (68%) rename src/{Code => }/Exception/FloatTypeException.php (67%) rename src/{Code => }/Exception/IntegerTypeException.php (67%) rename src/{Code => }/Exception/ReasonableRangeDateTimeTypeException.php (73%) rename src/{Code => }/Exception/StringTypeException.php (67%) rename src/{Code => }/Exception/TypeException.php (69%) diff --git a/.junie/guidelines.md b/.junie/guidelines.md index a0c43a5..69b4498 100755 --- a/.junie/guidelines.md +++ b/.junie/guidelines.md @@ -20,10 +20,9 @@ ## Folder structure -- `src/Code` folder contains the framework internal code +- `src/Abstract` folder contains the framework internal code - other folders like `src/"type"` contains specific types - `src/psalmTest.php` contains types usage to avoid Psalm issues like `unused method` -- `src/Code/Assert/Assert.php` contains `assert` methods, add new methods instead of checking conditions directly in classes. Prefer to use Assert::"methos()". ## Tests diff --git a/docs/USAGE.md b/docs/USAGE.md index 9daa5ce..78a63b7 100755 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -129,9 +129,9 @@ declare(strict_types=1); namespace App\Domain; -use PhpTypedValues\Code\Assert\Assert; -use PhpTypedValues\Code\Exception\FloatTypeException; -use PhpTypedValues\Code\Integer\IntType; +use PhpTypedValues\Abstract\Assert\Assert; +use PhpTypedValues\Exception\FloatTypeException; +use PhpTypedValues\Abstract\Integer\IntType; final class EvenPositiveInt extends IntType { diff --git a/src/Code/DateTime/DateTimeType.php b/src/Abstract/DateTime/DateTimeType.php similarity index 95% rename from src/Code/DateTime/DateTimeType.php rename to src/Abstract/DateTime/DateTimeType.php index afeade1..7c9b06d 100755 --- a/src/Code/DateTime/DateTimeType.php +++ b/src/Abstract/DateTime/DateTimeType.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace PhpTypedValues\Code\DateTime; +namespace PhpTypedValues\Abstract\DateTime; use const PHP_EOL; use DateTimeImmutable; use DateTimeZone; -use PhpTypedValues\Code\Exception\DateTimeTypeException; -use PhpTypedValues\Code\Exception\ReasonableRangeDateTimeTypeException; +use PhpTypedValues\Exception\DateTimeTypeException; +use PhpTypedValues\Exception\ReasonableRangeDateTimeTypeException; use function count; use function sprintf; diff --git a/src/Code/DateTime/DateTimeTypeInterface.php b/src/Abstract/DateTime/DateTimeTypeInterface.php similarity index 88% rename from src/Code/DateTime/DateTimeTypeInterface.php rename to src/Abstract/DateTime/DateTimeTypeInterface.php index 0c0f52e..781f7bd 100755 --- a/src/Code/DateTime/DateTimeTypeInterface.php +++ b/src/Abstract/DateTime/DateTimeTypeInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PhpTypedValues\Code\DateTime; +namespace PhpTypedValues\Abstract\DateTime; use DateTimeImmutable; diff --git a/src/Code/Float/FloatType.php b/src/Abstract/Float/FloatType.php similarity index 85% rename from src/Code/Float/FloatType.php rename to src/Abstract/Float/FloatType.php index 843da56..fe8b01b 100755 --- a/src/Code/Float/FloatType.php +++ b/src/Abstract/Float/FloatType.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace PhpTypedValues\Code\Float; +namespace PhpTypedValues\Abstract\Float; -use PhpTypedValues\Code\Exception\FloatTypeException; +use PhpTypedValues\Exception\FloatTypeException; use function sprintf; diff --git a/src/Code/Float/FloatTypeInterface.php b/src/Abstract/Float/FloatTypeInterface.php similarity index 87% rename from src/Code/Float/FloatTypeInterface.php rename to src/Abstract/Float/FloatTypeInterface.php index 2a8af7f..354de13 100755 --- a/src/Code/Float/FloatTypeInterface.php +++ b/src/Abstract/Float/FloatTypeInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PhpTypedValues\Code\Float; +namespace PhpTypedValues\Abstract\Float; /** * @psalm-immutable diff --git a/src/Code/Integer/IntType.php b/src/Abstract/Integer/IntType.php similarity index 87% rename from src/Code/Integer/IntType.php rename to src/Abstract/Integer/IntType.php index b358b16..1bb4245 100755 --- a/src/Code/Integer/IntType.php +++ b/src/Abstract/Integer/IntType.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace PhpTypedValues\Code\Integer; +namespace PhpTypedValues\Abstract\Integer; -use PhpTypedValues\Code\Exception\IntegerTypeException; +use PhpTypedValues\Exception\IntegerTypeException; use function sprintf; diff --git a/src/Code/Integer/IntTypeInterface.php b/src/Abstract/Integer/IntTypeInterface.php similarity index 86% rename from src/Code/Integer/IntTypeInterface.php rename to src/Abstract/Integer/IntTypeInterface.php index 0cb6a3f..67d913f 100755 --- a/src/Code/Integer/IntTypeInterface.php +++ b/src/Abstract/Integer/IntTypeInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PhpTypedValues\Code\Integer; +namespace PhpTypedValues\Abstract\Integer; /** * @psalm-immutable diff --git a/src/Code/String/StrType.php b/src/Abstract/String/StrType.php similarity index 83% rename from src/Code/String/StrType.php rename to src/Abstract/String/StrType.php index 6347ba8..4a23c55 100755 --- a/src/Code/String/StrType.php +++ b/src/Abstract/String/StrType.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PhpTypedValues\Code\String; +namespace PhpTypedValues\Abstract\String; /** * @psalm-immutable diff --git a/src/Code/String/StrTypeInterface.php b/src/Abstract/String/StrTypeInterface.php similarity index 84% rename from src/Code/String/StrTypeInterface.php rename to src/Abstract/String/StrTypeInterface.php index b156345..8fa6625 100755 --- a/src/Code/String/StrTypeInterface.php +++ b/src/Abstract/String/StrTypeInterface.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PhpTypedValues\Code\String; +namespace PhpTypedValues\Abstract\String; /** * @psalm-immutable diff --git a/src/DateTime/DateTimeAtom.php b/src/DateTime/DateTimeAtom.php index 89af691..f152fed 100755 --- a/src/DateTime/DateTimeAtom.php +++ b/src/DateTime/DateTimeAtom.php @@ -8,8 +8,8 @@ use DateTimeImmutable; use DateTimeZone; -use PhpTypedValues\Code\DateTime\DateTimeType; -use PhpTypedValues\Code\Exception\DateTimeTypeException; +use PhpTypedValues\Abstract\DateTime\DateTimeType; +use PhpTypedValues\Exception\DateTimeTypeException; /** * ATOM RFC 3339 format based on ISO 8601. diff --git a/src/DateTime/DateTimeRFC3339.php b/src/DateTime/DateTimeRFC3339.php index 7fae8f9..176802e 100755 --- a/src/DateTime/DateTimeRFC3339.php +++ b/src/DateTime/DateTimeRFC3339.php @@ -8,8 +8,8 @@ use DateTimeImmutable; use DateTimeZone; -use PhpTypedValues\Code\DateTime\DateTimeType; -use PhpTypedValues\Code\Exception\DateTimeTypeException; +use PhpTypedValues\Abstract\DateTime\DateTimeType; +use PhpTypedValues\Exception\DateTimeTypeException; /** * RFC 3339 format based on ISO 8601. diff --git a/src/DateTime/DateTimeRFC3339Extended.php b/src/DateTime/DateTimeRFC3339Extended.php index 6970a2c..ef3d4fe 100755 --- a/src/DateTime/DateTimeRFC3339Extended.php +++ b/src/DateTime/DateTimeRFC3339Extended.php @@ -8,8 +8,8 @@ use DateTimeImmutable; use DateTimeZone; -use PhpTypedValues\Code\DateTime\DateTimeType; -use PhpTypedValues\Code\Exception\DateTimeTypeException; +use PhpTypedValues\Abstract\DateTime\DateTimeType; +use PhpTypedValues\Exception\DateTimeTypeException; /** * RFC 3339 EXTENDED format based on ISO 8601 (with microseconds). diff --git a/src/DateTime/DateTimeW3C.php b/src/DateTime/DateTimeW3C.php index a176646..14b445a 100755 --- a/src/DateTime/DateTimeW3C.php +++ b/src/DateTime/DateTimeW3C.php @@ -8,8 +8,8 @@ use DateTimeImmutable; use DateTimeZone; -use PhpTypedValues\Code\DateTime\DateTimeType; -use PhpTypedValues\Code\Exception\DateTimeTypeException; +use PhpTypedValues\Abstract\DateTime\DateTimeType; +use PhpTypedValues\Exception\DateTimeTypeException; /** * W3C RFC 3339 format based on ISO 8601. diff --git a/src/DateTime/Timestamp/TimestampMilliseconds.php b/src/DateTime/Timestamp/TimestampMilliseconds.php index 3f5222f..436dbe9 100755 --- a/src/DateTime/Timestamp/TimestampMilliseconds.php +++ b/src/DateTime/Timestamp/TimestampMilliseconds.php @@ -5,8 +5,8 @@ namespace PhpTypedValues\DateTime\Timestamp; use DateTimeZone; -use PhpTypedValues\Code\DateTime\DateTimeType; -use PhpTypedValues\Code\Exception\DateTimeTypeException; +use PhpTypedValues\Abstract\DateTime\DateTimeType; +use PhpTypedValues\Exception\DateTimeTypeException; use function intdiv; use function sprintf; diff --git a/src/DateTime/Timestamp/TimestampSeconds.php b/src/DateTime/Timestamp/TimestampSeconds.php index 45eaf11..232290a 100755 --- a/src/DateTime/Timestamp/TimestampSeconds.php +++ b/src/DateTime/Timestamp/TimestampSeconds.php @@ -5,8 +5,8 @@ namespace PhpTypedValues\DateTime\Timestamp; use DateTimeZone; -use PhpTypedValues\Code\DateTime\DateTimeType; -use PhpTypedValues\Code\Exception\DateTimeTypeException; +use PhpTypedValues\Abstract\DateTime\DateTimeType; +use PhpTypedValues\Exception\DateTimeTypeException; /** * Unix timestamp (seconds since Unix epoch, UTC). diff --git a/src/Code/Exception/DateTimeTypeException.php b/src/Exception/DateTimeTypeException.php similarity index 68% rename from src/Code/Exception/DateTimeTypeException.php rename to src/Exception/DateTimeTypeException.php index c685e6b..23b8ffb 100755 --- a/src/Code/Exception/DateTimeTypeException.php +++ b/src/Exception/DateTimeTypeException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PhpTypedValues\Code\Exception; +namespace PhpTypedValues\Exception; class DateTimeTypeException extends TypeException { diff --git a/src/Code/Exception/FloatTypeException.php b/src/Exception/FloatTypeException.php similarity index 67% rename from src/Code/Exception/FloatTypeException.php rename to src/Exception/FloatTypeException.php index ad0aef0..95b7d3c 100755 --- a/src/Code/Exception/FloatTypeException.php +++ b/src/Exception/FloatTypeException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PhpTypedValues\Code\Exception; +namespace PhpTypedValues\Exception; class FloatTypeException extends TypeException { diff --git a/src/Code/Exception/IntegerTypeException.php b/src/Exception/IntegerTypeException.php similarity index 67% rename from src/Code/Exception/IntegerTypeException.php rename to src/Exception/IntegerTypeException.php index 1a128e0..249a4fa 100755 --- a/src/Code/Exception/IntegerTypeException.php +++ b/src/Exception/IntegerTypeException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PhpTypedValues\Code\Exception; +namespace PhpTypedValues\Exception; class IntegerTypeException extends TypeException { diff --git a/src/Code/Exception/ReasonableRangeDateTimeTypeException.php b/src/Exception/ReasonableRangeDateTimeTypeException.php similarity index 73% rename from src/Code/Exception/ReasonableRangeDateTimeTypeException.php rename to src/Exception/ReasonableRangeDateTimeTypeException.php index 872e3c7..5157a83 100755 --- a/src/Code/Exception/ReasonableRangeDateTimeTypeException.php +++ b/src/Exception/ReasonableRangeDateTimeTypeException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PhpTypedValues\Code\Exception; +namespace PhpTypedValues\Exception; class ReasonableRangeDateTimeTypeException extends DateTimeTypeException { diff --git a/src/Code/Exception/StringTypeException.php b/src/Exception/StringTypeException.php similarity index 67% rename from src/Code/Exception/StringTypeException.php rename to src/Exception/StringTypeException.php index ddef02d..b1208ee 100755 --- a/src/Code/Exception/StringTypeException.php +++ b/src/Exception/StringTypeException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PhpTypedValues\Code\Exception; +namespace PhpTypedValues\Exception; class StringTypeException extends TypeException { diff --git a/src/Code/Exception/TypeException.php b/src/Exception/TypeException.php similarity index 69% rename from src/Code/Exception/TypeException.php rename to src/Exception/TypeException.php index 609f63f..1ca411a 100755 --- a/src/Code/Exception/TypeException.php +++ b/src/Exception/TypeException.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace PhpTypedValues\Code\Exception; +namespace PhpTypedValues\Exception; use Exception; diff --git a/src/Float/FloatNonNegative.php b/src/Float/FloatNonNegative.php index 5500c03..7f297b9 100755 --- a/src/Float/FloatNonNegative.php +++ b/src/Float/FloatNonNegative.php @@ -4,8 +4,8 @@ namespace PhpTypedValues\Float; -use PhpTypedValues\Code\Exception\FloatTypeException; -use PhpTypedValues\Code\Float\FloatType; +use PhpTypedValues\Abstract\Float\FloatType; +use PhpTypedValues\Exception\FloatTypeException; use function sprintf; diff --git a/src/Float/FloatStandard.php b/src/Float/FloatStandard.php index 2c4d058..f538b40 100755 --- a/src/Float/FloatStandard.php +++ b/src/Float/FloatStandard.php @@ -4,8 +4,8 @@ namespace PhpTypedValues\Float; -use PhpTypedValues\Code\Exception\FloatTypeException; -use PhpTypedValues\Code\Float\FloatType; +use PhpTypedValues\Abstract\Float\FloatType; +use PhpTypedValues\Exception\FloatTypeException; /** * Represents any PHP float (double). diff --git a/src/Integer/IntegerNonNegative.php b/src/Integer/IntegerNonNegative.php index 95cb435..80273e0 100755 --- a/src/Integer/IntegerNonNegative.php +++ b/src/Integer/IntegerNonNegative.php @@ -4,8 +4,8 @@ namespace PhpTypedValues\Integer; -use PhpTypedValues\Code\Exception\IntegerTypeException; -use PhpTypedValues\Code\Integer\IntType; +use PhpTypedValues\Abstract\Integer\IntType; +use PhpTypedValues\Exception\IntegerTypeException; use function sprintf; diff --git a/src/Integer/IntegerPositive.php b/src/Integer/IntegerPositive.php index 1ab2661..e30c400 100755 --- a/src/Integer/IntegerPositive.php +++ b/src/Integer/IntegerPositive.php @@ -4,8 +4,8 @@ namespace PhpTypedValues\Integer; -use PhpTypedValues\Code\Exception\IntegerTypeException; -use PhpTypedValues\Code\Integer\IntType; +use PhpTypedValues\Abstract\Integer\IntType; +use PhpTypedValues\Exception\IntegerTypeException; use function sprintf; diff --git a/src/Integer/IntegerStandard.php b/src/Integer/IntegerStandard.php index d4a6320..8089e76 100755 --- a/src/Integer/IntegerStandard.php +++ b/src/Integer/IntegerStandard.php @@ -4,8 +4,8 @@ namespace PhpTypedValues\Integer; -use PhpTypedValues\Code\Exception\IntegerTypeException; -use PhpTypedValues\Code\Integer\IntType; +use PhpTypedValues\Abstract\Integer\IntType; +use PhpTypedValues\Exception\IntegerTypeException; /** * Represents any PHP integer. diff --git a/src/Integer/IntegerWeekDay.php b/src/Integer/IntegerWeekDay.php index 857fa45..c236dee 100755 --- a/src/Integer/IntegerWeekDay.php +++ b/src/Integer/IntegerWeekDay.php @@ -4,8 +4,8 @@ namespace PhpTypedValues\Integer; -use PhpTypedValues\Code\Exception\IntegerTypeException; -use PhpTypedValues\Code\Integer\IntType; +use PhpTypedValues\Abstract\Integer\IntType; +use PhpTypedValues\Exception\IntegerTypeException; use function sprintf; diff --git a/src/String/DB/StringVarChar255.php b/src/String/DB/StringVarChar255.php index 2d60aa0..b666e8c 100755 --- a/src/String/DB/StringVarChar255.php +++ b/src/String/DB/StringVarChar255.php @@ -4,8 +4,8 @@ namespace PhpTypedValues\String\DB; -use PhpTypedValues\Code\Exception\StringTypeException; -use PhpTypedValues\Code\String\StrType; +use PhpTypedValues\Abstract\String\StrType; +use PhpTypedValues\Exception\StringTypeException; /** * Database VARCHAR(255) string. diff --git a/src/String/StringNonEmpty.php b/src/String/StringNonEmpty.php index 0363e74..43f4242 100755 --- a/src/String/StringNonEmpty.php +++ b/src/String/StringNonEmpty.php @@ -4,8 +4,8 @@ namespace PhpTypedValues\String; -use PhpTypedValues\Code\Exception\StringTypeException; -use PhpTypedValues\Code\String\StrType; +use PhpTypedValues\Abstract\String\StrType; +use PhpTypedValues\Exception\StringTypeException; use function sprintf; diff --git a/src/String/StringStandard.php b/src/String/StringStandard.php index 50ee4b7..0e575ed 100755 --- a/src/String/StringStandard.php +++ b/src/String/StringStandard.php @@ -4,7 +4,7 @@ namespace PhpTypedValues\String; -use PhpTypedValues\Code\String\StrType; +use PhpTypedValues\Abstract\String\StrType; /** * Represents any PHP string. diff --git a/src/String/StringUuidV4.php b/src/String/StringUuidV4.php index e783c3a..61bf3ee 100755 --- a/src/String/StringUuidV4.php +++ b/src/String/StringUuidV4.php @@ -4,8 +4,8 @@ namespace PhpTypedValues\String; -use PhpTypedValues\Code\Exception\StringTypeException; -use PhpTypedValues\Code\String\StrType; +use PhpTypedValues\Abstract\String\StrType; +use PhpTypedValues\Exception\StringTypeException; use function preg_match; use function sprintf; diff --git a/src/String/StringUuidV7.php b/src/String/StringUuidV7.php index b3f1862..6aa4f1d 100755 --- a/src/String/StringUuidV7.php +++ b/src/String/StringUuidV7.php @@ -4,8 +4,8 @@ namespace PhpTypedValues\String; -use PhpTypedValues\Code\Exception\StringTypeException; -use PhpTypedValues\Code\String\StrType; +use PhpTypedValues\Abstract\String\StrType; +use PhpTypedValues\Exception\StringTypeException; use function preg_match; use function sprintf; diff --git a/tests/Arch/StructureTest.php b/tests/Arch/StructureTest.php index 2783491..514bb65 100755 --- a/tests/Arch/StructureTest.php +++ b/tests/Arch/StructureTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -use PhpTypedValues\Code\DateTime\DateTimeType; -use PhpTypedValues\Code\Float\FloatType; -use PhpTypedValues\Code\Integer\IntType; -use PhpTypedValues\Code\String\StrType; +use PhpTypedValues\Abstract\DateTime\DateTimeType; +use PhpTypedValues\Abstract\Float\FloatType; +use PhpTypedValues\Abstract\Integer\IntType; +use PhpTypedValues\Abstract\String\StrType; arch('Base classes') - ->expect('PhpTypedValues\Code\BaseType') + ->expect('PhpTypedValues\Abstract\BaseType') ->toBeClasses() ->toBeAbstract() ->toOnlyBeUsedIn('PhpTypedValues'); diff --git a/tests/Unit/Code/DateTime/DateTimeTypeTest.php b/tests/Unit/Code/DateTime/DateTimeTypeTest.php index a058820..6890e92 100755 --- a/tests/Unit/Code/DateTime/DateTimeTypeTest.php +++ b/tests/Unit/Code/DateTime/DateTimeTypeTest.php @@ -15,10 +15,10 @@ it('DateTimeImmutable has false and throws an exception', function (): void { expect( fn() => DateTimeAtom::fromString('') - )->toThrow(PhpTypedValues\Code\Exception\DateTimeTypeException::class); + )->toThrow(PhpTypedValues\Exception\DateTimeTypeException::class); }); it('throws DateTimeTypeException on unexpected conversion when input uses Z instead of +00:00', function (): void { $call = fn() => DateTimeAtom::fromString('2025-01-02T03:04:05Z'); - expect($call)->toThrow(PhpTypedValues\Code\Exception\DateTimeTypeException::class); + expect($call)->toThrow(PhpTypedValues\Exception\DateTimeTypeException::class); }); diff --git a/tests/Unit/Code/Float/FloatTypeTest.php b/tests/Unit/Code/Float/FloatTypeTest.php index 45fbd3b..e9ae4ed 100755 --- a/tests/Unit/Code/Float/FloatTypeTest.php +++ b/tests/Unit/Code/Float/FloatTypeTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\FloatTypeException; +use PhpTypedValues\Exception\FloatTypeException; use PhpTypedValues\Float\FloatStandard; it('fromFloat returns exact value and toString matches', function (): void { diff --git a/tests/Unit/Code/Integer/IntTypeTest.php b/tests/Unit/Code/Integer/IntTypeTest.php index f11fea5..4e73d6e 100755 --- a/tests/Unit/Code/Integer/IntTypeTest.php +++ b/tests/Unit/Code/Integer/IntTypeTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\IntegerTypeException; +use PhpTypedValues\Exception\IntegerTypeException; use PhpTypedValues\Integer\IntegerStandard; it('fromInt returns exact value and toString matches', function (): void { diff --git a/tests/Unit/DateTime/DateTimeAtomTest.php b/tests/Unit/DateTime/DateTimeAtomTest.php index c819a98..f7cad4a 100755 --- a/tests/Unit/DateTime/DateTimeAtomTest.php +++ b/tests/Unit/DateTime/DateTimeAtomTest.php @@ -22,7 +22,7 @@ it('fromString throws on invalid date parts (errors path)', function (): void { // invalid month 13 produces errors $call = fn() => DateTimeAtom::fromString('2025-13-02T03:04:05+00:00'); - expect($call)->toThrow(PhpTypedValues\Code\Exception\DateTimeTypeException::class); + expect($call)->toThrow(PhpTypedValues\Exception\DateTimeTypeException::class); }); it('fromString throws on trailing data (warnings path)', function (): void { @@ -31,7 +31,7 @@ DateTimeAtom::fromString('2025-01-02T03:04:05+00:00 '); expect()->fail('Exception was not thrown'); } catch (Throwable $e) { - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($e->getMessage())->toContain('Invalid date time value'); } }); @@ -47,7 +47,7 @@ DateTimeAtom::fromString($input); expect()->fail('Exception was not thrown'); } catch (Throwable $e) { - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($e->getMessage())->toContain('Invalid date time value') ->and($e->getMessage())->toContain('Error at') ->and($e->getMessage())->toContain('Warning at'); @@ -69,7 +69,7 @@ \DATE_ATOM ) . \PHP_EOL; - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($msg)->toContain($expectedHeader) ->and($msg)->toContain('Invalid date time value "2025-13-40T25:61:61+00:00", use format "Y-m-d\TH:i:sP" Warning at 25: The parsed date was invalid @@ -87,7 +87,7 @@ } catch (Throwable $e) { $msg = $e->getMessage(); // must contain the header + newline and at least one warning line ending with newline - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($msg)->toContain('Invalid date time value "2025-01-02T03:04:05+00:00 ", use format "Y-m-d\TH:i:sP" Error at 25: Trailing data '); @@ -105,7 +105,7 @@ } catch (Throwable $e) { $msg = $e->getMessage(); // must contain the header + newline and at least one warning line ending with newline - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($msg)->toContain('Invalid date time value "2025-12-02T03:04:05+ 00:00", use format "Y-m-d\TH:i:sP" Error at 19: The timezone could not be found in the database Error at 20: Trailing data diff --git a/tests/Unit/DateTime/DateTimeRFC3339ExtendedTest.php b/tests/Unit/DateTime/DateTimeRFC3339ExtendedTest.php index e1bba4c..4b15b81 100755 --- a/tests/Unit/DateTime/DateTimeRFC3339ExtendedTest.php +++ b/tests/Unit/DateTime/DateTimeRFC3339ExtendedTest.php @@ -22,7 +22,7 @@ it('fromString throws on invalid date parts (errors path)', function (): void { // invalid month 13 produces errors $call = fn() => DateTimeRFC3339Extended::fromString('2025-13-02T03:04:05.000+00:00'); - expect($call)->toThrow(PhpTypedValues\Code\Exception\DateTimeTypeException::class); + expect($call)->toThrow(PhpTypedValues\Exception\DateTimeTypeException::class); }); it('fromString throws on trailing data (warnings path)', function (): void { @@ -31,7 +31,7 @@ DateTimeRFC3339Extended::fromString('2025-01-02T03:04:05.000+00:00 '); expect()->fail('Exception was not thrown'); } catch (Throwable $e) { - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($e->getMessage())->toContain('Invalid date time value'); } }); @@ -47,7 +47,7 @@ DateTimeRFC3339Extended::fromString($input); expect()->fail('Exception was not thrown'); } catch (Throwable $e) { - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($e->getMessage())->toContain('Invalid date time value') ->and($e->getMessage())->toContain('Error at') ->and($e->getMessage())->toContain('Warning at'); @@ -69,7 +69,7 @@ \DATE_RFC3339_EXTENDED ) . \PHP_EOL; - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($msg)->toContain($expectedHeader) ->and($msg)->toContain('Invalid date time value "2025-13-40T25:61:61.000+00:00", use format "Y-m-d\TH:i:s.vP" Warning at 29: The parsed date was invalid @@ -87,7 +87,7 @@ } catch (Throwable $e) { $msg = $e->getMessage(); // must contain the header + newline and at least one warning line ending with newline - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($msg)->toContain('Invalid date time value "2025-01-02T03:04:05.000+00:00 ", use format "Y-m-d\TH:i:s.vP" Error at 29: Trailing data '); @@ -105,7 +105,7 @@ } catch (Throwable $e) { $msg = $e->getMessage(); // must contain the header + newline and at least one warning line ending with newline - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($msg)->toContain('Invalid date time value "2025-12-02T03:04:05.000+ 00:00", use format "Y-m-d\TH:i:s.vP" Error at 23: The timezone could not be found in the database Error at 24: Trailing data diff --git a/tests/Unit/DateTime/DateTimeRFC3339Test.php b/tests/Unit/DateTime/DateTimeRFC3339Test.php index 0be7cad..9b28157 100755 --- a/tests/Unit/DateTime/DateTimeRFC3339Test.php +++ b/tests/Unit/DateTime/DateTimeRFC3339Test.php @@ -22,7 +22,7 @@ it('fromString throws on invalid date parts (errors path)', function (): void { // invalid month 13 produces errors $call = fn() => DateTimeRFC3339::fromString('2025-13-02T03:04:05+00:00'); - expect($call)->toThrow(PhpTypedValues\Code\Exception\DateTimeTypeException::class); + expect($call)->toThrow(PhpTypedValues\Exception\DateTimeTypeException::class); }); it('fromString throws on trailing data (warnings path)', function (): void { @@ -31,7 +31,7 @@ DateTimeRFC3339::fromString('2025-01-02T03:04:05+00:00 '); expect()->fail('Exception was not thrown'); } catch (Throwable $e) { - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($e->getMessage())->toContain('Invalid date time value'); } }); @@ -47,7 +47,7 @@ DateTimeRFC3339::fromString($input); expect()->fail('Exception was not thrown'); } catch (Throwable $e) { - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($e->getMessage())->toContain('Invalid date time value') ->and($e->getMessage())->toContain('Error at') ->and($e->getMessage())->toContain('Warning at'); @@ -69,7 +69,7 @@ \DATE_RFC3339 ) . \PHP_EOL; - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($msg)->toContain($expectedHeader) ->and($msg)->toContain('Invalid date time value "2025-13-40T25:61:61+00:00", use format "Y-m-d\TH:i:sP" Warning at 25: The parsed date was invalid @@ -87,7 +87,7 @@ } catch (Throwable $e) { $msg = $e->getMessage(); // must contain the header + newline and at least one warning line ending with newline - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($msg)->toContain('Invalid date time value "2025-01-02T03:04:05+00:00 ", use format "Y-m-d\TH:i:sP" Error at 25: Trailing data '); @@ -105,7 +105,7 @@ } catch (Throwable $e) { $msg = $e->getMessage(); // must contain the header + newline and at least one warning line ending with newline - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($msg)->toContain('Invalid date time value "2025-12-02T03:04:05+ 00:00", use format "Y-m-d\TH:i:sP" Error at 19: The timezone could not be found in the database Error at 20: Trailing data diff --git a/tests/Unit/DateTime/DateTimeW3CTest.php b/tests/Unit/DateTime/DateTimeW3CTest.php index 201ebaa..de8582d 100755 --- a/tests/Unit/DateTime/DateTimeW3CTest.php +++ b/tests/Unit/DateTime/DateTimeW3CTest.php @@ -22,7 +22,7 @@ it('fromString throws on invalid date parts (errors path)', function (): void { // invalid month 13 produces errors $call = fn() => DateTimeW3C::fromString('2025-13-02T03:04:05+00:00'); - expect($call)->toThrow(PhpTypedValues\Code\Exception\DateTimeTypeException::class); + expect($call)->toThrow(PhpTypedValues\Exception\DateTimeTypeException::class); }); it('fromString throws on trailing data (warnings path)', function (): void { @@ -31,7 +31,7 @@ DateTimeW3C::fromString('2025-01-02T03:04:05+00:00 '); expect()->fail('Exception was not thrown'); } catch (Throwable $e) { - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($e->getMessage())->toContain('Invalid date time value'); } }); @@ -47,7 +47,7 @@ DateTimeW3C::fromString($input); expect()->fail('Exception was not thrown'); } catch (Throwable $e) { - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($e->getMessage())->toContain('Invalid date time value') ->and($e->getMessage())->toContain('Error at') ->and($e->getMessage())->toContain('Warning at'); @@ -69,7 +69,7 @@ \DATE_RFC3339 ) . \PHP_EOL; - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($msg)->toContain($expectedHeader) ->and($msg)->toContain('Invalid date time value "2025-13-40T25:61:61+00:00", use format "Y-m-d\TH:i:sP" Warning at 25: The parsed date was invalid @@ -87,7 +87,7 @@ } catch (Throwable $e) { $msg = $e->getMessage(); // must contain the header + newline and at least one warning line ending with newline - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($msg)->toContain('Invalid date time value "2025-01-02T03:04:05+00:00 ", use format "Y-m-d\TH:i:sP" Error at 25: Trailing data '); @@ -105,7 +105,7 @@ } catch (Throwable $e) { $msg = $e->getMessage(); // must contain the header + newline and at least one warning line ending with newline - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($msg)->toContain('Invalid date time value "2025-12-02T03:04:05+ 00:00", use format "Y-m-d\TH:i:sP" Error at 19: The timezone could not be found in the database Error at 20: Trailing data diff --git a/tests/Unit/DateTime/Timestamp/TimestampMillisecondsTest.php b/tests/Unit/DateTime/Timestamp/TimestampMillisecondsTest.php index 0fb2c23..63defda 100755 --- a/tests/Unit/DateTime/Timestamp/TimestampMillisecondsTest.php +++ b/tests/Unit/DateTime/Timestamp/TimestampMillisecondsTest.php @@ -69,7 +69,7 @@ TimestampMilliseconds::fromString('not-a-number'); expect()->fail('Exception was not thrown'); } catch (Throwable $e) { - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($e->getMessage())->toContain('Expected milliseconds timestamp as digits'); } }); @@ -79,7 +79,7 @@ TimestampMilliseconds::fromString('1000000000000 '); expect()->fail('Exception was not thrown'); } catch (Throwable $e) { - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($e->getMessage())->toContain('Expected milliseconds timestamp as digits'); } }); @@ -94,7 +94,7 @@ TimestampMilliseconds::fromString($tooLargeMs); expect()->fail('Exception was not thrown'); } catch (Throwable $e) { - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\ReasonableRangeDateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\ReasonableRangeDateTimeTypeException::class) ->and($e->getMessage())->toContain('Timestamp "253402300800" out of supported range "-62135596800"-"253402300799"') ->and($e->getMessage())->toContain('253402300800'); } diff --git a/tests/Unit/DateTime/Timestamp/TimestampSecondsTest.php b/tests/Unit/DateTime/Timestamp/TimestampSecondsTest.php index 3349453..747aca0 100755 --- a/tests/Unit/DateTime/Timestamp/TimestampSecondsTest.php +++ b/tests/Unit/DateTime/Timestamp/TimestampSecondsTest.php @@ -40,7 +40,7 @@ expect()->fail('Exception was not thrown'); } catch (Throwable $e) { $msg = $e->getMessage(); - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($msg)->toContain('Invalid date time value') ->and((bool) preg_match('/(Error at|Warning at)/', $msg))->toBeTrue(); } @@ -52,7 +52,7 @@ expect()->fail('Exception was not thrown'); } catch (Throwable $e) { $msg = $e->getMessage(); - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($msg)->toContain('Invalid date time value') ->and((bool) preg_match('/(Error at|Warning at)/', $msg))->toBeTrue(); } @@ -63,7 +63,7 @@ TimestampSeconds::fromString('0000000005'); expect()->fail('Exception was not thrown'); } catch (Throwable $e) { - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\DateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\DateTimeTypeException::class) ->and($e->getMessage())->toContain('Unexpected conversion') ->and($e->getMessage())->toContain('0000000005') ->and($e->getMessage())->toContain('5'); @@ -76,7 +76,7 @@ TimestampSeconds::fromString('253402300800'); expect()->fail('Exception was not thrown'); } catch (Throwable $e) { - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\ReasonableRangeDateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\ReasonableRangeDateTimeTypeException::class) ->and($e->getMessage())->toContain('Timestamp "253402300800" out of supported range "-62135596800"-"253402300799"') ->and($e->getMessage())->toContain('253402300800'); } @@ -88,7 +88,7 @@ TimestampSeconds::fromString('-62135596801'); expect()->fail('Exception was not thrown'); } catch (Throwable $e) { - expect($e)->toBeInstanceOf(PhpTypedValues\Code\Exception\ReasonableRangeDateTimeTypeException::class) + expect($e)->toBeInstanceOf(PhpTypedValues\Exception\ReasonableRangeDateTimeTypeException::class) ->and($e->getMessage())->toContain('Timestamp "-62135596801" out of supported range "-62135596800"-"253402300799"') ->and($e->getMessage())->toContain('-62135596801'); } diff --git a/tests/Unit/Float/FloatNonNegativeTypeTest.php b/tests/Unit/Float/FloatNonNegativeTypeTest.php index c7b6efe..9b8dbdd 100755 --- a/tests/Unit/Float/FloatNonNegativeTypeTest.php +++ b/tests/Unit/Float/FloatNonNegativeTypeTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\FloatTypeException; +use PhpTypedValues\Exception\FloatTypeException; use PhpTypedValues\Float\FloatNonNegative; it('accepts non-negative floats via fromFloat and toString matches', function (): void { diff --git a/tests/Unit/Integer/Alias/IdTypeTest.php b/tests/Unit/Integer/Alias/IdTypeTest.php index 55086f7..3be69fa 100755 --- a/tests/Unit/Integer/Alias/IdTypeTest.php +++ b/tests/Unit/Integer/Alias/IdTypeTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\IntegerTypeException; +use PhpTypedValues\Exception\IntegerTypeException; use PhpTypedValues\Integer\Alias\Id; it('creates Id', function (): void { diff --git a/tests/Unit/Integer/Alias/NonNegativeIntTypeTest.php b/tests/Unit/Integer/Alias/NonNegativeIntTypeTest.php index bd9bd89..8b3808b 100755 --- a/tests/Unit/Integer/Alias/NonNegativeIntTypeTest.php +++ b/tests/Unit/Integer/Alias/NonNegativeIntTypeTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\IntegerTypeException; +use PhpTypedValues\Exception\IntegerTypeException; use PhpTypedValues\Integer\Alias\NonNegativeInt; it('creates NonNegativeInt', function (): void { diff --git a/tests/Unit/Integer/Alias/PositiveIntTypeTest.php b/tests/Unit/Integer/Alias/PositiveIntTypeTest.php index c4f703c..4bf756a 100755 --- a/tests/Unit/Integer/Alias/PositiveIntTypeTest.php +++ b/tests/Unit/Integer/Alias/PositiveIntTypeTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\IntegerTypeException; +use PhpTypedValues\Exception\IntegerTypeException; use PhpTypedValues\Integer\Alias\PositiveInt; it('creates PositiveInt', function (): void { diff --git a/tests/Unit/Integer/Alias/WeekDayIntTypeTest.php b/tests/Unit/Integer/Alias/WeekDayIntTypeTest.php index c4f703c..4bf756a 100755 --- a/tests/Unit/Integer/Alias/WeekDayIntTypeTest.php +++ b/tests/Unit/Integer/Alias/WeekDayIntTypeTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\IntegerTypeException; +use PhpTypedValues\Exception\IntegerTypeException; use PhpTypedValues\Integer\Alias\PositiveInt; it('creates PositiveInt', function (): void { diff --git a/tests/Unit/Integer/IntegerNonNegativeTypeTest.php b/tests/Unit/Integer/IntegerNonNegativeTypeTest.php index 1b3ca15..d3f7814 100755 --- a/tests/Unit/Integer/IntegerNonNegativeTypeTest.php +++ b/tests/Unit/Integer/IntegerNonNegativeTypeTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\IntegerTypeException; +use PhpTypedValues\Exception\IntegerTypeException; use PhpTypedValues\Integer\IntegerNonNegative; it('creates NonNegativeInt', function (): void { diff --git a/tests/Unit/Integer/IntegerPositiveTypeTest.php b/tests/Unit/Integer/IntegerPositiveTypeTest.php index e0898c7..85710c9 100755 --- a/tests/Unit/Integer/IntegerPositiveTypeTest.php +++ b/tests/Unit/Integer/IntegerPositiveTypeTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\IntegerTypeException; +use PhpTypedValues\Exception\IntegerTypeException; use PhpTypedValues\Integer\IntegerPositive; it('creates IntegerPositive', function (): void { diff --git a/tests/Unit/Integer/IntegerStandartTypeTest.php b/tests/Unit/Integer/IntegerStandartTypeTest.php index da94c1f..ed33324 100755 --- a/tests/Unit/Integer/IntegerStandartTypeTest.php +++ b/tests/Unit/Integer/IntegerStandartTypeTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\IntegerTypeException; +use PhpTypedValues\Exception\IntegerTypeException; use PhpTypedValues\Integer\IntegerStandard; it('creates Integer from int', function (): void { diff --git a/tests/Unit/Integer/IntegerWeekDayTypeTest.php b/tests/Unit/Integer/IntegerWeekDayTypeTest.php index c806e00..d1081c0 100755 --- a/tests/Unit/Integer/IntegerWeekDayTypeTest.php +++ b/tests/Unit/Integer/IntegerWeekDayTypeTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\IntegerTypeException; +use PhpTypedValues\Exception\IntegerTypeException; use PhpTypedValues\Integer\IntegerWeekDay; it('creates WeekDayInt from int 1', function (): void { diff --git a/tests/Unit/String/DB/StringVarChar255Test.php b/tests/Unit/String/DB/StringVarChar255Test.php index 489f15b..a7d4fe3 100755 --- a/tests/Unit/String/DB/StringVarChar255Test.php +++ b/tests/Unit/String/DB/StringVarChar255Test.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\StringTypeException; +use PhpTypedValues\Exception\StringTypeException; use PhpTypedValues\String\DB\StringVarChar255; it('accepts empty string and preserves value', function (): void { diff --git a/tests/Unit/String/StringNonEmptyTypeTest.php b/tests/Unit/String/StringNonEmptyTypeTest.php index f96b878..e16fb87 100755 --- a/tests/Unit/String/StringNonEmptyTypeTest.php +++ b/tests/Unit/String/StringNonEmptyTypeTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\StringTypeException; +use PhpTypedValues\Exception\StringTypeException; use PhpTypedValues\String\StringNonEmpty; it('constructs and preserves non-empty string', function (): void { diff --git a/tests/Unit/String/StringUuidV4Test.php b/tests/Unit/String/StringUuidV4Test.php index f326a3f..54c5a41 100755 --- a/tests/Unit/String/StringUuidV4Test.php +++ b/tests/Unit/String/StringUuidV4Test.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\StringTypeException; +use PhpTypedValues\Exception\StringTypeException; use PhpTypedValues\String\StringUuidV4; it('accepts a valid lowercase UUID v4 and preserves value', function (): void { diff --git a/tests/Unit/String/StringUuidV7Test.php b/tests/Unit/String/StringUuidV7Test.php index 2f45d02..f3048ac 100755 --- a/tests/Unit/String/StringUuidV7Test.php +++ b/tests/Unit/String/StringUuidV7Test.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use PhpTypedValues\Code\Exception\StringTypeException; +use PhpTypedValues\Exception\StringTypeException; use PhpTypedValues\String\StringUuidV7; it('accepts a valid lowercase UUID v7 and preserves value', function (): void {