Top "Traits" questions

In computer programming, a trait is a collection of methods, used as a "simple conceptual model for structuring object oriented programs"

Collisions with other trait methods

How can I deal with traits with methods of same name? trait FooTrait { public function fooMethod() { return 'foo method'; } public …

php traits php-5.5
How to declare traits as taking implicit "constructor parameters"?

I'm designing a class hierarchy, which consists of a base class along with several traits. The base class provides default …

scala implicit traits
How would you implement a "trait" design-pattern in C#?

I know the feature doesn't exist in C#, but PHP recently added a feature called Traits which I thought was …

c# design-patterns traits code-reuse default-interface-member
How to mix-in a trait to instance?

Given a trait MyTrait: trait MyTrait { def doSomething = println("boo") } it can be mixed into a class with extends or …

scala traits
Extend Traits with Classes in PHP?

Why we are not allowed to extend Traits with Classes in PHP? For example: Trait T { } Class C use T {} /* …

php oop traits
Scala case class extending Product with Serializable

I am learning scala and tried following form Scala Cookbook: trait Animal trait FurryAnimal extends Animal case class Dog(name:…

scala types traits case-class
The trait cannot be made into an object

I have the following code: extern crate futures; // 0.1.24 use futures::Future; use std::io; struct Context; pub trait MyTrait { fn …

generics rust traits dynamic-dispatch trait-objects
Is there a way to extend a trait in PHP?

I want to use functionality of an existing trait and create my own trait on top of it only to …

php laravel traits php-7
Where to place traits in Laravel 5?

I am using Laravel 5 and I am confused about where to place traits files in the Laravel 5 directory structure. Should …

php laravel-5 traits
PHP instanceof for traits

What is the proper way to check if a class uses a certain trait?

php class instanceof traits