Adds support for macros (#500)

* Adds support for macros

* Fixes formatting
This commit is contained in:
Matthew Erwin
2017-05-05 11:22:12 +02:00
committed by Barry vd. Heuvel
parent 2a63d51496
commit b76156b24c
2 changed files with 65 additions and 0 deletions
+18
View File
@@ -312,6 +312,24 @@ class Alias
}
}
}
// Check if the class is macroable
$traits = collect($reflection->getTraitNames());
if ($traits->contains('Illuminate\Support\Traits\Macroable')) {
$properties = $reflection->getStaticProperties();
$macros = isset($properties['macros']) ? $properties['macros'] : [];
foreach ($macros as $macro_name => $macro_func) {
$function = new \ReflectionFunction($macro_func);
// Add macros
$this->methods[] = new Macro(
$function,
$this->alias,
$reflection,
$macro_name,
$this->interfaces
);
}
}
}
}