(image credits the Joomla Community)
Value Objects
A value object is a small object that represents a simple entity whose equality is ...
For further actions, you may consider blocking this person and/or reporting abuse
If
$value
is private, then this comparison:should not be possible?
In PHP encapsulation is done at class level, not object level, so you can "visit" other instances' private properties value.
I stand corrected.
PHP needs a
__equals
magic method :)That would be fantastic. How about you draft an RFC for that?
Someone proposed it for PHP 7.3, but it was declined: PHP RFC: User-defined object comparison
It is difficult to find the reasons for why it was declined: github.com/php/php-src/pull/3339#i...
As someone mentioned on a PHP podcast, the PHP RFC voting system needs a lot of improvement.
I understand. While things could certainly be better, I think we need to be careful: changing the RFC system could jeopardize the backward-compatibility, which is IMHO the best aspect of the platform.
Great article, great usecase !
Thanks 🙏
Is it really necessary to make constructor private for final class?
NIce one