Dependency updates and update version number

This commit is contained in:
Kode
2018-06-13 19:35:28 +01:00
parent 18ec208381
commit e3ec7de23a
1261 changed files with 45582 additions and 29687 deletions

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace PhpParser;
@@ -7,18 +7,23 @@ class Comment implements \JsonSerializable
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 @@ 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,
];
}
}
}