Issues (56)

Command/GetScopesCommand.php (4 issues)

Labels
Severity
1
<?php
2
/**
3
 * @author    oliverde8<[email protected]>
4
 * @category  @category  oliverde8/ComfyBundle
5
 */
6
7
namespace oliverde8\ComfyBundle\Command;
8
9
use oliverde8\ComfyBundle\Resolver\ScopeResolverInterface;
10
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...
11
use Symfony\Component\Console\Input\InputInterface;
0 ignored issues
show
The type Symfony\Component\Console\Input\InputInterface 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...
12
use Symfony\Component\Console\Output\OutputInterface;
0 ignored issues
show
The type Symfony\Component\Console\Output\OutputInterface 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...
13
use Symfony\Component\Console\Style\SymfonyStyle;
0 ignored issues
show
The type Symfony\Component\Console\Style\SymfonyStyle 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...
14
15
class GetScopesCommand extends Command
16
{
17
    /** @var ScopeResolverInterface */
18
    protected $scopeResolver;
19
20
    /**
21
     * GetScopesCommand constructor.
22
     * @param ScopeResolverInterface $scopeResolver
23
     */
24
    public function __construct(ScopeResolverInterface $scopeResolver)
25
    {
26
        parent::__construct();
27
28
        $this->scopeResolver = $scopeResolver;
29
    }
30
31
32
    protected function configure(): void
33
    {
34
        parent::configure();
35
        $this->setName("comfy:scope:list");
36
    }
37
38
    protected function execute(InputInterface $input, OutputInterface $output)
39
    {
40
        $sfs = new SymfonyStyle($input, $output);
41
42
        $lines = [];
43
        $this->getLinesRecursively($lines, $this->scopeResolver->getScopeTree());
44
        $sfs->table(["code", "name"], $lines);
45
46
        return self::SUCCESS;
47
    }
48
49
    private function getLinesRecursively(&$lines, $scopes, $depth = -1, $previousScopeCode = "")
50
    {
51
         foreach ($scopes as $scopeCode => $scopeName) {
52
             if ($scopeCode == "~name") {
53
                 $lines[] = [str_repeat("    ", $depth) . "- " . $previousScopeCode, $scopes["~name"]];
54
             } else {
55
                 $this->getLinesRecursively($lines, $scopeName, $depth + 1, $scopeCode);
56
             }
57
         }
58
    }
59
}
60