X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fnikic%2Fphp-parser%2Flib%2FPhpParser%2FComment.php;fp=vendor%2Fnikic%2Fphp-parser%2Flib%2FPhpParser%2FComment.php;h=5da8420958806baf58fc65f465e162ee93b7d269;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=4034cfa6b198299bd738b25fa600cfc7e94eb899;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website diff --git a/vendor/nikic/php-parser/lib/PhpParser/Comment.php b/vendor/nikic/php-parser/lib/PhpParser/Comment.php index 4034cfa6b..5da842095 100644 --- a/vendor/nikic/php-parser/lib/PhpParser/Comment.php +++ b/vendor/nikic/php-parser/lib/PhpParser/Comment.php @@ -1,4 +1,4 @@ -text = $text; $this->line = $startLine; $this->filePos = $startFilePos; + $this->tokenPos = $startTokenPos; } /** @@ -26,7 +31,7 @@ class Comment implements \JsonSerializable * * @return string The comment text (including comment delimiters like /*) */ - public function getText() { + public function getText() : string { return $this->text; } @@ -35,7 +40,7 @@ class Comment implements \JsonSerializable * * @return int Line number */ - public function getLine() { + public function getLine() : int { return $this->line; } @@ -44,16 +49,25 @@ class Comment implements \JsonSerializable * * @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 @@ class Comment implements \JsonSerializable 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 @@ class Comment implements \JsonSerializable 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 @@ class Comment implements \JsonSerializable 'text' => $this->text, 'line' => $this->line, 'filePos' => $this->filePos, + 'tokenPos' => $this->tokenPos, ]; } -} \ No newline at end of file +}