Mercurial > hg > isophonics-drupal-site
comparison vendor/psy/psysh/src/TabCompletion/Matcher/CommandsMatcher.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 5fb285c0d0e3 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
43 */ | 43 */ |
44 public function setCommands(array $commands) | 44 public function setCommands(array $commands) |
45 { | 45 { |
46 $names = []; | 46 $names = []; |
47 foreach ($commands as $command) { | 47 foreach ($commands as $command) { |
48 $names = array_merge([$command->getName()], $names); | 48 $names = \array_merge([$command->getName()], $names); |
49 $names = array_merge($command->getAliases(), $names); | 49 $names = \array_merge($command->getAliases(), $names); |
50 } | 50 } |
51 $this->commands = $names; | 51 $this->commands = $names; |
52 } | 52 } |
53 | 53 |
54 /** | 54 /** |
58 * | 58 * |
59 * @return bool | 59 * @return bool |
60 */ | 60 */ |
61 protected function isCommand($name) | 61 protected function isCommand($name) |
62 { | 62 { |
63 return in_array($name, $this->commands); | 63 return \in_array($name, $this->commands); |
64 } | 64 } |
65 | 65 |
66 /** | 66 /** |
67 * Check whether input matches a defined command. | 67 * Check whether input matches a defined command. |
68 * | 68 * |
86 */ | 86 */ |
87 public function getMatches(array $tokens, array $info = []) | 87 public function getMatches(array $tokens, array $info = []) |
88 { | 88 { |
89 $input = $this->getInput($tokens); | 89 $input = $this->getInput($tokens); |
90 | 90 |
91 return array_filter($this->commands, function ($command) use ($input) { | 91 return \array_filter($this->commands, function ($command) use ($input) { |
92 return AbstractMatcher::startsWith($input, $command); | 92 return AbstractMatcher::startsWith($input, $command); |
93 }); | 93 }); |
94 } | 94 } |
95 | 95 |
96 /** | 96 /** |
97 * {@inheritdoc} | 97 * {@inheritdoc} |
98 */ | 98 */ |
99 public function hasMatched(array $tokens) | 99 public function hasMatched(array $tokens) |
100 { | 100 { |
101 /* $openTag */ array_shift($tokens); | 101 /* $openTag */ \array_shift($tokens); |
102 $command = array_shift($tokens); | 102 $command = \array_shift($tokens); |
103 | 103 |
104 switch (true) { | 104 switch (true) { |
105 case self::tokenIs($command, self::T_STRING) && | 105 case self::tokenIs($command, self::T_STRING) && |
106 !$this->isCommand($command[1]) && | 106 !$this->isCommand($command[1]) && |
107 $this->matchCommand($command[1]) && | 107 $this->matchCommand($command[1]) && |