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 ($filesOrDirectories as $fileOrDirectory) {
$name = SpellcheckFormatter::format($fileOrDirectory->getFilenameWithoutExtension());
$newIssues = array_map(
fn (Misspelling $misspelling): Issue => new Issue(
$misspelling,
$fileOrDirectory->getRealPath(),
0,
), $this->spellchecker->check($name),
);
$issues = [
...$issues,
<?php foreach ($namesToCheck as $name) {
$issues = [
...$issues,
...array_map(
fn (Misspelling $misspelling): Issue => new Issue(
$misspelling,
$file->getRealPath(),
$this->getErrorLine($file, $name),
), $this->spellchecker->check(SpellcheckFormatter::format($name))),
];
}
<?php private function getMethodParameters(ReflectionMethod $method): array
{
return array_map(
fn (ReflectionParameter $parameter): string => $parameter->getName(),
$method->getParameters(),
);
}
<?php private function getConstantNames(ReflectionClass $reflection): array
{
return array_merge(...array_values((array_map(
function (ReflectionClassConstant $constant) use ($reflection): array {
foreach ($reflection->getTraits() as $trait) {
if ($trait->hasConstant($constant->getName())) {
return [];
}
}
if ($constant->class !== $reflection->name) {
return [];
}
$value = $constant->getValue();
if ($value instanceof BackedEnum) {
return is_string($value->value)
? [$value->name, $value->value]
: [$value->name];
}
return is_string($value)
? [$constant->name, $value]
: [$constant->name];
},
$reflection->getReflectionConstants()
))));
}
<?php },
);
$propertiesNames = array_map(
fn (ReflectionProperty $property): string => $property->getName(),
$properties,
);
$propertiesDocComments = array_reduce(
array_map(
<?php );
$propertiesDocComments = array_reduce(
array_map(
fn (ReflectionProperty $property): array => explode(PHP_EOL, $property->getDocComment() ?: ''),
$properties,
),
fn (array $carry, array $item): array => [
...$carry,
...$item,
<?php private function getErrorLine(SplFileInfo $file, string $misspellingWord): int
{
$contentsArray = explode(PHP_EOL, $file->getContents());
$contentsArrayLines = array_map(fn ($lineNumber): int => $lineNumber + 1, array_keys($contentsArray));
$lines = array_values(array_filter(
array_map(
<?php $contentsArrayLines = array_map(fn ($lineNumber): int => $lineNumber + 1, array_keys($contentsArray));
$lines = array_values(array_filter(
array_map(
fn (string $line, int $lineNumber): ?int => str_contains($line, $misspellingWord) ? $lineNumber : null,
$contentsArray,
$contentsArrayLines,
),
));
if ($lines === []) {
<?php public array $whitelistedPaths = [],
public ?string $preset = null,
) {
$this->whitelistedWords = array_map(strtolower(...), $whitelistedWords);
}
<?php public function ignoreWords(array $words): void
{
$this->whitelistedWords = array_merge($this->whitelistedWords, array_map(strtolower(...), $words));
$this->persist();
}
<?php if ($input->getOption('ignore-all')) {
$this->addMisspellingsToConfig($issues);
$wordsAddedCount = count(array_unique(array_map(
fn (Issue $issue): string => $issue->misspelling->word,
$issues,
)));
render(<<<HTML
<div class="mx-2 mb-1">
<?php private function formatIssueSuggestionsForDisplay(Issue $issue): string
{
$suggestions = array_map(
'strtolower',
$issue->misspelling->suggestions,
);
return implode(', ', $suggestions);
}
<?php private function addMisspellingsToConfig(array $issues): void
{
$misspellings = array_map(
fn (Issue $issue): string => $issue->misspelling->word,
$issues,
);
Config::instance()->ignoreWords(array_unique($misspellings));
}
<?php $output = $process->getOutput();
return array_values(array_map(function (string $line): Misspelling {
[$wordMetadataAsString, $suggestionsAsString] = explode(':', trim($line));
$word = explode(' ', $wordMetadataAsString)[1];
$suggestions = explode(', ', trim($suggestionsAsString));
return new Misspelling($word, $this->takeSuggestions($suggestions));
}, array_filter(explode(PHP_EOL, $output), fn (string $line): bool => str_starts_with($line, '&'))));
}
<?php public static function get(string $in, array $paths): array
{
$paths = array_map(
fn (string $path): string => (realpath(ProjectPath::get())).'/'.ltrim(ltrim($path, '/'), './'),
$paths,
);
return array_map(
fn (string $path): string => ltrim(str_replace((string) realpath($in), '', $path), '/'),