Timeline for Is there a way to document required properties in traits (PHP)?
Current License: CC BY-SA 3.0
2 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 20, 2020 at 21:41 | comment | added | Kamafeather | An improved version might be to define accessors (setter only in case the trait needs writing on the prop) and just ask the user to provide implementation inside the class; as you say. Imho the getter shouldn't do any validation of requirements from the trait; it should not throw an exception, but just access the data in the custom property defined on the class. Is IoC, implicitly gives the responsibility of choosing the data source and returning the correct value, to the user of the trait. It reduces boilerplate and prevents trying to validate any possible wrong thing the user could do | |
Jan 29, 2015 at 4:57 | history | answered | Privateer | CC BY-SA 3.0 |