comparison vendor/psy/psysh/src/TabCompletion/Matcher/ClassMethodsMatcher.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents c2387f117808
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
26 */ 26 */
27 public function getMatches(array $tokens, array $info = []) 27 public function getMatches(array $tokens, array $info = [])
28 { 28 {
29 $input = $this->getInput($tokens); 29 $input = $this->getInput($tokens);
30 30
31 $firstToken = array_pop($tokens); 31 $firstToken = \array_pop($tokens);
32 if (self::tokenIs($firstToken, self::T_STRING)) { 32 if (self::tokenIs($firstToken, self::T_STRING)) {
33 // second token is the nekudotayim operator 33 // second token is the nekudotayim operator
34 array_pop($tokens); 34 \array_pop($tokens);
35 } 35 }
36 36
37 $class = $this->getNamespaceAndClass($tokens); 37 $class = $this->getNamespaceAndClass($tokens);
38 38
39 try { 39 try {
46 $methods = $reflection->getMethods(); 46 $methods = $reflection->getMethods();
47 } else { 47 } else {
48 $methods = $reflection->getMethods(\ReflectionMethod::IS_STATIC); 48 $methods = $reflection->getMethods(\ReflectionMethod::IS_STATIC);
49 } 49 }
50 50
51 $methods = array_map(function (\ReflectionMethod $method) { 51 $methods = \array_map(function (\ReflectionMethod $method) {
52 return $method->getName(); 52 return $method->getName();
53 }, $methods); 53 }, $methods);
54 54
55 return array_map( 55 return \array_map(
56 function ($name) use ($class) { 56 function ($name) use ($class) {
57 $chunks = explode('\\', $class); 57 $chunks = \explode('\\', $class);
58 $className = array_pop($chunks); 58 $className = \array_pop($chunks);
59 59
60 return $className . '::' . $name; 60 return $className . '::' . $name;
61 }, 61 },
62 array_filter($methods, function ($method) use ($input) { 62 \array_filter($methods, function ($method) use ($input) {
63 return AbstractMatcher::startsWith($input, $method); 63 return AbstractMatcher::startsWith($input, $method);
64 }) 64 })
65 ); 65 );
66 } 66 }
67 67
68 /** 68 /**
69 * {@inheritdoc} 69 * {@inheritdoc}
70 */ 70 */
71 public function hasMatched(array $tokens) 71 public function hasMatched(array $tokens)
72 { 72 {
73 $token = array_pop($tokens); 73 $token = \array_pop($tokens);
74 $prevToken = array_pop($tokens); 74 $prevToken = \array_pop($tokens);
75 75
76 switch (true) { 76 switch (true) {
77 case self::tokenIs($prevToken, self::T_DOUBLE_COLON) && self::tokenIs($token, self::T_STRING): 77 case self::tokenIs($prevToken, self::T_DOUBLE_COLON) && self::tokenIs($token, self::T_STRING):
78 case self::tokenIs($token, self::T_DOUBLE_COLON): 78 case self::tokenIs($token, self::T_DOUBLE_COLON):
79 return true; 79 return true;