Supported Versions: PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8
Applies the callback to the elements of the given arrays
<?php array_map(?callable $callback, array $array, array ...$arrays): array
<?php foreach (array_chunk($processes, 4) as $batch) {
array_map(function (Process $process): void {
$process->start();
}, $batch);
array_map(function (Process $process): void {
$status = $process->wait();
<?php $process->start();
}, $batch);
array_map(function (Process $process): void {
$status = $process->wait();
echo '.';
if ($status !== 0) {
echo 'Process ' . $process->getCommandLine() . ' failed:' . PHP_EOL;
echo $process->getErrorOutput();
echo $process->getOutput();
exit(1);
}
}, $batch);
}
}
<?php $notLoaded = array_diff($devExtensions, $output);
if ($exitCode !== 0 || count($notLoaded) > 0) {
throw new Exception(implode(PHP_EOL, array_map(function ($extension) {
return "Extension $extension is not loaded";
}, $notLoaded)), $exitCode);
}
echo '.';
}
<?php $arguments = array_map(static function (string $arg): string {
return escapeshellarg($arg);
}, $arguments);
try {
$result = $lambda->invoke($function, json_encode(implode(' ', $arguments)));
<?php public function getRecords(): array
{
return array_map(
function ($record): DynamoDbRecord {
try {
return new DynamoDbRecord($record);
} catch (\InvalidArgumentException $e) {
throw new InvalidLambdaEvent('DynamoDb', $this->event);
}
},
$this->event['Records']
);
}
public function toArray(): array
<?php } else {
$headers = $this->event['headers'] ?? [];
$headers = array_map(function ($value): array {
return [$value];
}, $headers);
}
$headers = array_change_key_case($headers, CASE_LOWER);
<?php public function getRecords(): array
{
return array_map(
function ($record): KinesisRecord {
try {
return new KinesisRecord($record);
} catch (\InvalidArgumentException $e) {
throw new InvalidLambdaEvent('Kinesis', $this->event);
}
},
$this->event['Records']
);
}
public function toArray(): array
<?php public function getRecords(): array
{
return array_map(function ($record): S3Record {
try {
return new S3Record($record);
} catch (InvalidArgumentException $e) {
throw new InvalidLambdaEvent('S3', $this->event);
}
}, $this->event['Records']);
}
public function toArray(): array
<?php public function getRecords(): array
{
return array_map(function ($record): SnsRecord {
try {
return new SnsRecord($record);
} catch (InvalidArgumentException $e) {
throw new InvalidLambdaEvent('SNS', $this->event);
}
}, $this->event['Records']);
}
public function toArray(): array
<?php public function getMessageAttributes(): array
{
return array_map(function (array $attribute): MessageAttribute {
return new MessageAttribute($attribute);
}, $this->record['Sns']['MessageAttributes']);
}
public function getTopicArn(): string
<?php public function getRecords(): array
{
return array_map(function ($record): SqsRecord {
try {
return new SqsRecord($record);
} catch (InvalidArgumentException $e) {
throw new InvalidLambdaEvent('SQS', $this->event);
}
}, $this->event['Records']);
}
public function toArray(): array
<?php return;
}
$failures = array_map(
function (SqsRecord $record) {
return ['itemIdentifier' => $record->getMessageId()];
},
$this->failedRecords
);
return [
'batchItemFailures' => $failures,
<?php $this->assertEquals($expected, $this->event->getCookies());
$expectedHeader = array_map(function (string $value, string $key): string {
return $key . '=' . urlencode($value);
}, $expected, array_keys($expected));
$this->assertEquals(implode('; ', $expectedHeader), $this->event->getHeaders()['cookie'][0] ?? '');
}
<?php echo json_encode([
'$_GET' => $_GET,
'$_POST' => $_POST,
'$_FILES' => array_map(function ($file) {
$file['content'] = file_get_contents($file['tmp_name']);
unlink($file['tmp_name']);
unset($file['tmp_name']);
return $file;
}, $_FILES),
'$_COOKIE' => $_COOKIE,
'$_REQUEST' => $_REQUEST,
'$_SERVER' => $_SERVER,
<?php if (! ($response instanceof ResponseInterface)) {
throw new \Exception('Invalid response given.');
}
$headers = array_map(function ($h) {
return implode(' ,', $h);
}, $response->getHeaders());
$data[] = [
'status' => (string) $response->getStatusCode(),
'reason' => $response->getReasonPhrase(),