Skip to content

Commit

Permalink
Merge pull request #184 from Luc-cpl/master
Browse files Browse the repository at this point in the history
Fix trait collision on BladeOne constructor
  • Loading branch information
jorgecc authored Feb 1, 2024
2 parents 019036c + baf193d commit 9c80b89
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 9c80b89

Please sign in to comment.