diff --git a/src/MTProto.php b/src/MTProto.php index 706d8c778a..d05ea76354 100644 --- a/src/MTProto.php +++ b/src/MTProto.php @@ -139,7 +139,7 @@ final class MTProto implements TLCallback, LoggerGetter * * @var string */ - const RELEASE = '8.0.0-beta90'; + const RELEASE = '8.0.0-beta91'; /** * We're not logged in. * diff --git a/src/Namespace/AbstractAPI.php b/src/Namespace/AbstractAPI.php index 22911470a7..883ffd6b67 100644 --- a/src/Namespace/AbstractAPI.php +++ b/src/Namespace/AbstractAPI.php @@ -43,8 +43,23 @@ public function setWrapper(APIWrapper $wrapper): void */ public function __call(string $name, array $arguments) { - if ($arguments && !isset($arguments[0])) { - $arguments = [$arguments]; + if (!isset($arguments[0])) { + // Named arguments + $args = $arguments; + $aargs = []; + } else { + // Legacy arguments + $args = $arguments[0] ?? []; + $aargs = $arguments[1] ?? []; + if (!\array_is_list($arguments) + || \count($arguments) > 2 + || !\is_array($args) + || !\is_array($aargs) + || isset($args['_']) + || (isset($args[0]) && !isset($aargs['multiple'])) + ) { + throw new InvalidArgumentException('Parameter names must be provided!'); + } } $name = $this->namespace.'.'.$name; @@ -52,11 +67,6 @@ public function __call(string $name, array $arguments) throw new Exception(Blacklist::BLACKLIST[$name]); } - $aargs = isset($arguments[1]) && \is_array($arguments[1]) ? $arguments[1] : []; - $args = isset($arguments[0]) && \is_array($arguments[0]) ? $arguments[0] : []; - if (isset($args[0]) && !isset($args['multiple'])) { - throw new InvalidArgumentException('Parameter names must be provided!'); - } return $this->wrapper->getAPI()->methodCallAsyncRead($name, $args, $aargs); } }