Skip to content

Commit db4db5b

Browse files
committed
MissingReturnRule - make missing return with native return type non-ignorable
1 parent 81bebdd commit db4db5b

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

conf/config.level0.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ services:
172172
arguments:
173173
checkExplicitMixedMissingReturn: %checkExplicitMixedMissingReturn%
174174
checkPhpDocMissingReturn: %checkPhpDocMissingReturn%
175-
bleedingEdge: %featureToggles.bleedingEdge%
176175
tags:
177176
- phpstan.rules.rule
178177

src/Rules/Missing/MissingReturnRule.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,13 @@ class MissingReturnRule implements Rule
2828

2929
private bool $checkPhpDocMissingReturn;
3030

31-
private bool $bleedingEdge;
32-
3331
public function __construct(
3432
bool $checkExplicitMixedMissingReturn,
35-
bool $checkPhpDocMissingReturn,
36-
bool $bleedingEdge = false
33+
bool $checkPhpDocMissingReturn
3734
)
3835
{
3936
$this->checkExplicitMixedMissingReturn = $checkExplicitMixedMissingReturn;
4037
$this->checkPhpDocMissingReturn = $checkPhpDocMissingReturn;
41-
$this->bleedingEdge = $bleedingEdge;
4238
}
4339

4440
public function getNodeType(): string
@@ -112,7 +108,7 @@ public function processNode(Node $node, Scope $scope): array
112108
if ($returnType instanceof NeverType && $returnType->isExplicit()) {
113109
$errorBuilder = RuleErrorBuilder::message(sprintf('%s should always throw an exception or terminate script execution but doesn\'t do that.', $description))->line($node->getNode()->getStartLine());
114110

115-
if ($this->bleedingEdge && $node->hasNativeReturnTypehint()) {
111+
if ($node->hasNativeReturnTypehint()) {
116112
$errorBuilder->nonIgnorable();
117113
}
118114

@@ -137,7 +133,7 @@ public function processNode(Node $node, Scope $scope): array
137133
sprintf('%s should return %s but return statement is missing.', $description, $returnType->describe(VerbosityLevel::typeOnly()))
138134
)->line($node->getNode()->getStartLine());
139135

140-
if ($this->bleedingEdge && $node->hasNativeReturnTypehint()) {
136+
if ($node->hasNativeReturnTypehint()) {
141137
$errorBuilder->nonIgnorable();
142138
}
143139

0 commit comments

Comments
 (0)