mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit c45f0e2cef30cb0b3090d51fd14dc6ffaa1fc095
c45f0e2cef
[CodeQuality] Add Function_ support on ExplicitReturnNullRector (#5762)
This commit is contained in:
parent
e18e5ef364
commit
0e57251e46
|
@ -102,10 +102,10 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function getNodeTypes() : array
|
||||
{
|
||||
return [ClassMethod::class];
|
||||
return [ClassMethod::class, Function_::class];
|
||||
}
|
||||
/**
|
||||
* @param ClassMethod $node
|
||||
* @param ClassMethod|Function_ $node
|
||||
*/
|
||||
public function refactor(Node $node) : ?Node
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ CODE_SAMPLE
|
|||
if ($node->returnType instanceof Node) {
|
||||
return null;
|
||||
}
|
||||
if ($this->isName($node, MethodName::CONSTRUCT)) {
|
||||
if ($node instanceof ClassMethod && $this->isName($node, MethodName::CONSTRUCT)) {
|
||||
return null;
|
||||
}
|
||||
$returnType = $this->returnTypeInferer->inferFunctionLike($node);
|
||||
|
@ -143,9 +143,12 @@ CODE_SAMPLE
|
|||
$this->transformDocUnionVoidToUnionNull($node);
|
||||
return $node;
|
||||
}
|
||||
private function transformDocUnionVoidToUnionNull(ClassMethod $classMethod) : void
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $node
|
||||
*/
|
||||
private function transformDocUnionVoidToUnionNull($node) : void
|
||||
{
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($classMethod);
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
$returnType = $phpDocInfo->getReturnType();
|
||||
if (!$returnType instanceof UnionType) {
|
||||
return;
|
||||
|
@ -166,6 +169,6 @@ CODE_SAMPLE
|
|||
if (!$type instanceof UnionType) {
|
||||
return;
|
||||
}
|
||||
$this->phpDocTypeChanger->changeReturnType($classMethod, $phpDocInfo, $type);
|
||||
$this->phpDocTypeChanger->changeReturnType($node, $phpDocInfo, $type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '97e2433a8378ccc6666c67d4a01ace3abc97589f';
|
||||
public const PACKAGE_VERSION = 'c45f0e2cef30cb0b3090d51fd14dc6ffaa1fc095';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-03-23 13:26:17';
|
||||
public const RELEASE_DATE = '2024-03-23 13:36:05';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue