funeralzone / valueobjects

A PHP 7 value objects helper library.
MIT License
66 stars 8 forks source link

Wrong typehint on EnumTrait::fromNative() #15

Open joshua-bn opened 3 years ago

joshua-bn commented 3 years ago

https://github.com/funeralzone/valueobjects/blob/master/src/Enums/EnumTrait.php#L53 should be string

Why not put the typehint on the signature?

chrisharrison commented 3 years ago

You're absolutely right that the docblock is incorrect. If you create a PR, someone will accept it (I can't, because I've left the company that maintains this).

It can't be a typehint on the signature though, because that would break the interface defined here: https://github.com/funeralzone/valueobjects/blob/master/src/ValueObject.php

The idea is that all value objects have the fromNative and toNative methods. If we type hinted in the signature to a string it would break other value objects whose fromNative is not a string.