{"action":"created","issue":{"url":"https://api.github.com/repos/sebastianbergmann/comparator/issues/18","labels_url":"https://api.github.com/repos/sebastianbergmann/comparator/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/sebastianbergmann/comparator/issues/18/comments","events_url":"https://api.github.com/repos/sebastianbergmann/comparator/issues/18/events","html_url":"https://github.com/sebastianbergmann/comparator/pull/18","id":95847744,"number":18,"title":"Support DateTimeInterface in DateTimeComparator","user":{"login":"VasekPurchart","id":406821,"avatar_url":"https://avatars.githubusercontent.com/u/406821?v=3","gravatar_id":"","url":"https://api.github.com/users/VasekPurchart","html_url":"https://github.com/VasekPurchart","followers_url":"https://api.github.com/users/VasekPurchart/followers","following_url":"https://api.github.com/users/VasekPurchart/following{/other_user}","gists_url":"https://api.github.com/users/VasekPurchart/gists{/gist_id}","starred_url":"https://api.github.com/users/VasekPurchart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VasekPurchart/subscriptions","organizations_url":"https://api.github.com/users/VasekPurchart/orgs","repos_url":"https://api.github.com/users/VasekPurchart/repos","events_url":"https://api.github.com/users/VasekPurchart/events{/privacy}","received_events_url":"https://api.github.com/users/VasekPurchart/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-18T18:28:27Z","updated_at":"2015-07-26T13:20:43Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sebastianbergmann/comparator/pulls/18","html_url":"https://github.com/sebastianbergmann/comparator/pull/18","diff_url":"https://github.com/sebastianbergmann/comparator/pull/18.diff","patch_url":"https://github.com/sebastianbergmann/comparator/pull/18.patch"},"body":"DateTimeComparator is a great tool for comparing DateTime instances and very helpful in PHPUnit for providing assertEquals functionality for these objects.\r\n\r\nThe fact that it compares DT instances based on their actual represented time is great, because that is, what you usually want to compare in your tests (not that the DT instances are actually equal - meaning including the time zone etc.).\r\n\r\nCurrently there is one big drawback and that is no support for DateTimeInterface (hence also no support for DateTimeImmutable).\r\n\r\nYou can simply do \r\n```php\r\n<?php\r\n$this->assertEquals(\r\n  new DateTime('2013-03-29T05:13:35-0600'),\r\n  new DateTime('2013-03-29T05:13:35-0500')\r\n);\r\n```\r\nbut you cannot do\r\n```php\r\n<?php\r\n$this->assertEquals(\r\n  new DateTime('2013-03-29T05:13:35-0600'),\r\n  new DateTimeImmutable('2013-03-29T05:13:35-0500')\r\n);\r\n```\r\n\r\nI think this should be definitely supported for the sake of consistency and user expectations and this PR provides the support.\r\n\r\nImplementation notes:\r\n* Since the interfaces are not present before PHP 5.5 the tests were added as separate tests, not in current providers, so that they can be skipped nicely.\r\n* I had to remove the `DateTime` typehint in `DateTimeComparator::dateTimeToString`, because otherwise it would be not compatible and `DateTimeInterface` cannot be required because of the older versions. I chose not to add any verification of the argument since this is a protected method, if you want me to check the argument and throw an exception (or something else, since there is already an error string returned?), just tell me.\r\n* I am not sure if the string `'Invalid DateTime object'` returned from `DateTimeComparator::dateTimeToString` should be changed, because someone might consider it part of the interface (for representing error state), but again I think clarity is more important in this case."},"comment":{"url":"https://api.github.com/repos/sebastianbergmann/comparator/issues/comments/124984552","html_url":"https://github.com/sebastianbergmann/comparator/pull/18#issuecomment-124984552","issue_url":"https://api.github.com/repos/sebastianbergmann/comparator/issues/18","id":124984552,"user":{"login":"VasekPurchart","id":406821,"avatar_url":"https://avatars.githubusercontent.com/u/406821?v=3","gravatar_id":"","url":"https://api.github.com/users/VasekPurchart","html_url":"https://github.com/VasekPurchart","followers_url":"https://api.github.com/users/VasekPurchart/followers","following_url":"https://api.github.com/users/VasekPurchart/following{/other_user}","gists_url":"https://api.github.com/users/VasekPurchart/gists{/gist_id}","starred_url":"https://api.github.com/users/VasekPurchart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VasekPurchart/subscriptions","organizations_url":"https://api.github.com/users/VasekPurchart/orgs","repos_url":"https://api.github.com/users/VasekPurchart/repos","events_url":"https://api.github.com/users/VasekPurchart/events{/privacy}","received_events_url":"https://api.github.com/users/VasekPurchart/received_events","type":"User","site_admin":false},"created_at":"2015-07-26T13:20:43Z","updated_at":"2015-07-26T13:20:43Z","body":"Hi @sebastianbergmann, I have just seen that you released a new version of this repo. I was hoping that someone will look at this PR before releasing a new version, I've tried to make it as ready as possible. Since Jeff isn't active lately I was hoping that you could check this improvement before releasing a new version.\r\n\r\nIs there anything I could do to ease the review even more?"}}