Repository: symfony/symfony
File: src/Symfony/Component/Finder/Tests/FinderTest.php (PHP)

Code before:
        $finder1 = $this->buildFinder();
        $finder1->files()->in(self::$tmpDir.\DIRECTORY_SEPARATOR.'foo');

        $finder2 = $this->buildFinder();
        $finder2->directories()->in(self::$tmpDir);

        $finder1->append($finder2);
        $finder1->append($this->toAbsolute(['foo']));
        $finder1->append(array_map(fn (string $item): \SplFileInfo => new \SplFileInfo($item), $this->toAbsolute(['toto'])));

        foreach ($finder1 as $item) {
            $this->assertInstanceOf(SplFileInfo::class, $item);
        }
    }

    public function testRelativePathOfAppendedItems()
    {
        $finder1 = $this->buildFinder();
        $finder1->files()->in(self::$tmpDir.\DIRECTORY_SEPARATOR.'foo');

        $finder2 = $this->buildFinder();
        $finder2->directories()->in(self::$tmpDir);

        $finder1->append($finder2);
        $finder1->append($this->toAbsolute(['foo']));
        $finder1->append(array_map(fn (string $item): \SplFileInfo => new \SplFileInfo($item), $this->toAbsolute(['toto'])));

        $this->assertSame(
            [
                // $finder1's ->in()
                self::$tmpDir . '/foo/bar.tmp' => 'bar.tmp',
                // $finder2's ->in()
                self::$tmpDir . '/qux' => 'qux',
                // new \SplFileInfo('toto')
                self::$tmpDir . '/toto' => self::$tmpDir . '/toto',
                // 'foo'
                self::$tmpDir . '/foo' => self::$tmpDir . '/foo',
            ],
            array_map(
                fn (SplFileInfo $item) => $item->getRelativePathname(),
                iterator_to_array($finder1),
            ),
        );

        $finder3 = $this->buildFinder();
        $finder3->append($this->toAbsolute(['foo']));
        $this->assertSame(
            [
                self::$tmpDir . '/foo' =>  self::$tmpDir . '/foo'
            ],
            array_map(

Review comment (suggestion):
```suggestion
        $finder1->append(array_map(static fn ($item) => new \SplFileInfo($item), $this->toAbsolute(['toto'])));
```

Code after:
        $finder1 = $this->buildFinder();
        $finder1->files()->in(self::$tmpDir.\DIRECTORY_SEPARATOR.'foo');

        $finder2 = $this->buildFinder();
        $finder2->directories()->in(self::$tmpDir);

        $finder1->append($finder2);
        $finder1->append($this->toAbsolute(['foo']));
        $finder1->append(array_map(static fn ($item) => new \SplFileInfo($item), $this->toAbsolute(['toto'])));

        foreach ($finder1 as $item) {
            $this->assertInstanceOf(SplFileInfo::class, $item);
        }
    }

    public function testRelativePathOfAppendedItems()
    {
        $this->setupVfsProvider([
            'a' => [
                'a1' => '',
                'a2' => '',
                'b' => [
                    'b1' => '',
                    'b2' => '',
                    'c' => [
                        'c1' => '',
                        'c2' => '',
                    ],
                ],
            ],
        ]);

        $formatForAssert = static function (Finder $finder) {
            $data = [];
            foreach ($finder as $key => $value) {
                $data[] = ['key' => $key, 'relativePathname' => $value->getRelativePathname()];
            }

            return $data;
        };

        $dir = $this->vfsScheme.'://';

        // no append
        $finder = Finder::create()->sortByName()->in($dir.'a/b');
        $this->assertSame(
            [
                ['key' => $dir.'a/b/b1', 'relativePathname' => 'b1'],
                ['key' => $dir.'a/b/b2', 'relativePathname' => 'b2'],
                ['key' => $dir.'a/b/c', 'relativePathname' => 'c'],
                ['key' => $dir.'a/b/c/c1', 'relativePathname' => 'c/c1'],