Skip to content

Commit 0e2401b

Browse files
add known return mixed on get (#7425)
* add known return mixed on get * [ci-review] Rector Rectify --------- Co-authored-by: GitHub Action <actions@github.com>
1 parent 4a642a1 commit 0e2401b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

rules-tests/TypeDeclaration/Rector/ClassMethod/KnownMagicClassMethodTypeRector/Fixture/get_and_set.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\KnownMagicClassMethodT
2121

2222
final class GetAndSet
2323
{
24-
public function __get(string $method)
24+
public function __get(string $method): mixed
2525
{
2626
}
2727

rules/TypeDeclaration/Rector/ClassMethod/KnownMagicClassMethodTypeRector.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ public function refactor(Node $node): ?Node
110110
}
111111
}
112112

113+
if ($this->isName($classMethod, MethodName::__GET) && $this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::MIXED_TYPE) && ! $classMethod->returnType instanceof Node) {
114+
$classMethod->returnType = new Identifier('mixed');
115+
$hasChanged = true;
116+
}
117+
113118
if ($this->isName($classMethod, MethodName::__SET) && $this->phpVersionProvider->isAtLeastPhpVersion(
114119
PhpVersionFeature::MIXED_TYPE
115120
)) {

0 commit comments

Comments
 (0)