8000 [Uid] Add `@return non-empty-string` annotations to `AbstractUid` and relevant functions by niravpateljoin · Pull Request #59075 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Uid] Add @return non-empty-string annotations to AbstractUid and relevant functions #59075

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

Merged
Changes from all commits
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
22 changes: 22 additions & 0 deletions src/Symfony/Component/Uid/AbstractUid.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,17 @@ public static function fromRfc4122(string $uid): static

/**
* Returns the identifier as a raw binary string.
*
* @return non-empty-string
*/
abstract public function toBinary(): string;

/**
* Returns the identifier as a base58 case-sensitive string.
*
* @example 2AifFTC3zXgZzK5fPrrprL (len=22)
*
* @return non-empty-string
*/
public function toBase58(): string
{
Expand All @@ -104,6 +108,8 @@ public function toBase58(): string
* @see https://tools.ietf.org/html/rfc4648#section-6
*
* @example 09EJ0S614A9FXVG9C5537Q9ZE1 (len=26)
*
* @return non-empty-string
*/
public function toBase32(): string
{
Expand All @@ -127,6 +133,8 @@ public function toBase32(): string
* @see https://datatracker.ietf.org/doc/html/rfc9562/#section-4
*
* @example 09748193-048a-4bfb-b825-8528cf74fdc1 (len=36)
*
* @return non-empty-string
*/
public function toRfc4122(): string
{
Expand All @@ -143,6 +151,8 @@ public function toRfc4122(): string
* Returns the identifier as a prefixed hexadecimal case insensitive string.
*
* @example 0x09748193048a4bfbb8258528cf74fdc1 (len=34)
*
* @return non-empty-string
*/
public function toHex(): string
{
Expand All @@ -161,6 +171,9 @@ public function equals(mixed $other): bool
return $this->uid === $other->uid;
}

/**
* @return non-empty-string
*/
public function hash(): string
{
return $this->uid;
Expand All @@ -171,16 +184,25 @@ public function compare(self $other): int
return (\strlen($this->uid) - \strlen($other->uid)) ?: ($this->uid <=> $other->uid);
}

/**
* @return non-empty-string
*/
final public function toString(): string
{
return $this->__toString();
}

/**
* @return non-empty-string
*/
public function __toString(): string
{
return $this->uid;
}

/**
* @return non-empty-string
*/
public function jsonSerialize(): string
{
return $this->uid;
Expand Down
Loading
0