GithubHelp home page GithubHelp logo

Comments (8)

tchiotludo avatar tchiotludo commented on July 17, 2024 1

The same bug here in php 7.0.7 cloning a Carbon object with this error :

Unknown getter 'date'
InvalidArgumentException code(0) in /vendor/nesbot/carbon/src/Carbon/Carbon.php line 527

at Carbon\Carbon->__get ('date') in Carbon.php line 527
at getValue (Object(Cawa\Date\DateTime)) in DeepCopy.php line 179

In case it may help you, I've a similar bug on datetime related to this thread :
http://news.php.net/php.internals/93826%20view%20original
Datetime is not accessible via reflection and it seems to be "normal"

In my case, for a recursive serialize of object, I used a ugly hack that handle datetime like undeclared public properties : https://github.com/cawaphp/cawa/blob/master/src/Serializer/Serializer.php#L128
and unserialize is also hacky for internal class : https://github.com/cawaphp/cawa/blob/master/src/Serializer/Serializer.php#L205

@mnapoli : for simple cloning, take care about extends class that will contains reference like DatePeriod for example

from deepcopy.

mnapoli avatar mnapoli commented on July 17, 2024

That's interesting! The best solution I think would be to not try to iterate on internal classes properties: objects like DateTime or stdClass should simply be cloned as-is I guess (because they usually don't have references to other objects so we can treat them as values).

from deepcopy.

arthurkhusnullin avatar arthurkhusnullin commented on July 17, 2024

Also Notice: Undefined property: DateTimeZone::$timezone_type

from deepcopy.

peternijssen avatar peternijssen commented on July 17, 2024

@mnapoli I added a check for internal objects. (see pull request #42) The problem is now that multiple tests are failing because the tests are depending on the StdClass object. I am not sure if we should exclude that class from cloning or not.

The only thing I can think off right now is to let StdClass be cloned or change the tests to actually have a self defined object.

from deepcopy.

ladamalina avatar ladamalina commented on July 17, 2024

@theofidry Please, merge your fix asap. Our Jenkins unit tests are stuck because of DeepCopy bug with DateTime::$date 🙇 🙇

from deepcopy.

theofidry avatar theofidry commented on July 17, 2024

@ladamalina I'm not a maintainer and I don't have write access either, so the maintainers need to review my fix first and decide to merge it or not :)

from deepcopy.

mnapoli avatar mnapoli commented on July 17, 2024

I'm very sorry for the delay everyone. I've merged #43 and tagged 1.5.2, please check out if all works fine for you now.

Thanks @theofidry and others who contributed and review the fix.

from deepcopy.

theofidry avatar theofidry commented on July 17, 2024

You're welcome, works like a charm on my end ;)

from deepcopy.

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.