Open rgazelot opened 7 years ago
This will require to change signature to public function setData(?ElementInterface $element)
what will lead drop PHP7.0 support. Because nullable types are available since PHP7.1 only.
What about public function setData(ElementInterface $element = null)
?
By this way you will only be able to do $document->setData();
but not $docuemnt->setData(null)
. Try it yourself.
I agree that PHP7.1 nullable argument are by far the best way to do it, but I'm ok with the PHP7.0 compatibility. Maybe just keep in mind this thing for a future PHP7.1 support?
For PHP 7.0 compatibility, we would probably need a clearData()
function then.
What about creating a special case: function setNullData(): void
?
Before implement any of proposed ways we need to define concrete use case for it.
I think that the method Document::setData($element) should accept a nullable value as the constructor does.