mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
I think I understand strpos/strrpos a little better now
This commit is contained in:
parent
4832aa6075
commit
73eb71bada
@ -131,7 +131,7 @@ class FileManipulationBuffer
|
||||
return;
|
||||
}
|
||||
|
||||
$comment_end = strpos($file_contents, '*/', strlen($file_contents) - $bounds[1]);
|
||||
$comment_end = strpos($file_contents, '*/', $bounds[1]);
|
||||
|
||||
if ($comment_end === false) {
|
||||
return;
|
||||
@ -145,7 +145,7 @@ class FileManipulationBuffer
|
||||
$var_type_comment_end = $bounds[1] - $comment_start;
|
||||
|
||||
$var_start = strrpos($comment_text, '@var', $var_type_comment_start - strlen($comment_text));
|
||||
$var_end = strpos($comment_text, "\n", $var_type_comment_end - strlen($comment_text));
|
||||
$var_end = strpos($comment_text, "\n", $var_type_comment_end);
|
||||
|
||||
if ($var_start && $var_end) {
|
||||
$var_start = strrpos($comment_text, "\n", $var_start - strlen($comment_text)) ?: $var_start;
|
||||
|
@ -35,6 +35,30 @@ class UnnecessaryVarAnnotationManipulationTest extends FileManipulationTest
|
||||
['UnnecessaryVarAnnotation'],
|
||||
true,
|
||||
],
|
||||
'removeSingleLineVarAnnotationFlipped' => [
|
||||
'<?php
|
||||
function foo() : string {
|
||||
return "hello";
|
||||
}
|
||||
|
||||
/** @var "a"|"b" */
|
||||
$b = foo();
|
||||
|
||||
/** @var string */
|
||||
$a = foo();',
|
||||
'<?php
|
||||
function foo() : string {
|
||||
return "hello";
|
||||
}
|
||||
|
||||
/** @var "a"|"b" */
|
||||
$b = foo();
|
||||
|
||||
$a = foo();',
|
||||
'5.6',
|
||||
['UnnecessaryVarAnnotation'],
|
||||
true,
|
||||
],
|
||||
'removeSingleLineVarAnnotationAndType' => [
|
||||
'<?php
|
||||
function foo() : string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user