4 * This file is part of Psy Shell.
6 * (c) 2012-2017 Justin Hileman
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Psy\TabCompletion\Matcher;
14 class ObjectMethodDefaultParametersMatcher extends AbstractDefaultParametersMatcher
16 public function getMatches(array $tokens, array $info = array())
18 $openBracket = array_pop($tokens);
19 $functionName = array_pop($tokens);
20 $methodOperator = array_pop($tokens);
22 $objectToken = array_pop($tokens);
23 if (!is_array($objectToken)) {
27 $objectName = str_replace('$', '', $objectToken[1]);
30 $object = $this->getVariable($objectName);
31 $reflection = new \ReflectionObject($object);
32 } catch (InvalidArgumentException $e) {
34 } catch (\ReflectionException $e) {
38 $methods = $reflection->getMethods();
40 foreach ($methods as $method) {
41 if ($method->getName() === $functionName[1]) {
42 return $this->getDefaultParameterCompletion($method->getParameters());
49 public function hasMatched(array $tokens)
51 $openBracket = array_pop($tokens);
53 if ($openBracket !== '(') {
57 $functionName = array_pop($tokens);
59 if (!self::tokenIs($functionName, self::T_STRING)) {
63 $operator = array_pop($tokens);
65 if (!self::tokenIs($operator, self::T_OBJECT_OPERATOR)) {