tag:blogger.com,1999:blog-5023448542823447711.post6337948050372012128..comments2023-09-22T04:05:16.253-07:00Comments on Optimizely Module: Notes on Converting to Drupal 8: Drupal 8 requires PHP 5.4 or higher, and PHP traitsEarl Fonghttp://www.blogger.com/profile/05682372868411855409noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-5023448542823447711.post-21005436407149458152014-07-08T15:15:38.762-07:002014-07-08T15:15:38.762-07:00There are some good answers in this StackOverflow ...There are some good answers in this StackOverflow item: https://stackoverflow.com/questions/9205083/php-traits-vs-interfaces<br /><br />I think the lengthy comment by rdlowery is especially worth reading. It's near the top of the page.<br /><br />My use of a trait in this post is just an example of code reuse of two small methods. But now that I've looked at it again, defining a class instead of a trait, and declaring a property of that class within the client classes that need the functionality might be a better way to go.Earl Fonghttps://www.blogger.com/profile/05682372868411855409noreply@blogger.comtag:blogger.com,1999:blog-5023448542823447711.post-29892332848313761292014-07-08T14:53:18.654-07:002014-07-08T14:53:18.654-07:00So far, I haven't seen anything about the use ...So far, I haven't seen anything about the use of the ternary operator, including in the coding standards that I've happened across.<br /><br />I always strive for clarity first, then brevity. So I do use the ternary op as long as the resulting code is clear and easy to understand. That almost always means that the code is also concise.<br /><br />Otherwise, I prefer use of an "if-else" statement and try to avoid being too clever.Earl Fonghttps://www.blogger.com/profile/05682372868411855409noreply@blogger.comtag:blogger.com,1999:blog-5023448542823447711.post-82512372989748359762014-07-08T14:05:31.428-07:002014-07-08T14:05:31.428-07:00Do you know of any guidelines as to when to use tr...Do you know of any guidelines as to when to use traits?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-5023448542823447711.post-51490119692795925372014-07-08T14:04:26.998-07:002014-07-08T14:04:26.998-07:00For what it's worth, use of tertiaries is disc...For what it's worth, use of tertiaries is discourage in D7 coding standards. Perhaps this has changed in D8?Anonymousnoreply@blogger.com