Issues (200)

src/Command/CommandEnumerator.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * This file is part of the sj-i/php-profiler package.
5
 *
6
 * (c) sji <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace PhpProfiler\Command;
15
16
use FilesystemIterator;
17
use IteratorAggregate;
18
use SplFileInfo;
19
use Symfony\Component\Console\Command\Command;
0 ignored issues
show
The type Symfony\Component\Console\Command\Command was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
21
/** @implements IteratorAggregate<class-string<Command>> */
22
final class CommandEnumerator implements IteratorAggregate
23
{
24
    public function __construct(
25
        private FilesystemIterator $command_files_iterator
26
    ) {
27
    }
28
29
    /** @return \Generator<class-string<Command>> */
30
    public function getIterator()
31
    {
32
        /** @var SplFileInfo $command_file_info */
33
        foreach ($this->command_files_iterator as $command_file_info) {
34
            $class_name = $command_file_info->getBasename('.php');
35
            $namespace = $command_file_info->getPathInfo()->getFilename();
36
            $result = "PhpProfiler\\Command\\{$namespace}\\$class_name";
37
            assert(is_subclass_of($result, Command::class));
38
            yield $result;
39
        }
40
    }
41
}
42