Searching files in filesystem with Finder

Code
<?php

use Symfony\Component\Finder\Finder;

$rootDir = __DIR__;

/**
 * searching in filesystem with Finder
 */
$finder = new Finder();

$finder->files()
    ->in($rootDir) // dir path string
    ->name('*.php')
    ->sortByName();

echo '<b>Find all php files in dir:</b>' . PHP_EOL;
foreach($finder as $file) {
    echo $file->getFileName() . PHP_EOL;
}

$finder->contains('dump');

echo '<b>Find php files containing "dump":</b>' . PHP_EOL;
foreach($finder as $file) {
    echo $file->getFileName() . PHP_EOL;
}
Result
Find all php files in dir:
Library.php
Finder.php
Foo.php
Find php files containing "dump":
Library.php
Foo.php
Used Versions
PHP 8.3, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8