Mercurial > hg > isophonics-drupal-site
comparison vendor/psy/psysh/src/CodeCleaner/LegacyEmptyPass.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 private $atLeastPhp55; | 27 private $atLeastPhp55; |
28 | 28 |
29 public function __construct() | 29 public function __construct() |
30 { | 30 { |
31 $this->atLeastPhp55 = version_compare(PHP_VERSION, '5.5', '>='); | 31 $this->atLeastPhp55 = \version_compare(PHP_VERSION, '5.5', '>='); |
32 } | 32 } |
33 | 33 |
34 /** | 34 /** |
35 * Validate use of empty in PHP < 5.5. | 35 * Validate use of empty in PHP < 5.5. |
36 * | 36 * |
47 if (!$node instanceof Empty_) { | 47 if (!$node instanceof Empty_) { |
48 return; | 48 return; |
49 } | 49 } |
50 | 50 |
51 if (!$node->expr instanceof Variable) { | 51 if (!$node->expr instanceof Variable) { |
52 $msg = sprintf('syntax error, unexpected %s', $this->getUnexpectedThing($node->expr)); | 52 $msg = \sprintf('syntax error, unexpected %s', $this->getUnexpectedThing($node->expr)); |
53 | 53 |
54 throw new ParseErrorException($msg, $node->expr->getLine()); | 54 throw new ParseErrorException($msg, $node->expr->getLine()); |
55 } | 55 } |
56 } | 56 } |
57 | 57 |
59 { | 59 { |
60 switch ($node->getType()) { | 60 switch ($node->getType()) { |
61 case 'Scalar_String': | 61 case 'Scalar_String': |
62 case 'Scalar_LNumber': | 62 case 'Scalar_LNumber': |
63 case 'Scalar_DNumber': | 63 case 'Scalar_DNumber': |
64 return json_encode($node->value); | 64 return \json_encode($node->value); |
65 | 65 |
66 case 'Expr_ConstFetch': | 66 case 'Expr_ConstFetch': |
67 return (string) $node->name; | 67 return (string) $node->name; |
68 | 68 |
69 default: | 69 default: |