Mercurial > hg > isophonics-drupal-site
comparison vendor/psy/psysh/src/TabCompletion/Matcher/AbstractDefaultParametersMatcher.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 |
---|---|
34 | 34 |
35 if (empty($parametersProcessed)) { | 35 if (empty($parametersProcessed)) { |
36 return []; | 36 return []; |
37 } | 37 } |
38 | 38 |
39 return [implode(', ', $parametersProcessed) . ')']; | 39 return [\implode(', ', $parametersProcessed) . ')']; |
40 } | 40 } |
41 | 41 |
42 /** | 42 /** |
43 * Takes in the default value of a parameter and turns it into a | 43 * Takes in the default value of a parameter and turns it into a |
44 * string representation that fits inline. | 44 * string representation that fits inline. |
48 * | 48 * |
49 * @return string | 49 * @return string |
50 */ | 50 */ |
51 private function valueToShortString($value) | 51 private function valueToShortString($value) |
52 { | 52 { |
53 if (!is_array($value)) { | 53 if (!\is_array($value)) { |
54 return json_encode($value); | 54 return \json_encode($value); |
55 } | 55 } |
56 | 56 |
57 $chunks = []; | 57 $chunks = []; |
58 $chunksSequential = []; | 58 $chunksSequential = []; |
59 | 59 |
60 $allSequential = true; | 60 $allSequential = true; |
61 | 61 |
62 foreach ($value as $key => $item) { | 62 foreach ($value as $key => $item) { |
63 $allSequential = $allSequential && is_numeric($key) && $key === count($chunksSequential); | 63 $allSequential = $allSequential && \is_numeric($key) && $key === \count($chunksSequential); |
64 | 64 |
65 $keyString = $this->valueToShortString($key); | 65 $keyString = $this->valueToShortString($key); |
66 $itemString = $this->valueToShortString($item); | 66 $itemString = $this->valueToShortString($item); |
67 | 67 |
68 $chunks[] = "{$keyString} => {$itemString}"; | 68 $chunks[] = "{$keyString} => {$itemString}"; |
69 $chunksSequential[] = $itemString; | 69 $chunksSequential[] = $itemString; |
70 } | 70 } |
71 | 71 |
72 $chunksToImplode = $allSequential ? $chunksSequential : $chunks; | 72 $chunksToImplode = $allSequential ? $chunksSequential : $chunks; |
73 | 73 |
74 return '[' . implode(', ', $chunksToImplode) . ']'; | 74 return '[' . \implode(', ', $chunksToImplode) . ']'; |
75 } | 75 } |
76 } | 76 } |