Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Create an array containing a range of elements
<?php range(string|int|float $start, string|int|float $end, int|float $step = 1): array
<?php public static function range($from, $to)
{
return new static(range($from, $to));
}
<?php $collectionCount = $this->count();
foreach (range(1, min($count, $collectionCount)) as $item) {
array_push($results, array_pop($this->items));
}
<?php $collectionCount = $this->count();
foreach (range(1, min($count, $collectionCount)) as $item) {
array_push($results, array_shift($this->items));
}
<?php return array_map(function () use ($attributes, $parent) {
return $this->state($attributes)->getExpandedAttributes($parent);
}, range(1, $this->count));
}
<?php $instances = $this->newModel()->newCollection(array_map(function () use ($parent) {
return $this->makeInstance($parent);
}, range(1, $this->count)));
$this->callAfterMaking($instances);
<?php public function getUrlRange($start, $end)
{
return collect(range($start, $end))->mapWithKeys(function ($page) {
return [$page => $this->url($page)];
})->all();
}
<?php foreach ($ranges as $range) {
if (preg_match('/^[0-9]+\-[0-9]+$/', $range)) {
$ids = array_merge($ids, range(...explode('-', $range)));
}
}
<?php {
$slots = array_map(function ($i) {
return $this->name.$i;
}, range(1, $this->maxLocks));
return $this->redis->eval(...array_merge(
[$this->lockScript(), count($slots)],
<?php public static function measure(Closure|array $benchmarkables, int $iterations = 1): array|float
{
return collect(Arr::wrap($benchmarkables))->map(function ($callback) use ($iterations) {
return collect(range(1, $iterations))->map(function () use ($callback) {
gc_collect_cycles();
$start = hrtime(true);
<?php ? $this->options->processes
: $this->options->processes();
collect(range(1, $processes))->each(function ($token) use ($callback) {
tap($this->createApplication(), function ($app) use ($callback, $token) {
ParallelTesting::resolveTokenUsing(fn () => $token);
<?php $previous = null;
foreach (range(0, 10) as $ignored) {
$this->assertNotSame($previous, $previous = $model->virtualString);
}
}
<?php $this->assertIsBool($first);
foreach (range(0, 10) as $ignored) {
$this->assertSame($first, $model->virtual_boolean_cached);
}
}
<?php $this->assertSame(1, $model->virtualNullCalls);
foreach (range(0, 10) as $ignored) {
$this->assertSame($first, $model->virtual_null_cached);
}
<?php $this->assertIsBool($first);
foreach (range(0, 50) as $ignored) {
$current = $model->virtual_boolean;
$this->assertIsBool($current);
<?php $previous = $model->virtualObject;
foreach (range(0, 10) as $ignored) {
$this->assertSame($previous, $previous = $model->virtualObject);
}
}