Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / psy / psysh / src / Util / Docblock.php
index c7989471dbc0951bea266becc34491294a609798..750210baa1fd3dbb4702823226dae50cc4b330a9 100644 (file)
@@ -101,18 +101,18 @@ class Docblock
     protected static function prefixLength(array $lines)
     {
         // find only lines with interesting things
-        $lines = array_filter($lines, function ($line) {
-            return substr($line, strspn($line, "* \t\n\r\0\x0B"));
+        $lines = \array_filter($lines, function ($line) {
+            return \substr($line, \strspn($line, "* \t\n\r\0\x0B"));
         });
 
         // if we sort the lines, we only have to compare two items
-        sort($lines);
+        \sort($lines);
 
-        $first = reset($lines);
-        $last  = end($lines);
+        $first = \reset($lines);
+        $last  = \end($lines);
 
         // find the longest common substring
-        $count = min(strlen($first), strlen($last));
+        $count = \min(\strlen($first), \strlen($last));
         for ($i = 0; $i < $count; $i++) {
             if ($first[$i] !== $last[$i]) {
                 return $i;
@@ -130,15 +130,15 @@ class Docblock
     protected function parseComment($comment)
     {
         // Strip the opening and closing tags of the docblock
-        $comment = substr($comment, 3, -2);
+        $comment = \substr($comment, 3, -2);
 
         // Split into arrays of lines
-        $comment = array_filter(preg_split('/\r?\n\r?/', $comment));
+        $comment = \array_filter(\preg_split('/\r?\n\r?/', $comment));
 
         // Trim asterisks and whitespace from the beginning and whitespace from the end of lines
         $prefixLength = self::prefixLength($comment);
-        $comment = array_map(function ($line) use ($prefixLength) {
-            return rtrim(substr($line, $prefixLength));
+        $comment = \array_map(function ($line) use ($prefixLength) {
+            return \rtrim(\substr($line, $prefixLength));
         }, $comment);
 
         // Group the lines together by @tags
@@ -157,30 +157,30 @@ class Docblock
 
         // Parse the blocks
         foreach ($blocks as $block => $body) {
-            $body = trim(implode("\n", $body));
+            $body = \trim(\implode("\n", $body));
 
             if ($block === 0 && !self::isTagged($body)) {
                 // This is the description block
                 $this->desc = $body;
             } else {
                 // This block is tagged
-                $tag  = substr(self::strTag($body), 1);
-                $body = ltrim(substr($body, strlen($tag) + 2));
+                $tag  = \substr(self::strTag($body), 1);
+                $body = \ltrim(\substr($body, \strlen($tag) + 2));
 
                 if (isset(self::$vectors[$tag])) {
                     // The tagged block is a vector
-                    $count = count(self::$vectors[$tag]);
+                    $count = \count(self::$vectors[$tag]);
                     if ($body) {
-                        $parts = preg_split('/\s+/', $body, $count);
+                        $parts = \preg_split('/\s+/', $body, $count);
                     } else {
                         $parts = [];
                     }
 
                     // Default the trailing values
-                    $parts = array_pad($parts, $count, null);
+                    $parts = \array_pad($parts, $count, null);
 
                     // Store as a mapped array
-                    $this->tags[$tag][] = array_combine(self::$vectors[$tag], $parts);
+                    $this->tags[$tag][] = \array_combine(self::$vectors[$tag], $parts);
                 } else {
                     // The tagged block is only text
                     $this->tags[$tag][] = $body;
@@ -198,7 +198,7 @@ class Docblock
      */
     public function hasTag($tag)
     {
-        return is_array($this->tags) && array_key_exists($tag, $this->tags);
+        return \is_array($this->tags) && \array_key_exists($tag, $this->tags);
     }
 
     /**
@@ -222,7 +222,7 @@ class Docblock
      */
     public static function isTagged($str)
     {
-        return isset($str[1]) && $str[0] === '@' && ctype_alpha($str[1]);
+        return isset($str[1]) && $str[0] === '@' && !\preg_match('/[^A-Za-z]/', $str[1]);
     }
 
     /**
@@ -234,7 +234,7 @@ class Docblock
      */
     public static function strTag($str)
     {
-        if (preg_match('/^@[a-z0-9_]+/', $str, $matches)) {
+        if (\preg_match('/^@[a-z0-9_]+/', $str, $matches)) {
             return $matches[0];
         }
     }