• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fractalzombie / frzb-dependency-injection / 4355207088

pending completion
4355207088

push

github

Mykhailo Shtanko
[DependencyInjection] Added SonarCloud checks, refactor GitHub actions, refactor for using not only id as class

44 of 50 new or added lines in 9 files covered. (88.0%)

7 existing lines in 5 files now uncovered.

210 of 247 relevant lines covered (85.02%)

4.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.75
/Compiler/RegisterAsIgnoredAttributesPass.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This is package for Symfony framework.
7
 *
8
 * (c) Mykhailo Shtanko <fractalzombie@gmail.com>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13

14
namespace FRZB\Component\DependencyInjection\Compiler;
15

16
use Fp\Collections\ArrayList;
17
use FRZB\Component\DependencyInjection\Attribute\AsAlias;
18
use FRZB\Component\DependencyInjection\Attribute\AsIgnored;
19
use FRZB\Component\DependencyInjection\Attribute\AsService;
20
use FRZB\Component\DependencyInjection\Helper\DefinitionHelper;
21
use FRZB\Component\DependencyInjection\Helper\EnvironmentHelper;
22
use Symfony\Component\DependencyInjection\ContainerBuilder;
23
use Symfony\Component\DependencyInjection\Definition;
24

25
/**
26
 * @internal
27
 *
28
 * Register #[AsAlias] attribute on alias that is autoconfigured
29
 *
30
 * @author Mykhailo Shtanko <fractalzombie@gmail.com>
31
 */
32
final class RegisterAsIgnoredAttributesPass extends AbstractRegisterAttributePass
33
{
34
    public function __construct()
35
    {
36
        parent::__construct(AsIgnored::class);
1✔
37
    }
38

39
    public function register(ContainerBuilder $container, \ReflectionClass $reflectionClass, AsIgnored $attribute): void
40
    {
41
        if (!EnvironmentHelper::isPermittedEnvironment($container, $reflectionClass)) {
1✔
UNCOV
42
            return;
×
43
        }
44

45
        ArrayList::collect(DefinitionHelper::getAttributesFor($reflectionClass, AsService::class))
1✔
46
            ->map(static fn (\ReflectionAttribute $reflectionAttribute) => $reflectionAttribute->newInstance())
1✔
47
            ->filter(static fn (AsService $asService) => $container->hasDefinition(DefinitionHelper::getServiceId($container, $reflectionClass, $asService->id)))
1✔
48
            ->map(static fn (AsService $asService) => DefinitionHelper::getServiceId($container, $reflectionClass, $asService->id))
1✔
49
            ->tap(static fn (string $serviceId) => $container->removeDefinition($serviceId))
1✔
50
        ;
1✔
51

52
        ArrayList::collect(DefinitionHelper::getAttributesFor($reflectionClass, AsAlias::class))
1✔
53
            ->map(static fn (\ReflectionAttribute $reflectionAttribute) => $reflectionAttribute->newInstance())
1✔
54
            ->filter(static fn (AsAlias $asAlias) => $container->hasAlias(DefinitionHelper::getServiceId($container, $reflectionClass, $asAlias->getServiceAlias())))
1✔
55
            ->map(static fn (AsAlias $asAlias) => DefinitionHelper::getServiceId($container, $reflectionClass, $asAlias->service))
1✔
56
            ->tap(static fn (string $serviceId) => $container->removeAlias($serviceId))
1✔
57
        ;
1✔
58
    }
59

60
    protected function accept(Definition $definition): bool
61
    {
62
        return $definition->isAutoconfigured() && $this->isAttributesIgnored($definition);
1✔
63
    }
64
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc