Skip to content
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

[4.0] UuidVX::fromString should fail if provided string belongs to a different version #301

Open
jacekkarczmarczyk opened this issue Mar 23, 2020 · 3 comments
Labels

Comments

@jacekkarczmarczyk
Copy link

Describe the bug

Specific version factory, unlike the general one (RamsayUuid::uuidX()) should fail if provided string belongs to a different version

To Reproduce...

        $uuid4String = RamseyUuid::uuid4()->toString();
        $uuid = UuidV1::fromString($uuid4String);
        assert($uuid instanceof UuidV1);

Expected behavior

UuidV1::fromString should throw InvalidArgumentException

Screenshots or output

  • UuidV1::fromString returns instance of UuidV4
  • assert fails

Environment details

  • OS: Windows 10
  • PHP version: 7.4
  • ramsey/uuid version: 4.0
@ramsey
Copy link
Owner

ramsey commented Mar 23, 2020

Good catch. This is a result of these classes extending Ramsey\Uuid\Uuid right now. Technically, they shouldn't even have the static methods, since these methods are not part of the interface. In version 5.0, Ramsey\Uuid\Uuid will be a final, static class, and these subclasses will not have these static methods, so I'm not sure whether this requires any action at this point.

@jacekkarczmarczyk
Copy link
Author

Is 5.0 coming soon?

@ramsey
Copy link
Owner

ramsey commented Mar 24, 2020

Not until PHP 8. I just released 4.0 two days ago. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants