Mercurial > hg > isophonics-drupal-site
comparison vendor/psy/psysh/src/Context.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 |
---|---|
73 case '__class': | 73 case '__class': |
74 case '__namespace': | 74 case '__namespace': |
75 case '__file': | 75 case '__file': |
76 case '__line': | 76 case '__line': |
77 case '__dir': | 77 case '__dir': |
78 if (array_key_exists($name, $this->commandScopeVariables)) { | 78 if (\array_key_exists($name, $this->commandScopeVariables)) { |
79 return $this->commandScopeVariables[$name]; | 79 return $this->commandScopeVariables[$name]; |
80 } | 80 } |
81 break; | 81 break; |
82 | 82 |
83 default: | 83 default: |
84 if (array_key_exists($name, $this->scopeVariables)) { | 84 if (\array_key_exists($name, $this->scopeVariables)) { |
85 return $this->scopeVariables[$name]; | 85 return $this->scopeVariables[$name]; |
86 } | 86 } |
87 break; | 87 break; |
88 } | 88 } |
89 | 89 |
95 * | 95 * |
96 * @return array | 96 * @return array |
97 */ | 97 */ |
98 public function getAll() | 98 public function getAll() |
99 { | 99 { |
100 return array_merge($this->scopeVariables, $this->getSpecialVariables()); | 100 return \array_merge($this->scopeVariables, $this->getSpecialVariables()); |
101 } | 101 } |
102 | 102 |
103 /** | 103 /** |
104 * Get all defined magic variables: $_, $_e, $__out, $__class, $__file, etc. | 104 * Get all defined magic variables: $_, $_e, $__out, $__class, $__file, etc. |
105 * | 105 * |
121 | 121 |
122 if (isset($this->boundObject)) { | 122 if (isset($this->boundObject)) { |
123 $vars['this'] = $this->boundObject; | 123 $vars['this'] = $this->boundObject; |
124 } | 124 } |
125 | 125 |
126 return array_merge($vars, $this->commandScopeVariables); | 126 return \array_merge($vars, $this->commandScopeVariables); |
127 } | 127 } |
128 | 128 |
129 /** | 129 /** |
130 * Set all scope variables. | 130 * Set all scope variables. |
131 * | 131 * |
226 * | 226 * |
227 * @param object|null $boundObject | 227 * @param object|null $boundObject |
228 */ | 228 */ |
229 public function setBoundObject($boundObject) | 229 public function setBoundObject($boundObject) |
230 { | 230 { |
231 $this->boundObject = is_object($boundObject) ? $boundObject : null; | 231 $this->boundObject = \is_object($boundObject) ? $boundObject : null; |
232 $this->boundClass = null; | 232 $this->boundClass = null; |
233 } | 233 } |
234 | 234 |
235 /** | 235 /** |
236 * Get the bound object ($this variable) for the interactive shell. | 236 * Get the bound object ($this variable) for the interactive shell. |
249 * | 249 * |
250 * @param string|null $boundClass | 250 * @param string|null $boundClass |
251 */ | 251 */ |
252 public function setBoundClass($boundClass) | 252 public function setBoundClass($boundClass) |
253 { | 253 { |
254 $this->boundClass = (is_string($boundClass) && $boundClass !== '') ? $boundClass : null; | 254 $this->boundClass = (\is_string($boundClass) && $boundClass !== '') ? $boundClass : null; |
255 $this->boundObject = null; | 255 $this->boundObject = null; |
256 } | 256 } |
257 | 257 |
258 /** | 258 /** |
259 * Get the bound class (self) for the interactive shell. | 259 * Get the bound class (self) for the interactive shell. |
273 public function setCommandScopeVariables(array $commandScopeVariables) | 273 public function setCommandScopeVariables(array $commandScopeVariables) |
274 { | 274 { |
275 $vars = []; | 275 $vars = []; |
276 foreach ($commandScopeVariables as $key => $value) { | 276 foreach ($commandScopeVariables as $key => $value) { |
277 // kind of type check | 277 // kind of type check |
278 if (is_scalar($value) && in_array($key, self::$commandScopeNames)) { | 278 if (\is_scalar($value) && \in_array($key, self::$commandScopeNames)) { |
279 $vars[$key] = $value; | 279 $vars[$key] = $value; |
280 } | 280 } |
281 } | 281 } |
282 | 282 |
283 $this->commandScopeVariables = $vars; | 283 $this->commandScopeVariables = $vars; |
301 * | 301 * |
302 * @return array Array of unused variable names | 302 * @return array Array of unused variable names |
303 */ | 303 */ |
304 public function getUnusedCommandScopeVariableNames() | 304 public function getUnusedCommandScopeVariableNames() |
305 { | 305 { |
306 return array_diff(self::$commandScopeNames, array_keys($this->commandScopeVariables)); | 306 return \array_diff(self::$commandScopeNames, \array_keys($this->commandScopeVariables)); |
307 } | 307 } |
308 | 308 |
309 /** | 309 /** |
310 * Check whether a variable name is a magic variable. | 310 * Check whether a variable name is a magic variable. |
311 * | 311 * |
313 * | 313 * |
314 * @return bool | 314 * @return bool |
315 */ | 315 */ |
316 public static function isSpecialVariableName($name) | 316 public static function isSpecialVariableName($name) |
317 { | 317 { |
318 return in_array($name, self::$specialNames) || in_array($name, self::$commandScopeNames); | 318 return \in_array($name, self::$specialNames) || \in_array($name, self::$commandScopeNames); |
319 } | 319 } |
320 } | 320 } |