Mercurial > hg > isophonics-drupal-site
comparison vendor/psy/psysh/src/TabCompletion/Matcher/ClassAttributesMatcher.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 { |
40 $reflection = new \ReflectionClass($class); | 40 $reflection = new \ReflectionClass($class); |
41 } catch (\ReflectionException $re) { | 41 } catch (\ReflectionException $re) { |
42 return []; | 42 return []; |
43 } | 43 } |
44 | 44 |
45 $vars = array_merge( | 45 $vars = \array_merge( |
46 array_map( | 46 \array_map( |
47 function ($var) { | 47 function ($var) { |
48 return '$' . $var; | 48 return '$' . $var; |
49 }, | 49 }, |
50 array_keys($reflection->getStaticProperties()) | 50 \array_keys($reflection->getStaticProperties()) |
51 ), | 51 ), |
52 array_keys($reflection->getConstants()) | 52 \array_keys($reflection->getConstants()) |
53 ); | 53 ); |
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( | 62 \array_filter( |
63 $vars, | 63 $vars, |
64 function ($var) use ($input) { | 64 function ($var) use ($input) { |
65 return AbstractMatcher::startsWith($input, $var); | 65 return AbstractMatcher::startsWith($input, $var); |
66 } | 66 } |
67 ) | 67 ) |
71 /** | 71 /** |
72 * {@inheritdoc} | 72 * {@inheritdoc} |
73 */ | 73 */ |
74 public function hasMatched(array $tokens) | 74 public function hasMatched(array $tokens) |
75 { | 75 { |
76 $token = array_pop($tokens); | 76 $token = \array_pop($tokens); |
77 $prevToken = array_pop($tokens); | 77 $prevToken = \array_pop($tokens); |
78 | 78 |
79 switch (true) { | 79 switch (true) { |
80 case self::tokenIs($prevToken, self::T_DOUBLE_COLON) && self::tokenIs($token, self::T_STRING): | 80 case self::tokenIs($prevToken, self::T_DOUBLE_COLON) && self::tokenIs($token, self::T_STRING): |
81 case self::tokenIs($token, self::T_DOUBLE_COLON): | 81 case self::tokenIs($token, self::T_DOUBLE_COLON): |
82 return true; | 82 return true; |