mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 03:37:44 +08:00
Optimized code.
This commit is contained in:
parent
61c25b4a69
commit
209993efd4
@ -76,6 +76,7 @@ Now:
|
||||
## Fixed
|
||||
|
||||
- [#448](https://github.com/hyperf-cloud/hyperf/pull/448) Fixed TCP Server does not works when HTTP Server or WebSocket Server exists.
|
||||
- [#623](https://github.com/hyperf-cloud/hyperf/pull/623) Fixed `null` is replaced by default value.
|
||||
|
||||
# v1.0.16 - TBD
|
||||
|
||||
|
@ -43,10 +43,10 @@ trait ProxyTrait
|
||||
];
|
||||
$reflectMethod = ReflectionManager::reflectMethod($className, $method);
|
||||
$reflectParameters = $reflectMethod->getParameters();
|
||||
foreach ($reflectParameters as $key => $reflectionParameter) {
|
||||
$leftCount = count($args);
|
||||
foreach ($reflectParameters as $key => $reflectionParameter) {
|
||||
$arg = $reflectionParameter->isVariadic() ? $args : array_shift($args);
|
||||
if (! isset($arg) && $leftCount === 0) {
|
||||
if (! isset($arg) && $leftCount-- <= 0) {
|
||||
$arg = $reflectionParameter->getDefaultValue();
|
||||
}
|
||||
$map['keys'][$reflectionParameter->getName()] = $arg;
|
||||
|
@ -33,5 +33,8 @@ class ProxyTraitTest extends TestCase
|
||||
|
||||
$this->assertEquals(['id' => null, 'str' => ''], $obj->get2(null)['keys']);
|
||||
$this->assertEquals(['id', 'str'], $obj->get2(null)['order']);
|
||||
|
||||
$this->assertEquals(['id' => 1, 'str' => '', 'num' => 1.0], $obj->get3()['keys']);
|
||||
$this->assertEquals(['id', 'str', 'num'], $obj->get3()['order']);
|
||||
}
|
||||
}
|
||||
|
@ -27,4 +27,9 @@ class ProxyTraitObject
|
||||
{
|
||||
return $this->getParamsMap(static::class, 'get2', func_get_args());
|
||||
}
|
||||
|
||||
public function get3(?int $id = 1, string $str = '', float $num = 1.0)
|
||||
{
|
||||
return $this->getParamsMap(static::class, 'get3', func_get_args());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user