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

[Uid] Unify InvalidUuidException and InvalidUlidException #60328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Unify InvalidUuidException and InvalidUlidException into single Inval…
…idUidException
  • Loading branch information
rela589n committed May 2, 2025
commit dcec307ab0df390d56a63d4d71d6226bc04b793b
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@

namespace Symfony\Component\Uid\Exception;

class InvalidUlidException extends InvalidArgumentException
class InvalidUidException extends InvalidArgumentException
{
public function __construct(string $value)
{
parent::__construct(\sprintf('Invalid ULID: "%s".', $value));
}
}
22 changes: 0 additions & 22 deletions 22 src/Symfony/Component/Uid/Exception/InvalidUuidException.php

This file was deleted.

4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/Uid/Tests/UlidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use PHPUnit\Framework\TestCase;
use Symfony\Component\Uid\Exception\InvalidArgumentException;
use Symfony\Component\Uid\Exception\InvalidUlidException;
use Symfony\Component\Uid\Exception\InvalidUidException;
use Symfony\Component\Uid\MaxUlid;
use Symfony\Component\Uid\NilUlid;
use Symfony\Component\Uid\Tests\Fixtures\CustomUlid;
Expand Down Expand Up @@ -43,7 +43,7 @@ public function testGenerate()

public function testWithInvalidUlid()
{
$this->expectException(InvalidUlidException::class);
$this->expectException(InvalidUidException::class);
$this->expectExceptionMessage('Invalid ULID: "this is not a ulid".');

new Ulid('this is not a ulid');
Expand Down
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/Uid/Ulid.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Component\Uid;

use Symfony\Component\Uid\Exception\InvalidArgumentException;
use Symfony\Component\Uid\Exception\InvalidUlidException;
use Symfony\Component\Uid\Exception\InvalidUidException;

/**
* A ULID is lexicographically sortable and contains a 48-bit timestamp and 80-bit of crypto-random entropy.
Expand All @@ -39,7 +39,7 @@ public function __construct(?string $ulid = null)
$this->uid = $ulid;
} else {
if (!self::isValid($ulid)) {
throw new InvalidUlidException($ulid);
throw new InvalidUidException(\sprintf('Invalid ULID: "%s".', $ulid));
}

$this->uid = strtoupper($ulid);
Expand Down
6 changes: 3 additions & 3 deletions 6 src/Symfony/Component/Uid/Uuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\Uid;

use Symfony\Component\Uid\Exception\InvalidUuidException;
use Symfony\Component\Uid\Exception\InvalidUidException;

/**
* @author Grégoire Pineau <lyrixx@lyrixx.info>
Expand Down Expand Up @@ -41,13 +41,13 @@ public function __construct(string $uuid, bool $checkVariant = false)
$type = preg_match('{^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$}Di', $uuid) ? (int) $uuid[14] : false;

if (false === $type || (static::TYPE ?: $type) !== $type) {
throw new InvalidUuidException(static::TYPE, $uuid);
throw new InvalidUidException(\sprintf('Invalid UUID%s: "%s".', static::TYPE ? 'v'.static::TYPE : '', $uuid));
}

$this->uid = strtolower($uuid);

if ($checkVariant && !\in_array($this->uid[19], ['8', '9', 'a', 'b'], true)) {
throw new InvalidUuidException(static::TYPE, $uuid);
throw new InvalidUidException(\sprintf('Invalid UUID%s: "%s".', static::TYPE ? 'v'.static::TYPE : '', $uuid));
}
}

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.