Mercurial > hg > isophonics-drupal-site
comparison vendor/psy/psysh/src/Reflection/ReflectionClassConstant.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 |
---|---|
36 | 36 |
37 $this->class = $class; | 37 $this->class = $class; |
38 $this->name = $name; | 38 $this->name = $name; |
39 | 39 |
40 $constants = $class->getConstants(); | 40 $constants = $class->getConstants(); |
41 if (!array_key_exists($name, $constants)) { | 41 if (!\array_key_exists($name, $constants)) { |
42 throw new \InvalidArgumentException('Unknown constant: ' . $name); | 42 throw new \InvalidArgumentException('Unknown constant: ' . $name); |
43 } | 43 } |
44 | 44 |
45 $this->value = $constants[$name]; | 45 $this->value = $constants[$name]; |
46 } | 46 } |
57 public static function export($class, $name, $return = false) | 57 public static function export($class, $name, $return = false) |
58 { | 58 { |
59 $refl = new self($class, $name); | 59 $refl = new self($class, $name); |
60 $value = $refl->getValue(); | 60 $value = $refl->getValue(); |
61 | 61 |
62 $str = sprintf('Constant [ public %s %s ] { %s }', gettype($value), $refl->getName(), $value); | 62 $str = \sprintf('Constant [ public %s %s ] { %s }', \gettype($value), $refl->getName(), $value); |
63 | 63 |
64 if ($return) { | 64 if ($return) { |
65 return $str; | 65 return $str; |
66 } | 66 } |
67 | 67 |
217 * | 217 * |
218 * @return ReflectionClassConstant|\ReflectionClassConstant | 218 * @return ReflectionClassConstant|\ReflectionClassConstant |
219 */ | 219 */ |
220 public static function create($class, $name) | 220 public static function create($class, $name) |
221 { | 221 { |
222 if (class_exists('\\ReflectionClassConstant')) { | 222 if (\class_exists('\\ReflectionClassConstant')) { |
223 return new \ReflectionClassConstant($class, $name); | 223 return new \ReflectionClassConstant($class, $name); |
224 } | 224 } |
225 | 225 |
226 return new self($class, $name); | 226 return new self($class, $name); |
227 } | 227 } |