Traits vs Interfaces in PHP: when to use what?
Hello everyone! I'm a beginner PHP developer, and I constantly get confused about when to use traits and when to use interfaces. They both seem to help with code reuse, but I feel they are different things.
Here's a specific example. I have a `Car` class and a `Bicycle` class. Both can move, so I created a `MovableInterface` with a `move()` method. This works, but in each class I have to write my own implementation of the `move()` method.
Then I learned about traits. I created an `EngineTrait` with a `startEngine()` method. Now I can attach it to the `Car` class, but not to `Bicycle`, because a bicycle doesn't have an engine. And then I thought: wouldn't it be better to make `startEngine()` an interface method? But then I would have to implement it in `Bicycle` as well, where it's not needed.