comparison vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/LNumber.php @ 13:5fb285c0d0e3

Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've been lucky to get away with this so far, as we don't support self-registration which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5 was vulnerable to.
author Chris Cannam
date Mon, 23 Apr 2018 09:33:26 +0100
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
12:7a779792577d 13:5fb285c0d0e3
1 <?php 1 <?php declare(strict_types=1);
2 2
3 namespace PhpParser\Node\Scalar; 3 namespace PhpParser\Node\Scalar;
4 4
5 use PhpParser\Error; 5 use PhpParser\Error;
6 use PhpParser\Node\Scalar; 6 use PhpParser\Node\Scalar;
20 * Constructs an integer number scalar node. 20 * Constructs an integer number scalar node.
21 * 21 *
22 * @param int $value Value of the number 22 * @param int $value Value of the number
23 * @param array $attributes Additional attributes 23 * @param array $attributes Additional attributes
24 */ 24 */
25 public function __construct($value, array $attributes = array()) { 25 public function __construct(int $value, array $attributes = []) {
26 parent::__construct($attributes); 26 parent::__construct($attributes);
27 $this->value = $value; 27 $this->value = $value;
28 } 28 }
29 29
30 public function getSubNodeNames() { 30 public function getSubNodeNames() : array {
31 return array('value'); 31 return ['value'];
32 } 32 }
33 33
34 /** 34 /**
35 * Constructs an LNumber node from a string number literal. 35 * Constructs an LNumber node from a string number literal.
36 * 36 *
38 * @param array $attributes Additional attributes 38 * @param array $attributes Additional attributes
39 * @param bool $allowInvalidOctal Whether to allow invalid octal numbers (PHP 5) 39 * @param bool $allowInvalidOctal Whether to allow invalid octal numbers (PHP 5)
40 * 40 *
41 * @return LNumber The constructed LNumber, including kind attribute 41 * @return LNumber The constructed LNumber, including kind attribute
42 */ 42 */
43 public static function fromString($str, array $attributes = array(), $allowInvalidOctal = false) { 43 public static function fromString(string $str, array $attributes = [], bool $allowInvalidOctal = false) : LNumber {
44 if ('0' !== $str[0] || '0' === $str) { 44 if ('0' !== $str[0] || '0' === $str) {
45 $attributes['kind'] = LNumber::KIND_DEC; 45 $attributes['kind'] = LNumber::KIND_DEC;
46 return new LNumber((int) $str, $attributes); 46 return new LNumber((int) $str, $attributes);
47 } 47 }
48 48
62 62
63 // use intval instead of octdec to get proper cutting behavior with malformed numbers 63 // use intval instead of octdec to get proper cutting behavior with malformed numbers
64 $attributes['kind'] = LNumber::KIND_OCT; 64 $attributes['kind'] = LNumber::KIND_OCT;
65 return new LNumber(intval($str, 8), $attributes); 65 return new LNumber(intval($str, 8), $attributes);
66 } 66 }
67
68 public function getType() : string {
69 return 'Scalar_LNumber';
70 }
67 } 71 }