Skip to content

Commit

Permalink
fix: Allow usage of null parameter to pass optional url argument
Browse files Browse the repository at this point in the history
Previously, if arguments pass as `$api->projects($idOrName)` were failing if `$idOrName` was null, expecting a scalar type, now ignore arguments if it's value is null.

This allow to use `$api->projects($idOrName)`:
* to request `/projects` when `$idOrName` is null
* to request `/projects/{idOrName}` otherwise
  • Loading branch information
emri99 committed Jan 16, 2020
1 parent c25a394 commit e8116a3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/GitlabApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ public function __call($method, array $args)
}

foreach ($args as $param) {
if (null === $param) {
continue;
}

if (!is_scalar($param)) {
throw new \InvalidArgumentException(sprintf('Method "%s" : Invalid argument type. scalar expected.', $method));
}
Expand Down

0 comments on commit e8116a3

Please sign in to comment.