Giter Site home page Giter Site logo

Serializable Uuid's. about uuid HOT 3 CLOSED

ramsey avatar ramsey commented on May 7, 2024
Serializable Uuid's.

from uuid.

Comments (3)

ramsey avatar ramsey commented on May 7, 2024

What is the output corruption you're seeing?

I gave some thought to this when I accepted the JsonSerializable pull request, but I couldn't figure out the value of it, since the behavior would be confusing.

If we serialize it to a string representation of a UUID, what information is available in the serialized representation to tell PHP to unserialize it back into a Ramsey\Uuid\Uuid object? It seems to me the engine would see it as a serialized string (despite having an unserialize method on the class) and unserialize it into a PHP string, which is not what I would expect.

If my understanding of how this would work is wrong, let me know.

from uuid.

frankdejonge avatar frankdejonge commented on May 7, 2024

@ramsey the string representation output by the serialize method is used for the output rather than replacing the output, so the output is something like:

"C:16:"Ramsey\Uuid\Uuid":36:{daf8aaf8-be7a-46ed-88ae-41221f36ba11}"

So in practice a this:

$oldUuid = Uuid::uuid4();
$uuid = Uuid::fromString($oldUuid->toString());
$oldUuid->equals($uuid); // true

Will be the same as:

$oldUuid = Uuid::uuid4();
$uuid = unserialize(serialize($oldUuid);
$oldUuid->equals($uuid); // true

Hope this clears it up.

from uuid.

ramsey avatar ramsey commented on May 7, 2024

Interesting. Please proceed. :-)

from uuid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.