Added ModelUpdateVisitor::getReturnType method (#7077)

This commit is contained in:
Deeka Wong 2024-09-19 16:17:27 +08:00 committed by GitHub
parent 3cf0da31d3
commit 2443aa4f10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

View File

@ -4,6 +4,7 @@
- [#7059](https://github.com/hyperf/hyperf/pull/7059) Added `Hyperf\Database\Schema\Schema::getForeignKeys()`.
- [#7064](https://github.com/hyperf/hyperf/pull/7064) Support db type `enum` for `DoctrineConnection`.
- [#7077](https://github.com/hyperf/hyperf/pull/7077) Added `ModelUpdateVisitor::getReturnType` method.
# v3.1.40 - 2024-09-12

View File

@ -259,7 +259,7 @@ class ModelUpdateVisitor extends NodeVisitorAbstract
// Magic get<name>Attribute
$name = Str::snake(substr($method->getName(), 3, -9));
if (! empty($name)) {
$type = PhpDocReader::getInstance()->getReturnType($method, true);
$type = $this->getReturnType($method, true);
$this->setProperty($name, $type, true, false, '', false, 1);
}
continue;
@ -438,4 +438,9 @@ class ModelUpdateVisitor extends NodeVisitorAbstract
$model = new $className();
return '\\' . get_class($model->newCollection());
}
protected function getReturnType(ReflectionMethod $method, bool $withoutNamespace = false): array
{
return PhpDocReader::getInstance()->getReturnType($method, $withoutNamespace);
}
}