From 53c732a96d5e50b5c93a5b7b8a074731b5411d1d Mon Sep 17 00:00:00 2001 From: Eridan Domoratskiy Date: Thu, 19 Jul 2018 17:54:04 +0300 Subject: [PATCH] Add useFunction() and useConst() builder methods --- lib/PhpParser/BuilderFactory.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/PhpParser/BuilderFactory.php b/lib/PhpParser/BuilderFactory.php index ee85558..10028cd 100644 --- a/lib/PhpParser/BuilderFactory.php +++ b/lib/PhpParser/BuilderFactory.php @@ -104,7 +104,7 @@ class BuilderFactory /** * Creates a namespace/class use builder. * - * @param string|Node\Name $name Name to alias + * @param Node\Name|string $name Name of the entity (namespace or class) to alias * * @return Builder\Use_ The create use builder */ @@ -112,6 +112,28 @@ class BuilderFactory return new Builder\Use_($name, Use_::TYPE_NORMAL); } + /** + * Creates a function use builder. + * + * @param Node\Name|string $name Name of the function to alias + * + * @return Builder\Use_ The create use builder + */ + public function useFunction($name) : Builder\Use_ { + return new Builder\Use_($name, Use_::TYPE_FUNCTION); + } + + /** + * Creates a constant use builder. + * + * @param Node\Name|string $name Name of the const to alias + * + * @return Builder\Use_ The create use builder + */ + public function useConst($name) : Builder\Use_ { + return new Builder\Use_($name, Use_::TYPE_CONSTANT); + } + /** * Creates node a for a literal value. *