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:
George Steel
2023-01-10 22:09:08 +00:00
committed by GitHub
parent 9077ba9f0e
commit 4a14ce0c62
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -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;
}
}