About the use of php traits

problem description

has been doing interface development recently, and suddenly I have an idea:
encapsulate traits, for each interface method and then create an interface class. The function of the interface class is to combine the traits interface to form a complete interface. In this way, you only need to replace the corresponding traits during the iteration of the version update.
is this feasible? Or is there any drawback?

Php
Mar.30,2021

first of all, one of your ideas is very good, that is, using traits to reuse code, traits itself is designed to solve the problem that PHP cannot inherit much and reuse code

but your above design, I think of some questions:

  1. how do different versions of a service exist at the same time (do you maintain a different version of traits)
  2. how your class only inherits different functions, traits, then why do it directly with the corresponding base class, do it with traits? this question is worth thinking about
  3. in actual development, traits is more likely to act as some abstract common parts, such as an abstract class An and an abstract class B. they may want to share some methods or something at the same time. You can use traits
  4. .
  5. when you ask this question, what I feel on my side is that you need to think more about how to design classes and how to design your software architecture
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bed8-3469d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bed8-3469d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?