Skip to content

Commit 1de5e32

Browse files
committed
example errors
1 parent 1b3d2aa commit 1de5e32

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎src/Command/ErrorFormatter/CheckstyleErrorFormatter.php‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PHPStan\File\RelativePathHelper;
1111
use function count;
1212
use function htmlspecialchars;
13+
use function PHPStan\debugScope;
1314
use function sprintf;
1415
use const ENT_COMPAT;
1516
use const ENT_XML1;
@@ -124,4 +125,20 @@ private function groupByFile(AnalysisResult $analysisResult): array
124125
return $files;
125126
}
126127

128+
/** @param 1 $i */
129+
public function demoErrorAnnotations(int $i): array
130+
{
131+
if ($i === 1) {
132+
echo 1; // @phpstan-ignore variable.undefined
133+
}
134+
135+
debugScope();
136+
return [$this->demoWithoutTip()];
137+
}
138+
139+
private function demoWithoutTip(): int
140+
{
141+
return 'not an int';
142+
}
143+
127144
}

‎src/Command/ErrorFormatter/RawErrorFormatter.php‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PHPStan\Command\ErrorFormatter;
44

5+
use Exception;
56
use PHPStan\Command\AnalysisResult;
67
use PHPStan\Command\Output;
78
use PHPStan\DependencyInjection\AutowiredService;
@@ -49,4 +50,20 @@ public function formatErrors(
4950
return $analysisResult->hasErrors() ? 1 : 0;
5051
}
5152

53+
public function demoErrorAnnotations(): void
54+
{
55+
$this->demoObjectShape(new Exception());
56+
$rocket = '🚀 launch 😃';
57+
if ($rocket === '🐢 slow') {
58+
return;
59+
}
60+
}
61+
62+
/**
63+
* @param object{foo: int, bar: string} $o
64+
*/
65+
private function demoObjectShape(object $o): void
66+
{
67+
}
68+
5269
}

0 commit comments

Comments
 (0)