Mercurial > hg > isophonics-drupal-site
diff vendor/nikic/php-parser/lib/PhpParser/Comment.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 |
line wrap: on
line diff
--- a/vendor/nikic/php-parser/lib/PhpParser/Comment.php Fri Feb 23 15:52:07 2018 +0000 +++ b/vendor/nikic/php-parser/lib/PhpParser/Comment.php Mon Apr 23 09:33:26 2018 +0100 @@ -1,4 +1,4 @@ -<?php +<?php declare(strict_types=1); namespace PhpParser; @@ -7,18 +7,23 @@ protected $text; protected $line; protected $filePos; + protected $tokenPos; /** * Constructs a comment node. * - * @param string $text Comment text (including comment delimiters like /*) - * @param int $startLine Line number the comment started on - * @param int $startFilePos File offset the comment started on + * @param string $text Comment text (including comment delimiters like /*) + * @param int $startLine Line number the comment started on + * @param int $startFilePos File offset the comment started on + * @param int $startTokenPos Token offset the comment started on */ - public function __construct($text, $startLine = -1, $startFilePos = -1) { + public function __construct( + string $text, int $startLine = -1, int $startFilePos = -1, int $startTokenPos = -1 + ) { $this->text = $text; $this->line = $startLine; $this->filePos = $startFilePos; + $this->tokenPos = $startTokenPos; } /** @@ -26,7 +31,7 @@ * * @return string The comment text (including comment delimiters like /*) */ - public function getText() { + public function getText() : string { return $this->text; } @@ -35,7 +40,7 @@ * * @return int Line number */ - public function getLine() { + public function getLine() : int { return $this->line; } @@ -44,16 +49,25 @@ * * @return int File offset */ - public function getFilePos() { + public function getFilePos() : int { return $this->filePos; } /** + * Gets the token offset the comment started on. + * + * @return int Token offset + */ + public function getTokenPos() : int { + return $this->tokenPos; + } + + /** * Gets the comment text. * * @return string The comment text (including comment delimiters like /*) */ - public function __toString() { + public function __toString() : string { return $this->text; } @@ -114,9 +128,17 @@ return $text; } - private function getShortestWhitespacePrefixLen($str) { + /** + * Get length of shortest whitespace prefix (at the start of a line). + * + * If there is a line with no prefix whitespace, 0 is a valid return value. + * + * @param string $str String to check + * @return int Length in characters. Tabs count as single characters. + */ + private function getShortestWhitespacePrefixLen(string $str) : int { $lines = explode("\n", $str); - $shortestPrefixLen = INF; + $shortestPrefixLen = \INF; foreach ($lines as $line) { preg_match('(^\s*)', $line, $matches); $prefixLen = strlen($matches[0]); @@ -127,7 +149,11 @@ return $shortestPrefixLen; } - public function jsonSerialize() { + /** + * @return array + * @psalm-return array{nodeType:string, text:mixed, line:mixed, filePos:mixed} + */ + public function jsonSerialize() : array { // Technically not a node, but we make it look like one anyway $type = $this instanceof Comment\Doc ? 'Comment_Doc' : 'Comment'; return [ @@ -135,6 +161,7 @@ 'text' => $this->text, 'line' => $this->line, 'filePos' => $this->filePos, + 'tokenPos' => $this->tokenPos, ]; } -} \ No newline at end of file +}