array_filter

Supported Versions: PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8
Filters elements of an array using a callback function
<?php array_filter(array $array, ?callable $callback = null, int $mode = 0): array
<?php             $className = 'InvalidTestName'.Str::random();

        }



        $classAvailableAttributes = array_filter(self::ATTRIBUTES, fn (string $attribute): bool => $attribute::$above);

        $methodAvailableAttributes = array_filter(self::ATTRIBUTES, fn (string $attribute): bool => ! $attribute::$above);



        $classAttributes = [];
<?php         }



        $classAvailableAttributes = array_filter(self::ATTRIBUTES, fn (string $attribute): bool => $attribute::$above);

        $methodAvailableAttributes = array_filter(self::ATTRIBUTES, fn (string $attribute): bool => ! $attribute::$above);



        $classAttributes = [];
<?php         $frames = explode("\n", $stackTrace);




        $frames = array_filter($frames);




        $frames = array_map(
<?php     public function handleArguments(array $originals): array

    {

        $arguments = [...[''], ...array_values(array_filter($originals, function (string $original): bool {

            foreach ([self::COVERAGE_OPTION, self::MIN_OPTION] as $option) {

                if ($original === sprintf('--%s', $option)) {

                    return true;

                }



                if (Str::startsWith($original, sprintf('--%s=', $option))) {

                    return true;

                }

            }



            return false;

        }))];



        $originals = array_flip($originals);

        foreach ($arguments as $argument) {
<?php     private function runTestSuiteInParallel(array $arguments): int

    {

        $handlers = array_filter(

            array_map(fn (string $handler): object|string => Container::getInstance()->get($handler), self::HANDLERS),

            fn (object|string $handler): bool => $handler instanceof HandlesArguments,

        );



        $filteredArguments = array_reduce(

            $handlers,
<?php     private function runWorkerHandlers(array $arguments): array

    {

        $handlers = array_filter(

            array_map(fn (string $handler): object|string => Container::getInstance()->get($handler), self::HANDLERS),

            fn (object|string $handler): bool => $handler instanceof HandlersWorkerArguments,

        );



        return array_reduce(

            $handlers,
<?php             $testResultSum->testTriggeredPhpunitErrorEvents(),

            $testResultSum->testTriggeredPhpunitWarningEvents(),

            $testResultSum->testRunnerTriggeredDeprecationEvents(),

            array_values(array_filter(

                $testResultSum->testRunnerTriggeredWarningEvents(),

                fn (WarningTriggered $event): bool => ! str_contains($event->message(), 'No tests found')

            )),

            $testResultSum->errors(),

            $testResultSum->deprecations(),

            $testResultSum->notices(),
<?php     {


        $files = [

            ...array_values(array_filter(

                $suiteLoader->tests,

                fn (string $filename): bool => ! str_ends_with($filename, "eval()'d code")

            )),

            ...TestSuite::getInstance()->tests->getFilenames(),

        ];
<?php     private static function getScopedDataset(string $name, string $currentTestFile): Closure|iterable

    {

        $matchingDatasets = array_filter(self::$datasets, function (string $key) use ($name, $currentTestFile): bool {

            [$datasetScope, $datasetName] = explode(self::SEPARATOR, $key);



            if ($name !== $datasetName) {

                return false;

            }



            return str_starts_with($currentTestFile, $datasetScope);

        }, ARRAY_FILTER_USE_KEY);



        $closestScopeDatasetKey = array_reduce(

            array_keys($matchingDatasets),
<?php         $testRunnerTriggeredWarningEvents = $property->getValue($collector);



        $testRunnerTriggeredWarningEvents = array_values(array_filter($testRunnerTriggeredWarningEvents, fn (WarningTriggered $event): bool => $event->message() !== 'No tests found in class "Pest\TestCases\IgnorableTestCase".'));



        $property->setValue($collector, $testRunnerTriggeredWarningEvents);

    }
<?php         };



        $array = [];

        foreach (array_filter($file->lineCoverageData(), 'is_array') as $line => $tests) {

            $array = $eachLine($array, $tests, $line);

        }
<?php             $dirtyFiles[substr($dirtyFile, 3)] = trim(substr($dirtyFile, 0, 3));

        }



        $dirtyFiles = array_filter($dirtyFiles, fn (string $status): bool => $status !== 'D');



        $dirtyFiles = array_map(

            fn (string $file, string $status): string => in_array($status, ['R', 'RM'], true)
<?php                 : $file, array_keys($dirtyFiles), $dirtyFiles,

        );



        $dirtyFiles = array_filter(

            $dirtyFiles,

            fn (string $file): bool => str_starts_with('.'.DIRECTORY_SEPARATOR.$file, TestSuite::getInstance()->testPath)

                || str_starts_with($file, TestSuite::getInstance()->testPath)

        );



        $dirtyFiles = array_values($dirtyFiles);