mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
replace deprecated methods with their equivalent (#4217)
This commit is contained in:
parent
ba202b7ad3
commit
b559951bf4
@ -51,8 +51,6 @@
|
|||||||
<DeprecatedMethod>
|
<DeprecatedMethod>
|
||||||
<errorLevel type="suppress">
|
<errorLevel type="suppress">
|
||||||
<directory name="tests" />
|
<directory name="tests" />
|
||||||
<referencedMethod name="PhpParser\Comment::getFilePos" />
|
|
||||||
<referencedMethod name="PhpParser\Comment::getLine" />
|
|
||||||
</errorLevel>
|
</errorLevel>
|
||||||
</DeprecatedMethod>
|
</DeprecatedMethod>
|
||||||
<DeprecatedClass>
|
<DeprecatedClass>
|
||||||
|
@ -122,9 +122,9 @@ class CodeLocation
|
|||||||
|
|
||||||
$doc_comment = $stmt->getDocComment();
|
$doc_comment = $stmt->getDocComment();
|
||||||
|
|
||||||
$this->docblock_start = $doc_comment ? $doc_comment->getFilePos() : null;
|
$this->docblock_start = $doc_comment ? $doc_comment->getStartFilePos() : null;
|
||||||
$this->docblock_end = $doc_comment ? $this->file_start : null;
|
$this->docblock_end = $doc_comment ? $this->file_start : null;
|
||||||
$this->docblock_start_line_number = $doc_comment ? $doc_comment->getLine() : null;
|
$this->docblock_start_line_number = $doc_comment ? $doc_comment->getStartLine() : null;
|
||||||
|
|
||||||
$this->preview_start = $this->docblock_start ?: $this->file_start;
|
$this->preview_start = $this->docblock_start ?: $this->file_start;
|
||||||
|
|
||||||
|
@ -1281,8 +1281,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer
|
|||||||
function (FunctionLikeParameter $param) : PhpParser\Node\Param {
|
function (FunctionLikeParameter $param) : PhpParser\Node\Param {
|
||||||
$fake_param = (new PhpParser\Builder\Param($param->name));
|
$fake_param = (new PhpParser\Builder\Param($param->name));
|
||||||
if ($param->signature_type) {
|
if ($param->signature_type) {
|
||||||
/** @psalm-suppress DeprecatedMethod */
|
$fake_param->setType((string)$param->signature_type);
|
||||||
$fake_param->setTypeHint((string)$param->signature_type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $fake_param->getNode();
|
return $fake_param->getNode();
|
||||||
@ -1853,7 +1852,7 @@ class ClassAnalyzer extends ClassLikeAnalyzer
|
|||||||
$comments = $stmt->getComments();
|
$comments = $stmt->getComments();
|
||||||
|
|
||||||
if ($comments) {
|
if ($comments) {
|
||||||
$start = $comments[0]->getFilePos();
|
$start = $comments[0]->getStartFilePos();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($codebase->diff_methods
|
if ($codebase->diff_methods
|
||||||
|
@ -100,7 +100,7 @@ class CommentAnalyzer
|
|||||||
|
|
||||||
$comment_text = $comment->getText();
|
$comment_text = $comment->getText();
|
||||||
|
|
||||||
$var_line_number = $comment->getLine();
|
$var_line_number = $comment->getStartLine();
|
||||||
|
|
||||||
if (isset($parsed_docblock->combined_tags['var'])) {
|
if (isset($parsed_docblock->combined_tags['var'])) {
|
||||||
foreach ($parsed_docblock->combined_tags['var'] as $offset => $var_line) {
|
foreach ($parsed_docblock->combined_tags['var'] as $offset => $var_line) {
|
||||||
@ -115,10 +115,10 @@ class CommentAnalyzer
|
|||||||
|
|
||||||
$line_parts = self::splitDocLine($var_line);
|
$line_parts = self::splitDocLine($var_line);
|
||||||
|
|
||||||
$line_number = $comment->getLine() + substr_count($comment_text, "\n", 0, $offset);
|
$line_number = $comment->getStartLine() + substr_count($comment_text, "\n", 0, $offset);
|
||||||
|
|
||||||
if ($line_parts && $line_parts[0]) {
|
if ($line_parts && $line_parts[0]) {
|
||||||
$type_start = $offset + $comment->getFilePos();
|
$type_start = $offset + $comment->getStartFilePos();
|
||||||
$type_end = $type_start + strlen($line_parts[0]);
|
$type_end = $type_start + strlen($line_parts[0]);
|
||||||
|
|
||||||
$line_parts[0] = self::sanitizeDocblockType($line_parts[0]);
|
$line_parts[0] = self::sanitizeDocblockType($line_parts[0]);
|
||||||
@ -168,7 +168,7 @@ class CommentAnalyzer
|
|||||||
' (from ' .
|
' (from ' .
|
||||||
$source->getFilePath() .
|
$source->getFilePath() .
|
||||||
':' .
|
':' .
|
||||||
$comment->getLine() .
|
$comment->getStartLine() .
|
||||||
')'
|
')'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -393,7 +393,7 @@ class CommentAnalyzer
|
|||||||
|
|
||||||
$line_parts[1] = preg_replace('/,$/', '', $line_parts[1]);
|
$line_parts[1] = preg_replace('/,$/', '', $line_parts[1]);
|
||||||
|
|
||||||
$start = $offset + $comment->getFilePos();
|
$start = $offset + $comment->getStartFilePos();
|
||||||
$end = $start + strlen($line_parts[0]);
|
$end = $start + strlen($line_parts[0]);
|
||||||
|
|
||||||
$line_parts[0] = self::sanitizeDocblockType($line_parts[0]);
|
$line_parts[0] = self::sanitizeDocblockType($line_parts[0]);
|
||||||
@ -408,7 +408,7 @@ class CommentAnalyzer
|
|||||||
$info->params[] = [
|
$info->params[] = [
|
||||||
'name' => trim($line_parts[1]),
|
'name' => trim($line_parts[1]),
|
||||||
'type' => $line_parts[0],
|
'type' => $line_parts[0],
|
||||||
'line_number' => $comment->getLine() + substr_count($comment_text, "\n", 0, $offset),
|
'line_number' => $comment->getStartLine() + substr_count($comment_text, "\n", 0, $offset),
|
||||||
'start' => $start,
|
'start' => $start,
|
||||||
'end' => $end,
|
'end' => $end,
|
||||||
];
|
];
|
||||||
@ -450,7 +450,7 @@ class CommentAnalyzer
|
|||||||
$info->params_out[] = [
|
$info->params_out[] = [
|
||||||
'name' => trim($line_parts[1]),
|
'name' => trim($line_parts[1]),
|
||||||
'type' => str_replace("\n", '', $line_parts[0]),
|
'type' => str_replace("\n", '', $line_parts[0]),
|
||||||
'line_number' => $comment->getLine() + substr_count($comment_text, "\n", 0, $offset),
|
'line_number' => $comment->getStartLine() + substr_count($comment_text, "\n", 0, $offset),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -468,7 +468,7 @@ class CommentAnalyzer
|
|||||||
|
|
||||||
$info->self_out = [
|
$info->self_out = [
|
||||||
'type' => str_replace("\n", '', $line_parts[0]),
|
'type' => str_replace("\n", '', $line_parts[0]),
|
||||||
'line_number' => $comment->getLine() + substr_count($comment_text, "\n", 0, $offset),
|
'line_number' => $comment->getStartLine() + substr_count($comment_text, "\n", 0, $offset),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -611,7 +611,7 @@ class CommentAnalyzer
|
|||||||
$info->globals[] = [
|
$info->globals[] = [
|
||||||
'name' => $line_parts[1],
|
'name' => $line_parts[1],
|
||||||
'type' => $line_parts[0],
|
'type' => $line_parts[0],
|
||||||
'line_number' => $comment->getLine() + substr_count($comment_text, "\n", 0, $offset),
|
'line_number' => $comment->getStartLine() + substr_count($comment_text, "\n", 0, $offset),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -642,7 +642,7 @@ class CommentAnalyzer
|
|||||||
if (isset($parsed_docblock->tags['psalm-suppress'])) {
|
if (isset($parsed_docblock->tags['psalm-suppress'])) {
|
||||||
foreach ($parsed_docblock->tags['psalm-suppress'] as $offset => $suppress_entry) {
|
foreach ($parsed_docblock->tags['psalm-suppress'] as $offset => $suppress_entry) {
|
||||||
foreach (DocComment::parseSuppressList($suppress_entry) as $issue_offset => $suppressed_issue) {
|
foreach (DocComment::parseSuppressList($suppress_entry) as $issue_offset => $suppressed_issue) {
|
||||||
$info->suppressed_issues[$issue_offset + $offset + $comment->getFilePos()] = $suppressed_issue;
|
$info->suppressed_issues[$issue_offset + $offset + $comment->getStartFilePos()] = $suppressed_issue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -657,8 +657,8 @@ class CommentAnalyzer
|
|||||||
|
|
||||||
$info->throws[] = [
|
$info->throws[] = [
|
||||||
$throws_class,
|
$throws_class,
|
||||||
$offset + $comment->getFilePos(),
|
$offset + $comment->getStartFilePos(),
|
||||||
$comment->getLine() + substr_count($comment->getText(), "\n", 0, $offset)
|
$comment->getStartLine() + substr_count($comment->getText(), "\n", 0, $offset)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -795,7 +795,7 @@ class CommentAnalyzer
|
|||||||
throw new IncorrectDocblockException('Misplaced variable');
|
throw new IncorrectDocblockException('Misplaced variable');
|
||||||
}
|
}
|
||||||
|
|
||||||
$start = $offset + $comment->getFilePos();
|
$start = $offset + $comment->getStartFilePos();
|
||||||
$end = $start + strlen($line_parts[0]);
|
$end = $start + strlen($line_parts[0]);
|
||||||
|
|
||||||
$line_parts[0] = self::sanitizeDocblockType($line_parts[0]);
|
$line_parts[0] = self::sanitizeDocblockType($line_parts[0]);
|
||||||
@ -804,7 +804,7 @@ class CommentAnalyzer
|
|||||||
$info->return_type_description = $line_parts ? implode(' ', $line_parts) : null;
|
$info->return_type_description = $line_parts ? implode(' ', $line_parts) : null;
|
||||||
|
|
||||||
$info->return_type_line_number
|
$info->return_type_line_number
|
||||||
= $comment->getLine() + substr_count($comment->getText(), "\n", 0, $offset);
|
= $comment->getStartLine() + substr_count($comment->getText(), "\n", 0, $offset);
|
||||||
$info->return_type_start = $start;
|
$info->return_type_start = $start;
|
||||||
$info->return_type_end = $end;
|
$info->return_type_end = $end;
|
||||||
} else {
|
} else {
|
||||||
@ -985,7 +985,7 @@ class CommentAnalyzer
|
|||||||
if (isset($parsed_docblock->tags['psalm-suppress'])) {
|
if (isset($parsed_docblock->tags['psalm-suppress'])) {
|
||||||
foreach ($parsed_docblock->tags['psalm-suppress'] as $offset => $suppress_entry) {
|
foreach ($parsed_docblock->tags['psalm-suppress'] as $offset => $suppress_entry) {
|
||||||
foreach (DocComment::parseSuppressList($suppress_entry) as $issue_offset => $suppressed_issue) {
|
foreach (DocComment::parseSuppressList($suppress_entry) as $issue_offset => $suppressed_issue) {
|
||||||
$info->suppressed_issues[$issue_offset + $offset + $comment->getFilePos()] = $suppressed_issue;
|
$info->suppressed_issues[$issue_offset + $offset + $comment->getStartFilePos()] = $suppressed_issue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -993,9 +993,9 @@ class CommentAnalyzer
|
|||||||
if (isset($parsed_docblock->tags['psalm-import-type'])) {
|
if (isset($parsed_docblock->tags['psalm-import-type'])) {
|
||||||
foreach ($parsed_docblock->tags['psalm-import-type'] as $offset => $imported_type_entry) {
|
foreach ($parsed_docblock->tags['psalm-import-type'] as $offset => $imported_type_entry) {
|
||||||
$info->imported_types[] = [
|
$info->imported_types[] = [
|
||||||
'line_number' => $comment->getLine() + substr_count($comment->getText(), "\n", 0, $offset),
|
'line_number' => $comment->getStartLine() + substr_count($comment->getText(), "\n", 0, $offset),
|
||||||
'start_offset' => $comment->getFilePos() + $offset,
|
'start_offset' => $comment->getStartFilePos() + $offset,
|
||||||
'end_offset' => $comment->getFilePos() + $offset + strlen($imported_type_entry),
|
'end_offset' => $comment->getStartFilePos() + $offset + strlen($imported_type_entry),
|
||||||
'parts' => self::splitDocLine($imported_type_entry) ?: []
|
'parts' => self::splitDocLine($imported_type_entry) ?: []
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -1144,16 +1144,16 @@ class CommentAnalyzer
|
|||||||
/** @var \PhpParser\Comment\Doc */
|
/** @var \PhpParser\Comment\Doc */
|
||||||
$node_doc_comment = $node->getDocComment();
|
$node_doc_comment = $node->getDocComment();
|
||||||
|
|
||||||
$statements[0]->stmts[0]->setAttribute('startLine', $node_doc_comment->getLine());
|
$statements[0]->stmts[0]->setAttribute('startLine', $node_doc_comment->getStartLine());
|
||||||
$statements[0]->stmts[0]->setAttribute('startFilePos', $node_doc_comment->getFilePos());
|
$statements[0]->stmts[0]->setAttribute('startFilePos', $node_doc_comment->getStartFilePos());
|
||||||
$statements[0]->stmts[0]->setAttribute('endFilePos', $node->getAttribute('startFilePos'));
|
$statements[0]->stmts[0]->setAttribute('endFilePos', $node->getAttribute('startFilePos'));
|
||||||
|
|
||||||
if ($doc_comment = $statements[0]->stmts[0]->getDocComment()) {
|
if ($doc_comment = $statements[0]->stmts[0]->getDocComment()) {
|
||||||
$statements[0]->stmts[0]->setDocComment(
|
$statements[0]->stmts[0]->setDocComment(
|
||||||
new \PhpParser\Comment\Doc(
|
new \PhpParser\Comment\Doc(
|
||||||
$doc_comment->getText(),
|
$doc_comment->getText(),
|
||||||
$comment->getLine() + substr_count($comment->getText(), "\n", 0, $offset),
|
$comment->getStartLine() + substr_count($comment->getText(), "\n", 0, $offset),
|
||||||
$node_doc_comment->getFilePos()
|
$node_doc_comment->getStartFilePos()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1207,7 +1207,7 @@ class CommentAnalyzer
|
|||||||
|
|
||||||
$line_parts[1] = preg_replace('/,$/', '', $line_parts[1]);
|
$line_parts[1] = preg_replace('/,$/', '', $line_parts[1]);
|
||||||
|
|
||||||
$start = $offset + $comment->getFilePos();
|
$start = $offset + $comment->getStartFilePos();
|
||||||
$end = $start + strlen($line_parts[0]);
|
$end = $start + strlen($line_parts[0]);
|
||||||
|
|
||||||
$line_parts[0] = str_replace("\n", '', preg_replace('@^[ \t]*\*@m', '', $line_parts[0]));
|
$line_parts[0] = str_replace("\n", '', preg_replace('@^[ \t]*\*@m', '', $line_parts[0]));
|
||||||
@ -1228,7 +1228,7 @@ class CommentAnalyzer
|
|||||||
$info->properties[] = [
|
$info->properties[] = [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'type' => $line_parts[0],
|
'type' => $line_parts[0],
|
||||||
'line_number' => $comment->getLine() + substr_count($comment->getText(), "\n", 0, $offset),
|
'line_number' => $comment->getStartLine() + substr_count($comment->getText(), "\n", 0, $offset),
|
||||||
'tag' => $property_tag,
|
'tag' => $property_tag,
|
||||||
'start' => $start,
|
'start' => $start,
|
||||||
'end' => $end,
|
'end' => $end,
|
||||||
|
@ -349,7 +349,7 @@ class StatementsAnalyzer extends SourceAnalyzer implements StatementsSource
|
|||||||
|
|
||||||
foreach ($suppressed as $offset => $suppress_entry) {
|
foreach ($suppressed as $offset => $suppress_entry) {
|
||||||
foreach (DocComment::parseSuppressList($suppress_entry) as $issue_offset => $issue_type) {
|
foreach (DocComment::parseSuppressList($suppress_entry) as $issue_offset => $issue_type) {
|
||||||
$new_issues[$issue_offset + $offset + $docblock->getFilePos()] = $issue_type;
|
$new_issues[$issue_offset + $offset + $docblock->getStartFilePos()] = $issue_type;
|
||||||
|
|
||||||
if ($issue_type === 'InaccessibleMethod') {
|
if ($issue_type === 'InaccessibleMethod') {
|
||||||
continue;
|
continue;
|
||||||
@ -358,7 +358,7 @@ class StatementsAnalyzer extends SourceAnalyzer implements StatementsSource
|
|||||||
if ($codebase->track_unused_suppressions) {
|
if ($codebase->track_unused_suppressions) {
|
||||||
IssueBuffer::addUnusedSuppression(
|
IssueBuffer::addUnusedSuppression(
|
||||||
$statements_analyzer->getFilePath(),
|
$statements_analyzer->getFilePath(),
|
||||||
$issue_offset + $offset + $docblock->getFilePos(),
|
$issue_offset + $offset + $docblock->getStartFilePos(),
|
||||||
$issue_type
|
$issue_type
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ class ClassStatementsDiffer extends AstDiffer
|
|||||||
$signature_change = true;
|
$signature_change = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$a_start = $a_comments[0]->getFilePos();
|
$a_start = $a_comments[0]->getStartFilePos();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($b_comments) {
|
if ($b_comments) {
|
||||||
@ -80,7 +80,7 @@ class ClassStatementsDiffer extends AstDiffer
|
|||||||
$signature_change = true;
|
$signature_change = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$b_start = $b_comments[0]->getFilePos();
|
$b_start = $b_comments[0]->getStartFilePos();
|
||||||
}
|
}
|
||||||
|
|
||||||
$a_size = $a_end - $a_start;
|
$a_size = $a_end - $a_start;
|
||||||
@ -115,7 +115,7 @@ class ClassStatementsDiffer extends AstDiffer
|
|||||||
$a_stmts_start = (int) $first_stmt->getAttribute('startFilePos');
|
$a_stmts_start = (int) $first_stmt->getAttribute('startFilePos');
|
||||||
|
|
||||||
if ($a_stmt_comments = $first_stmt->getComments()) {
|
if ($a_stmt_comments = $first_stmt->getComments()) {
|
||||||
$a_stmts_start = $a_stmt_comments[0]->getFilePos();
|
$a_stmts_start = $a_stmt_comments[0]->getStartFilePos();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$a_stmts_start = $a_end;
|
$a_stmts_start = $a_end;
|
||||||
@ -126,7 +126,7 @@ class ClassStatementsDiffer extends AstDiffer
|
|||||||
$b_stmts_start = (int) $first_stmt->getAttribute('startFilePos');
|
$b_stmts_start = (int) $first_stmt->getAttribute('startFilePos');
|
||||||
|
|
||||||
if ($b_stmt_comments = $first_stmt->getComments()) {
|
if ($b_stmt_comments = $first_stmt->getComments()) {
|
||||||
$b_stmts_start = $b_stmt_comments[0]->getFilePos();
|
$b_stmts_start = $b_stmt_comments[0]->getStartFilePos();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$b_stmts_start = $b_end;
|
$b_stmts_start = $b_end;
|
||||||
|
@ -61,7 +61,7 @@ class ClassDocblockManipulator
|
|||||||
) {
|
) {
|
||||||
$this->stmt = $stmt;
|
$this->stmt = $stmt;
|
||||||
$docblock = $stmt->getDocComment();
|
$docblock = $stmt->getDocComment();
|
||||||
$this->docblock_start = $docblock ? $docblock->getFilePos() : (int)$stmt->getAttribute('startFilePos');
|
$this->docblock_start = $docblock ? $docblock->getStartFilePos() : (int)$stmt->getAttribute('startFilePos');
|
||||||
$this->docblock_end = (int)$stmt->getAttribute('startFilePos');
|
$this->docblock_end = (int)$stmt->getAttribute('startFilePos');
|
||||||
|
|
||||||
$codebase = $project_analyzer->getCodebase();
|
$codebase = $project_analyzer->getCodebase();
|
||||||
|
@ -119,7 +119,7 @@ class FunctionDocblockManipulator
|
|||||||
{
|
{
|
||||||
$this->stmt = $stmt;
|
$this->stmt = $stmt;
|
||||||
$docblock = $stmt->getDocComment();
|
$docblock = $stmt->getDocComment();
|
||||||
$this->docblock_start = $docblock ? $docblock->getFilePos() : (int)$stmt->getAttribute('startFilePos');
|
$this->docblock_start = $docblock ? $docblock->getStartFilePos() : (int)$stmt->getAttribute('startFilePos');
|
||||||
$this->docblock_end = $function_start = (int)$stmt->getAttribute('startFilePos');
|
$this->docblock_end = $function_start = (int)$stmt->getAttribute('startFilePos');
|
||||||
$function_end = (int)$stmt->getAttribute('endFilePos');
|
$function_end = (int)$stmt->getAttribute('endFilePos');
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ class PropertyDocblockManipulator
|
|||||||
) {
|
) {
|
||||||
$this->stmt = $stmt;
|
$this->stmt = $stmt;
|
||||||
$docblock = $stmt->getDocComment();
|
$docblock = $stmt->getDocComment();
|
||||||
$this->docblock_start = $docblock ? $docblock->getFilePos() : (int)$stmt->getAttribute('startFilePos');
|
$this->docblock_start = $docblock ? $docblock->getStartFilePos() : (int)$stmt->getAttribute('startFilePos');
|
||||||
$this->docblock_end = (int)$stmt->getAttribute('startFilePos');
|
$this->docblock_end = (int)$stmt->getAttribute('startFilePos');
|
||||||
|
|
||||||
$codebase = $project_analyzer->getCodebase();
|
$codebase = $project_analyzer->getCodebase();
|
||||||
|
@ -35,14 +35,14 @@ class OffsetShifterVisitor extends PhpParser\NodeVisitorAbstract implements PhpP
|
|||||||
if ($c instanceof PhpParser\Comment\Doc) {
|
if ($c instanceof PhpParser\Comment\Doc) {
|
||||||
$new_comments[] = new PhpParser\Comment\Doc(
|
$new_comments[] = new PhpParser\Comment\Doc(
|
||||||
$c->getText(),
|
$c->getText(),
|
||||||
$c->getLine() + $this->line_offset,
|
$c->getStartLine() + $this->line_offset,
|
||||||
$c->getFilePos() + $this->file_offset
|
$c->getStartFilePos() + $this->file_offset
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$new_comments[] = new PhpParser\Comment(
|
$new_comments[] = new PhpParser\Comment(
|
||||||
$c->getText(),
|
$c->getText(),
|
||||||
$c->getLine() + $this->line_offset,
|
$c->getStartLine() + $this->line_offset,
|
||||||
$c->getFilePos() + $this->file_offset
|
$c->getStartFilePos() + $this->file_offset
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,8 +90,8 @@ class ParamReplacementVisitor extends PhpParser\NodeVisitorAbstract implements P
|
|||||||
|
|
||||||
if ($replaced) {
|
if ($replaced) {
|
||||||
$this->replacements[] = new FileManipulation(
|
$this->replacements[] = new FileManipulation(
|
||||||
$docblock->getFilePos(),
|
$docblock->getStartFilePos(),
|
||||||
$docblock->getFilePos() + \strlen($docblock->getText()),
|
$docblock->getStartFilePos() + \strlen($docblock->getText()),
|
||||||
\rtrim($parsed_docblock->render($parsed_docblock->first_line_padding)),
|
\rtrim($parsed_docblock->render($parsed_docblock->first_line_padding)),
|
||||||
false,
|
false,
|
||||||
false
|
false
|
||||||
|
@ -69,7 +69,7 @@ class PartialParserVisitor extends PhpParser\NodeVisitorAbstract implements PhpP
|
|||||||
$attrs = $node->getAttributes();
|
$attrs = $node->getAttributes();
|
||||||
|
|
||||||
if ($cs = $node->getComments()) {
|
if ($cs = $node->getComments()) {
|
||||||
$stmt_start_pos = $cs[0]->getFilePos();
|
$stmt_start_pos = $cs[0]->getStartFilePos();
|
||||||
} else {
|
} else {
|
||||||
$stmt_start_pos = $attrs['startFilePos'];
|
$stmt_start_pos = $attrs['startFilePos'];
|
||||||
}
|
}
|
||||||
@ -283,14 +283,14 @@ class PartialParserVisitor extends PhpParser\NodeVisitorAbstract implements PhpP
|
|||||||
if ($c instanceof PhpParser\Comment\Doc) {
|
if ($c instanceof PhpParser\Comment\Doc) {
|
||||||
$new_comments[] = new PhpParser\Comment\Doc(
|
$new_comments[] = new PhpParser\Comment\Doc(
|
||||||
$c->getText(),
|
$c->getText(),
|
||||||
$c->getLine() + $line_offset,
|
$c->getStartLine() + $line_offset,
|
||||||
$c->getFilePos() + $start_offset
|
$c->getStartFilePos() + $start_offset
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
$new_comments[] = new PhpParser\Comment(
|
$new_comments[] = new PhpParser\Comment(
|
||||||
$c->getText(),
|
$c->getText(),
|
||||||
$c->getLine() + $line_offset,
|
$c->getStartLine() + $line_offset,
|
||||||
$c->getFilePos() + $start_offset
|
$c->getStartFilePos() + $start_offset
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ class SimpleNameResolver extends NodeVisitorAbstract
|
|||||||
$attrs = $node->getAttributes();
|
$attrs = $node->getAttributes();
|
||||||
|
|
||||||
if ($cs = $node->getComments()) {
|
if ($cs = $node->getComments()) {
|
||||||
$attrs['startFilePos'] = $cs[0]->getFilePos();
|
$attrs['startFilePos'] = $cs[0]->getStartFilePos();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($attrs['endFilePos'] < $this->start_change
|
if ($attrs['endFilePos'] < $this->start_change
|
||||||
|
@ -166,7 +166,7 @@ class FileDiffTest extends TestCase
|
|||||||
|
|
||||||
$this->assertNotSame($a_doc, $b_doc);
|
$this->assertNotSame($a_doc, $b_doc);
|
||||||
|
|
||||||
$this->assertSame($a_doc->getLine(), $b_doc->getLine());
|
$this->assertSame($a_doc->getStartLine(), $b_doc->getStartLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
|
Loading…
Reference in New Issue
Block a user