Skip to content

Commit 836d227

Browse files
committed
Documentation URL showed with autoloading errors
1 parent 9b712a9 commit 836d227

12 files changed

+54
-2
lines changed

src/AnalysedCodeException.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55
abstract class AnalysedCodeException extends \Exception
66
{
77

8+
abstract public function getTip(): ?string;
9+
810
}

src/Analyser/FileAnalyser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function analyseFile(
8282
}
8383

8484
$uniquedAnalysedCodeExceptionMessages[$e->getMessage()] = true;
85-
$fileErrors[] = new Error($e->getMessage(), $file, $node->getLine(), false);
85+
$fileErrors[] = new Error($e->getMessage(), $file, $node->getLine(), false, null, null, $e->getTip());
8686
continue;
8787
} catch (IdentifierNotFound $e) {
8888
$fileErrors[] = new Error(sprintf('Reflection error: %s not found.', $e->getIdentifier()->getName()), $file, $node->getLine(), false);
@@ -176,7 +176,7 @@ public function analyseFile(
176176
$fileErrors[] = new Error($error->getMessage(), $file, $error->getStartLine() !== -1 ? $error->getStartLine() : null, false);
177177
}
178178
} catch (\PHPStan\AnalysedCodeException $e) {
179-
$fileErrors[] = new Error($e->getMessage(), $file, null, false);
179+
$fileErrors[] = new Error($e->getMessage(), $file, null, false, null, null, $e->getTip());
180180
} catch (IdentifierNotFound $e) {
181181
$fileErrors[] = new Error(sprintf('Reflection error: %s not found.', $e->getIdentifier()->getName()), $file, null, false);
182182
}

src/Analyser/UndefinedVariableException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,9 @@ public function getVariableName(): string
2828
return $this->variableName;
2929
}
3030

31+
public function getTip(): ?string
32+
{
33+
return null;
34+
}
35+
3136
}

src/Broker/ClassAutoloadingException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,9 @@ public function getClassName(): string
3535
return $this->className;
3636
}
3737

38+
public function getTip(): ?string
39+
{
40+
return 'Learn more at https://phpstan.org/user-guide/autoloading';
41+
}
42+
3843
}

src/Broker/ClassNotFoundException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ public function getClassName(): string
1919
return $this->className;
2020
}
2121

22+
public function getTip(): ?string
23+
{
24+
return 'Learn more at https://phpstan.org/user-guide/autoloading';
25+
}
26+
2227
}

src/Broker/ConstantNotFoundException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ public function getConstantName(): string
1919
return $this->constantName;
2020
}
2121

22+
public function getTip(): ?string
23+
{
24+
return 'Learn more at https://phpstan.org/user-guide/autoloading';
25+
}
26+
2227
}

src/Broker/FunctionNotFoundException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ public function getFunctionName(): string
1919
return $this->functionName;
2020
}
2121

22+
public function getTip(): ?string
23+
{
24+
return 'Learn more at https://phpstan.org/user-guide/autoloading';
25+
}
26+
2227
}

src/File/CouldNotReadFileException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ public function __construct(string $fileName)
1010
parent::__construct(sprintf('Could not read file: %s', $fileName));
1111
}
1212

13+
public function getTip(): ?string
14+
{
15+
return null;
16+
}
17+
1318
}

src/File/CouldNotWriteFileException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@ public function __construct(string $fileName, string $error)
1010
parent::__construct(sprintf('Could not write file: %s (%s)', $fileName, $error));
1111
}
1212

13+
public function getTip(): ?string
14+
{
15+
return null;
16+
}
17+
1318
}

src/Reflection/MissingConstantFromReflectionException.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ public function __construct(
2323
);
2424
}
2525

26+
public function getTip(): ?string
27+
{
28+
return null;
29+
}
30+
2631
}

0 commit comments

Comments
 (0)