mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-13 15:46:53 +03:00
fix: Amends psalm assertion syntax on Uuid::isValid() to prevent incorrect type inference (#486)
* fix: Amends psalm assertion syntax on `Uuid::isValid()` to prevent incorrect type inference * Add static analysis test case for invalid input
This commit is contained in:
+1
-1
@@ -569,7 +569,7 @@ class Uuid implements UuidInterface
|
||||
* @psalm-pure note: changing the internal factory is an edge case not covered by purity invariants,
|
||||
* but under constant factory setups, this method operates in functionally pure manners
|
||||
*
|
||||
* @psalm-assert-if-true non-empty-string $uuid
|
||||
* @psalm-assert-if-true =non-empty-string $uuid
|
||||
*/
|
||||
public static function isValid(string $uuid): bool
|
||||
{
|
||||
|
||||
@@ -32,4 +32,13 @@ final class ValidUuidIsNonEmpty
|
||||
|
||||
throw new InvalidArgumentException('Not a UUID');
|
||||
}
|
||||
|
||||
public function givenInvalidInputValueRemainsAString(string $input): string
|
||||
{
|
||||
if (Uuid::isValid($input)) {
|
||||
return 'It Worked!';
|
||||
}
|
||||
|
||||
return $input;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user