-
-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f9c44ec
commit 36d4b65
Showing
7 changed files
with
113 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/TypeDeclaration/src/TypeInferer/ParamTypeInferer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Rector\TypeDeclaration\TypeInferer; | ||
|
||
use PhpParser\Node\Param; | ||
use Rector\TypeDeclaration\Contract\TypeInferer\ParamTypeInfererInterface; | ||
|
||
final class ParamTypeInferer | ||
{ | ||
/** | ||
* @var ParamTypeInfererInterface[] | ||
*/ | ||
private $paramTypeInferers = []; | ||
|
||
/** | ||
* @param ParamTypeInfererInterface[] $paramTypeInferers | ||
*/ | ||
public function __construct(array $paramTypeInferers) | ||
{ | ||
$this->paramTypeInferers = $paramTypeInferers; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
public function inferParam(Param $param): array | ||
{ | ||
foreach ($this->paramTypeInferers as $paramTypeInferers) { | ||
$types = $paramTypeInferers->inferParam($param); | ||
if ($types !== []) { | ||
return $types; | ||
} | ||
} | ||
|
||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters