Skip to content

Commit

Permalink
[TypeDeclaration] Skip conditional Throw_ on ReturnNeverTypeRector (#…
Browse files Browse the repository at this point in the history
…1217)

Co-authored-by: Markus Staab <markus.staab@redaxo.de>
Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
3 people committed Nov 12, 2021
1 parent 5f9adb6 commit af81708
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\Fixture;

function assertEmptyOutputBuffer($messagePrefix)
{
if (Rocket::isAppMode('development')) {
if (ob_get_length() > 0) {
throw new Exception($messagePrefix.'Unexpected start of output:'.print_r(ob_get_contents(), true));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector\Fixture;

class X {
protected function configBoot()
{
if (isset($helper_files)) {
throw new Exception('error');
}
if (isset($builtin_files)) {
throw new Exception('error');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,8 @@ private function shouldSkip(ClassMethod | Function_ $node): bool
return true;
}

$hasNotNeverNodes = $this->betterNodeFinder->hasInstancesOf(
$node,
[Yield_::class] + ControlStructure::CONDITIONAL_NODE_SCOPE_TYPES
);
$yieldAndConditionalNodes = array_merge([Yield_::class], ControlStructure::CONDITIONAL_NODE_SCOPE_TYPES);
$hasNotNeverNodes = $this->betterNodeFinder->hasInstancesOf($node, $yieldAndConditionalNodes);
if ($hasNotNeverNodes) {
return true;
}
Expand Down

0 comments on commit af81708

Please sign in to comment.