-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'phpstan/1.10.x' into HEAD
- Loading branch information
Showing
16 changed files
with
230 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Rules\PhpDoc; | ||
|
||
use PhpParser\Node as PhpParserNode; | ||
use PHPStan\PhpDocParser\Ast\Node as PhpDocNode; | ||
|
||
class PhpDocLineHelper | ||
{ | ||
|
||
/** | ||
* This method returns exact line of e.g. `@param` tag in PHPDoc so that it can be used for precise error reporting | ||
* - exact position is available only when bleedingEdge is enabled | ||
* - otherwise, it falls back to given node start line | ||
*/ | ||
public static function detectLine(PhpParserNode $node, PhpDocNode $phpDocNode): int | ||
{ | ||
$phpDocTagLine = $phpDocNode->getAttribute('startLine'); | ||
$phpDoc = $node->getDocComment(); | ||
|
||
if ($phpDocTagLine === null || $phpDoc === null) { | ||
return $node->getLine(); | ||
} | ||
|
||
return $phpDoc->getStartLine() + $phpDocTagLine - 1; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace IgnoreNextLineLegacy; | ||
|
||
class Foo | ||
{ | ||
|
||
public function doFoo(): void | ||
{ | ||
fail(); // reported | ||
|
||
// @phpstan-ignore-next-line | ||
fail(); | ||
|
||
/* @phpstan-ignore-next-line */ | ||
fail(); | ||
|
||
/** @phpstan-ignore-next-line */ | ||
fail(); | ||
|
||
/* | ||
* @phpstan-ignore-next-line | ||
*/ | ||
fail(); | ||
|
||
/** | ||
* @phpstan-ignore-next-line | ||
* | ||
* This is the legacy behaviour, the next line is meant as next-non-comment-line | ||
*/ | ||
fail(); | ||
fail(); // reported | ||
|
||
// @phpstan-ignore-next-line | ||
if (fail()) { | ||
fail(); // reported | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.