diff --git a/lib/BladeOne.php b/lib/BladeOne.php index 91d7ad1..28a1342 100644 --- a/lib/BladeOne.php +++ b/lib/BladeOne.php @@ -278,9 +278,13 @@ public function __construct($templatePath = null, $compiledPath = null, $mode = // 2- it must don't have arguments // 3- It must have the name of the trait. i.e. trait=MyTrait, method=MyTrait() $traits = get_declared_traits(); + $currentTraits = (array) class_uses($this); foreach ($traits as $trait) { $r = explode('\\', $trait); $name = end($r); + if (!in_array($trait, $currentTraits, true)) { + continue; + } if (is_callable([$this, $name]) && method_exists($this, $name)) { $this->{$name}(); }