woohoolabs / yang

The efficient and elegant, PSR-7 compliant JSON:API 1.1 client library for PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ClassDocumentHydrator::hydrateSingleResource() enforces use of stdClass

holtkamp opened this issue · comments

See:

public function hydrateSingleResource(Document $document): stdClass

Which prevents the use of a custom hydrator which returns other objects.

PR here: #24

@kocsismate do you need meer information on this issue and PR? Or are the intents clear?

Hey @holtkamp Sorry for the delay!

Yes, the intents are clear (and I agree with it completely), my only problem is (and it's the reason I haven't answered yet) that technically, it's a BC break. :/ I am not sure though that the change breaks any compatibility in the practice. What do you think about the BC aspect of the change?

technically, it's a BC break.

mmm, is it?

An object is "looser" than specifically an instance of stdClass...

All instances of stdClass are an object, so AFAIK this is not a BC break but a bug fix :neckbeard:

I think this stdClass return type was simply "forgotten", so I added a test to never forget it again 😄

So a patch version 2.2.1 would suffice to release this.

I said that it's a BC break mainly because if someone overrides the hydrateSingleResource() then they will face an issue. At least below PHP 7.4 😎 https://3v4l.org/YaolE

All in all, let's merge your PR, it brings quite some benefits while its BC break aspect doesn't seem much in practice. Thank you for your work!

I said that it's a BC break mainly because if someone overrides the hydrateSingleResource() then they will face an issue. At least below PHP 7.4 😎 https://3v4l.org/YaolE

aaah, did you mean it like that. Mmm, yeah that is true.. Fingers crossed nobody did that yet 😉

Thank you for your effort!