Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Document::setData() should be nullable #130

Open
rgazelot opened this issue Jun 30, 2017 · 7 comments
Open

Document::setData() should be nullable #130

rgazelot opened this issue Jun 30, 2017 · 7 comments

Comments

@rgazelot
Copy link

I think that the method Document::setData($element) should accept a nullable value as the constructor does.

@rgazelot rgazelot changed the title Document::addData() should be nullable Document::setData() should be nullable Jun 30, 2017
@antonkomarev
Copy link

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.

@rgazelot
Copy link
Author

What about public function setData(ElementInterface $element = null)?

@antonkomarev
Copy link

By this way you will only be able to do $document->setData(); but not $docuemnt->setData(null). Try it yourself.

@rgazelot
Copy link
Author

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?

@franzliedke
Copy link
Contributor

For PHP 7.0 compatibility, we would probably need a clearData() function then.

@f3ath
Copy link
Contributor

f3ath commented Sep 29, 2017

What about creating a special case: function setNullData(): void?

@antonkomarev
Copy link

Before implement any of proposed ways we need to define concrete use case for it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants