PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.7.0
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.7.0
4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.5.2 All 199 releases
betterdocs / includes / Dependencies / PhpParser / Builder / Use_.php

Use_.php in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.7.0, at includes/Dependencies/PhpParser/Builder/Use_.php

60 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:ignoreFile -- Bundled third-party (Mozart) dependency; exempt from plugin coding standards.
3
4 namespace WPDeveloper\BetterDocs\Dependencies\PhpParser\Builder;
5
6 use WPDeveloper\BetterDocs\Dependencies\PhpParser\BuilderAbstract;
7 use WPDeveloper\BetterDocs\Dependencies\PhpParser\Node;
8 use WPDeveloper\BetterDocs\Dependencies\PhpParser\Node\Stmt;
9
10 /**
11 * @method $this as(string $alias) Sets alias for used name.
12 */
13 class Use_ extends BuilderAbstract {
14 protected $name;
15 protected $type;
16 protected $alias = null;
17
18 /**
19 * Creates a name use (alias) builder.
20 *
21 * @param Node\Name|string $name Name of the entity (namespace, class, function, constant) to alias
22 * @param int $type One of the Stmt\Use_::TYPE_* constants
23 */
24 public function __construct($name, $type) {
25 $this->name = $this->normalizeName($name);
26 $this->type = $type;
27 }
28
29 /**
30 * Sets alias for used name.
31 *
32 * @param string $alias Alias to use (last component of full name by default)
33 *
34 * @return $this The builder instance (for fluid interface)
35 */
36 protected function as_($alias) {
37 $this->alias = $alias;
38 return $this;
39 }
40 public function __call($name, $args) {
41 if (method_exists($this, $name . '_')) {
42 return call_user_func_array(array($this, $name . '_'), $args);
43 }
44
45 throw new \LogicException(sprintf('Method "%s" does not exist', $name));
46 }
47
48 /**
49 * Returns the built node.
50 *
51 * @return Node The built node
52 */
53 public function getNode() {
54 $alias = null !== $this->alias ? $this->alias : $this->name->getLast();
55 return new Stmt\Use_(array(
56 new Stmt\UseUse($this->name, $alias)
57 ), $this->type);
58 }
59 }
60