Skip to content

Commit

Permalink
[TypeDeclaration] Using native type scope get on ReturnTypeInferer (#…
Browse files Browse the repository at this point in the history
…4648)

* [TypeDeclaration] Using native type scope get on ReturnTypeInferer

* remove left over tests

* fallback

* missing set unregister
  • Loading branch information
samsonasik committed Aug 4, 2023
1 parent ae767eb commit 529defd
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 109 deletions.

This file was deleted.

2 changes: 1 addition & 1 deletion rules/TypeDeclaration/TypeInferer/ReturnTypeInferer.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private function resolveBenevolentUnionTypeInteger(
foreach ($returnsWithExpr as $returnWithExpr) {
/** @var Expr $expr */
$expr = $returnWithExpr->expr;
$type = $this->nodeTypeResolver->getType($expr);
$type = $this->nodeTypeResolver->getNativeType($expr);

if (! $type instanceof BenevolentUnionType) {
return $unionType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer;

use PhpParser\Node;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\FunctionLike;
Expand Down Expand Up @@ -62,7 +63,9 @@ public function inferFunctionLike(FunctionLike $functionLike): Type
}

foreach ($localReturnNodes as $localReturnNode) {
$returnedExprType = $this->nodeTypeResolver->getType($localReturnNode);
$returnedExprType = $localReturnNode->expr instanceof Expr
? $this->nodeTypeResolver->getNativeType($localReturnNode->expr)
: $this->nodeTypeResolver->getType($localReturnNode);
$returnedExprType = $this->correctWithNestedType($returnedExprType, $localReturnNode, $functionLike);

$types[] = $this->splArrayFixedTypeNarrower->narrow($returnedExprType);
Expand Down
31 changes: 0 additions & 31 deletions tests/Issues/Issue6677/DoNotTriggerPhpWarningRectorTest.php

This file was deleted.

45 changes: 0 additions & 45 deletions tests/Issues/Issue6677/Fixture/do_not_trigger_php_warning.php.inc

This file was deleted.

12 changes: 0 additions & 12 deletions tests/Issues/Issue6677/config/configured_rule.php

This file was deleted.

1 change: 0 additions & 1 deletion utils/Command/MissingInSetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ final class MissingInSetCommand extends Command
__DIR__ . '/../../vendor/rector/rector-phpunit/rules/CodeQuality' => __DIR__ . '/../../vendor/rector/rector-phpunit/config/sets/phpunit-code-quality.php',

// rector-downgrade
__DIR__ . '/../../vendor/rector/rector-downgrade-php/rules/DowngradePhp71' => __DIR__ . '/../../vendor/rector/rector-downgrade-php/config/set/downgrade-php71.php',
__DIR__ . '/../../vendor/rector/rector-downgrade-php/rules/DowngradePhp72' => __DIR__ . '/../../vendor/rector/rector-downgrade-php/config/set/downgrade-php72.php',
__DIR__ . '/../../vendor/rector/rector-downgrade-php/rules/DowngradePhp73' => __DIR__ . '/../../vendor/rector/rector-downgrade-php/config/set/downgrade-php73.php',
__DIR__ . '/../../vendor/rector/rector-downgrade-php/rules/DowngradePhp74' => __DIR__ . '/../../vendor/rector/rector-downgrade-php/config/set/downgrade-php74.php',
Expand Down

0 comments on commit 529defd

Please sign in to comment.