Cannot instantiate trait %s

Description

Traits cannot be instantiated directly. They need to be used in a class, or another trait, which will also need to be used in a class.

Example

<?php

trait T {}

//Cannot instantiate trait T
new T();

?>

Literal Examples

  • Cannot instantiate trait t

Solutions

  • Use one of the class using that trait.

  • Rewrite the trait into an class.