DEV Community

Discussion on: All flavors of PHP 8 getters

Collapse
andreidascalu profile image
Andrei Dascalu

You have a weird definition of what's a pro and a con:

  • 2 birds with one stone => violate SRP, which you mention so technically you're calling the pro also a con (fair, but confusing)
  • can execute arbitrary code => violate the meaning of getter (eg: return the underlying value, the expectation is not to have arbitrary side-effects), technically is a call to violate SRP

"Getter/setter" - also same 'con' as public access: anyone can change the value.

Collapse
bdelespierre profile image
Benjamin Delespierre Author

Thanks for your message. Your concerns actually make sense. I'll change the article.