Skip to content

Commit 927f3d3

Browse files
Optimized the parameters of method __call() to make them more standardized. (#7637)
Co-authored-by: 李铭昕 <[email protected]>
1 parent efe2634 commit 927f3d3

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

src/Fluent.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,14 @@ public function __construct($attributes = [])
6363

6464
/**
6565
* Handle dynamic calls to the fluent instance to set attributes.
66-
*
67-
* @param TKey $method
68-
* @param array $parameters
69-
* @return $this
7066
*/
71-
public function __call($method, $parameters)
67+
public function __call(string $name, array $arguments): mixed
7268
{
73-
if (static::hasMacro($method)) {
74-
return $this->macroCall($method, $parameters);
69+
if (static::hasMacro($name)) {
70+
return $this->macroCall($name, $arguments);
7571
}
7672

77-
$this->attributes[$method] = count($parameters) > 0 ? $parameters[0] : true;
73+
$this->attributes[$name] = count($arguments) > 0 ? $arguments[0] : true;
7874

7975
return $this;
8076
}

src/Optional.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,15 @@ public function __isset($name)
6666

6767
/**
6868
* Dynamically pass a method to the underlying object.
69-
*
70-
* @param string $method
71-
* @param array $parameters
72-
* @return mixed
7369
*/
74-
public function __call($method, $parameters)
70+
public function __call(string $name, array $arguments): mixed
7571
{
76-
if (static::hasMacro($method)) {
77-
return $this->macroCall($method, $parameters);
72+
if (static::hasMacro($name)) {
73+
return $this->macroCall($name, $arguments);
7874
}
7975

8076
if (is_object($this->value)) {
81-
return $this->value->{$method}(...$parameters);
77+
return $this->value->{$name}(...$arguments);
8278
}
8379

8480
return null;

src/Reflection/ClassInvoker.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __get($name)
3030
return $property->getValue($this->instance);
3131
}
3232

33-
public function __call($name, $arguments)
33+
public function __call(string $name, array $arguments): mixed
3434
{
3535
$method = $this->reflection->getMethod($name);
3636

0 commit comments

Comments
 (0)