Skip to content

Commit

Permalink
fix: avoid trait collision on BladeOne constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Luc-cpl committed Dec 19, 2023
1 parent 019036c commit baf193d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/BladeOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}();
}
Expand Down

0 comments on commit baf193d

Please sign in to comment.