Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f4a50b9

Browse filesBrowse files
committed
feat: add value to InvalidArgumentException
1 parent 468c22b commit f4a50b9
Copy full SHA for f4a50b9

9 files changed

+18
-11
lines changed

‎src/Symfony/Component/Uid/AbstractUid.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Uid/AbstractUid.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ abstract public static function fromString(string $uid): static;
4141
public static function fromBinary(string $uid): static
4242
{
4343
if (16 !== \strlen($uid)) {
44-
throw new InvalidArgumentException('Invalid binary uid provided.');
44+
throw new InvalidArgumentException($uid, 'Invalid binary uid provided.');
4545
}
4646

4747
return static::fromString($uid);
@@ -53,7 +53,7 @@ public static function fromBinary(string $uid): static
5353
public static function fromBase58(string $uid): static
5454
{
5555
if (22 !== \strlen($uid)) {
56-
throw new InvalidArgumentException('Invalid base-58 uid provided.');
56+
throw new InvalidArgumentException($uid, 'Invalid base-58 uid provided.');
5757
}
5858

5959
return static::fromString($uid);
@@ -65,7 +65,7 @@ public static function fromBase58(string $uid): static
6565
public static function fromBase32(string $uid): static
6666
{
6767
if (26 !== \strlen($uid)) {
68-
throw new InvalidArgumentException('Invalid base-32 uid provided.');
68+
throw new InvalidArgumentException($uid, 'Invalid base-32 uid provided.');
6969
}
7070

7171
return static::fromString($uid);
@@ -79,7 +79,7 @@ public static function fromBase32(string $uid): static
7979
public static function fromRfc4122(string $uid): static
8080
{
8181
if (36 !== \strlen($uid)) {
82-
throw new InvalidArgumentException('Invalid RFC4122 uid provided.');
82+
throw new InvalidArgumentException($uid, 'Invalid RFC4122 uid provided.');
8383
}
8484

8585
return static::fromString($uid);

‎src/Symfony/Component/Uid/BinaryUtil.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Uid/BinaryUtil.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public static function dateTimeToHex(\DateTimeInterface $time): string
164164
{
165165
if (\PHP_INT_SIZE >= 8) {
166166
if (-self::TIME_OFFSET_INT > $time = (int) $time->format('Uu0')) {
167-
throw new InvalidArgumentException('The given UUID date cannot be earlier than 1582-10-15.');
167+
throw new InvalidArgumentException($time, 'The given UUID date cannot be earlier than 1582-10-15.');
168168
}
169169

170170
return str_pad(dechex(self::TIME_OFFSET_INT + $time), 16, '0', \STR_PAD_LEFT);
@@ -173,7 +173,7 @@ public static function dateTimeToHex(\DateTimeInterface $time): string
173173
$time = $time->format('Uu0');
174174
$negative = '-' === $time[0];
175175
if ($negative && self::TIME_OFFSET_INT < $time = substr($time, 1)) {
176-
throw new InvalidArgumentException('The given UUID date cannot be earlier than 1582-10-15.');
176+
throw new InvalidArgumentException($time, 'The given UUID date cannot be earlier than 1582-10-15.');
177177
}
178178
$time = self::fromBase($time, self::BASE10);
179179
$time = str_pad($time, 8, "\0", \STR_PAD_LEFT);

‎src/Symfony/Component/Uid/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Uid/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* Add component-specific exception hierarchy
8+
* Add `InvalidArgumentException::$value`
89

910
7.2
1011
---

‎src/Symfony/Component/Uid/Exception/InvalidArgumentException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Uid/Exception/InvalidArgumentException.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,10 @@
1313

1414
class InvalidArgumentException extends \InvalidArgumentException
1515
{
16+
public function __construct(
17+
public readonly mixed $value,
18+
string $message,
19+
) {
20+
parent::__construct($message);
21+
}
1622
}

‎src/Symfony/Component/Uid/Exception/InvalidUlidException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Uid/Exception/InvalidUlidException.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ class InvalidUlidException extends InvalidArgumentException
1515
{
1616
public function __construct(string $value)
1717
{
18-
parent::__construct(\sprintf('Invalid ULID: "%s".', $value));
18+
parent::__construct($value, \sprintf('Invalid ULID: "%s".', $value));
1919
}
2020
}

‎src/Symfony/Component/Uid/Exception/InvalidUuidException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Uid/Exception/InvalidUuidException.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ public function __construct(
1717
public readonly int $type,
1818
string $value,
1919
) {
20-
parent::__construct(\sprintf('Invalid UUID%s: "%s".', $type ? 'v'.$type : '', $value));
20+
parent::__construct($value, \sprintf('Invalid UUID%s: "%s".', $type ? 'v'.$type : '', $value));
2121
}
2222
}

‎src/Symfony/Component/Uid/Ulid.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Uid/Ulid.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public static function generate(?\DateTimeInterface $time = null): string
157157
$time = microtime(false);
158158
$time = substr($time, 11).substr($time, 2, 3);
159159
} elseif (0 > $time = $time->format('Uv')) {
160-
throw new InvalidArgumentException('The timestamp must be positive.');
160+
throw new InvalidArgumentException($time, 'The timestamp must be positive.');
161161
}
162162

163163
if ($time > self::$time || (null !== $mtime && $time !== self::$time)) {

‎src/Symfony/Component/Uid/UuidV6.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Uid/UuidV6.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function toV7(): UuidV7
5050
$uuid = $this->uid;
5151
$time = BinaryUtil::hexToNumericString('0'.substr($uuid, 0, 8).substr($uuid, 9, 4).substr($uuid, 15, 3));
5252
if ('-' === $time[0]) {
53-
throw new InvalidArgumentException('Cannot convert UUID to v7: its timestamp is before the Unix epoch.');
53+
throw new InvalidArgumentException($uuid, 'Cannot convert UUID to v7: its timestamp is before the Unix epoch.');
5454
}
5555

5656
$ms = \strlen($time) > 4 ? substr($time, 0, -4) : '0';

‎src/Symfony/Component/Uid/UuidV7.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Uid/UuidV7.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static function generate(?\DateTimeInterface $time = null): string
5757
$time = microtime(false);
5858
$time = substr($time, 11).substr($time, 2, 3);
5959
} elseif (0 > $time = $time->format('Uv')) {
60-
throw new InvalidArgumentException('The timestamp must be positive.');
60+
throw new InvalidArgumentException($time, 'The timestamp must be positive.');
6161
}
6262

6363
if ($time > self::$time || (null !== $mtime && $time !== self::$time)) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.