Timeline for Is there a way to document required properties in traits (PHP)?
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 17, 2020 at 0:00 | history | tweeted | twitter.com/StackSoftEng/status/1239703066741481472 | ||
| Mar 16, 2020 at 5:49 | comment | added | slepic | Stop and think for a moment why you think you need a trait in the first place. Traits cannot enforce properties, the same reason you cannot put properties on interfaces in PHP. Traits should be your last resort, dont use them if you dont have to. | |
| Mar 16, 2020 at 5:02 | answer | added | LinuXpert | timeline score: 4 | |
| Aug 17, 2015 at 21:49 | comment | added | Privateer | Thanks awons. Reviewing what I was doing at the time I did have a couple of conceptual problems. | |
| Jun 28, 2015 at 18:12 | comment | added | Aleksander Wons | I am putting into a comment since it doesn't exactly answer your question. Anyway. There is no way to ensure things like that because trait is not part of the class. You can think of it (it's a bit oversimplified) as of an include for classes. It is a simple way of doing copy/paste without code duplication. If you have a shared functionality in your trait then this trait should already have everything to work by itself. If it doesn't you might already have some conceptual issues. | |
| Jan 29, 2015 at 4:57 | answer | added | Privateer | timeline score: 11 | |
| Jan 29, 2015 at 2:36 | review | First posts | |||
| Jan 29, 2015 at 8:37 | |||||
| Jan 29, 2015 at 2:34 | history | asked | Privateer | CC BY-SA 3.0 |