diff vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.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 129ea1e6d783
line wrap: on
line diff
--- a/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php	Fri Feb 23 15:52:07 2018 +0000
+++ b/vendor/nikic/php-parser/lib/PhpParser/Node/Scalar/String_.php	Mon Apr 23 09:33:26 2018 +0100
@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
 
 namespace PhpParser\Node\Scalar;
 
@@ -16,7 +16,7 @@
     /** @var string String value */
     public $value;
 
-    protected static $replacements = array(
+    protected static $replacements = [
         '\\' => '\\',
         '$'  =>  '$',
         'n'  => "\n",
@@ -25,7 +25,7 @@
         'f'  => "\f",
         'v'  => "\v",
         'e'  => "\x1B",
-    );
+    ];
 
     /**
      * Constructs a string scalar node.
@@ -33,13 +33,13 @@
      * @param string $value      Value of the string
      * @param array  $attributes Additional attributes
      */
-    public function __construct($value, array $attributes = array()) {
+    public function __construct(string $value, array $attributes = []) {
         parent::__construct($attributes);
         $this->value = $value;
     }
 
-    public function getSubNodeNames() {
-        return array('value');
+    public function getSubNodeNames() : array {
+        return ['value'];
     }
 
     /**
@@ -52,7 +52,7 @@
      *
      * @return string The parsed string
      */
-    public static function parse($str, $parseUnicodeEscape = true) {
+    public static function parse(string $str, bool $parseUnicodeEscape = true) : string {
         $bLength = 0;
         if ('b' === $str[0] || 'B' === $str[0]) {
             $bLength = 1;
@@ -60,8 +60,8 @@
 
         if ('\'' === $str[$bLength]) {
             return str_replace(
-                array('\\\\', '\\\''),
-                array(  '\\',   '\''),
+                ['\\\\', '\\\''],
+                ['\\', '\''],
                 substr($str, $bLength + 1, -1)
             );
         } else {
@@ -82,7 +82,7 @@
      *
      * @return string String with escape sequences parsed
      */
-    public static function parseEscapeSequences($str, $quote, $parseUnicodeEscape = true) {
+    public static function parseEscapeSequences(string $str, $quote, bool $parseUnicodeEscape = true) : string {
         if (null !== $quote) {
             $str = str_replace('\\' . $quote, $quote, $str);
         }
@@ -111,7 +111,14 @@
         );
     }
 
-    private static function codePointToUtf8($num) {
+    /**
+     * Converts a Unicode code point to its UTF-8 encoded representation.
+     *
+     * @param int $num Code point
+     *
+     * @return string UTF-8 representation of code point
+     */
+    private static function codePointToUtf8(int $num) : string {
         if ($num <= 0x7F) {
             return chr($num);
         }
@@ -139,7 +146,7 @@
      *
      * @return string Parsed string
      */
-    public static function parseDocString($startToken, $str, $parseUnicodeEscape = true) {
+    public static function parseDocString(string $startToken, string $str, bool $parseUnicodeEscape = true) : string {
         // strip last newline (thanks tokenizer for sticking it into the string!)
         $str = preg_replace('~(\r\n|\n|\r)\z~', '', $str);
 
@@ -150,4 +157,8 @@
 
         return self::parseEscapeSequences($str, null, $parseUnicodeEscape);
     }
+    
+    public function getType() : string {
+        return 'Scalar_String';
+    }
 }