getMethods(\ReflectionMethod::IS_PUBLIC); foreach ($methods as $method) { $params = $method->getNumberOfParameters() + 2; static::$methodArgs[$method->name] = $params; } } if (!isset(static::$methodArgs[$name])) { throw new \BadMethodCallException($name . ' is not a valid method'); } $numArgs = \count($arguments); $array = $numArgs ? $arguments[0] : ''; if ($numArgs === static::$methodArgs[$name]) { $args = \array_slice($arguments, 1, -1); } else { $args = \array_slice($arguments, 1); } $arrayy = Arrayy::create($array); return \call_user_func_array([$arrayy, $name], $args); } //////////////////////////////////////////////////////////////////// ///////////////////////////// GENERATE ///////////////////////////// //////////////////////////////////////////////////////////////////// /** * Generate an array from a range. * * @param int $base The base number * @param int|null $stop The stopping point * @param int $step How many to increment of * * @return Arrayy * * @psalm-suppress InvalidReturnStatement - why? * @psalm-suppress InvalidReturnType - why? */ public static function range(int $base, int $stop = null, int $step = 1): Arrayy { if ($stop !== null) { $start = $base; } else { $start = 1; $stop = $base; } return Arrayy::create(\range($start, $stop, $step)); } /** * Fill an array with $times times some $data. * * @param float|int|string|null $data * @param int $times * * @return Arrayy * * @psalm-suppress InvalidReturnStatement - why? * @psalm-suppress InvalidReturnType - why? */ public static function repeat($data, int $times): Arrayy { if ($times === 0 || empty($data)) { return Arrayy::create(); } return Arrayy::create(\array_fill(0, $times, $data)); } }