hasResults example

public function testCountWithoutIn()
    {
        $this->expectException(\LogicException::class);
        $finder = Finder::create()->files();
        \count($finder);
    }

    public function testHasResults()
    {
        $finder = $this->buildFinder();
        $finder->in(__DIR__);
        $this->assertTrue($finder->hasResults());
    }

    public function testNoResults()
    {
        $finder = $this->buildFinder();
        $finder->in(__DIR__)->name('DoesNotExist');
        $this->assertFalse($finder->hasResults());
    }

    /** * @dataProvider getContainsTestData */
if ($this->clusterMode) {
            // In cluster mode we can't delete caches on the filesystem             // because this only runs on one node in the cluster             return;
        }

        $finder = (new Finder())
            ->directories()
            ->name($this->environment . '*')
            ->in(\dirname($this->cacheDir) . '/');

        if (!$finder->hasResults()) {
            return;
        }

        $remove = [];
        foreach ($finder->getIterator() as $directory) {
            if ($directory->getPathname() !== $this->cacheDir) {
                $remove[] = $directory->getPathname();
            }
        }

        if ($remove !== []) {
            
$tempFileExtension = 'sw_bak';
        $tempFileName = sprintf('%s_%s.%s', $diruniqid()$tempFileExtension);

        // Move the existing cache to a temporary new location prior to deletion, so it won't be written to in the meantime         $fileSystem->rename($dir$tempFileName);

        $finder->directories()
            ->in(\dirname($dir, 1))
            ->name(sprintf('*.%s', $tempFileExtension));

        if ($finder->hasResults()) {
            $fileSystem->remove($finder);
        }
    }
}
return $errors;
    }

    /** * @return list<string> */
    private function getUnreleasedChangelogFiles(): array
    {
        $entries = [];
        $finder = new Finder();
        $finder->in($this->getUnreleasedDir())->files()->sortByName()->depth('0')->name('*.md');
        if ($finder->hasResults()) {
            foreach ($finder as $file) {
                $entries[] = (string) $file->getRealPath();
            }
        }

        return $entries;
    }
}


    /** * Prepare the list of changelog files which need to process */
    protected function prepareChangelogFiles(?string $version = null, bool $includeFeatureFlags = false): ChangelogFileCollection
    {
        $entries = new ChangelogFileCollection();

        $finder = new Finder();
        $finder->in($version ? $this->getTargetReleaseDir($version) : $this->getUnreleasedDir())->files()->sortByName()->depth('0')->name('*.md');
        if ($finder->hasResults()) {
            foreach ($finder as $file) {
                $definition = $this->parser->parse($file->getContents());

                $issues = $this->validator->validate($definition);
                if ($issues->count()) {
                    $messages = \array_map(static fn (ConstraintViolationInterface $violation) => $violation->getMessage(), \iterator_to_array($issues));

                    throw new \InvalidArgumentException(\sprintf('Invalid file at path: %s, errors: %s', $file->getRealPath(), \implode(', ', $messages)));
                }

                $featureFlagDefaultOn = false;

                
Home | Imprint | This part of the site doesn't use cookies.