• 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

88.89
/Compiler/RegisterAsDeprecatedAttributesPass.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\AsDeprecated;
18
use FRZB\Component\DependencyInjection\Attribute\AsService;
19
use FRZB\Component\DependencyInjection\Helper\DefinitionHelper;
20
use FRZB\Component\DependencyInjection\Helper\EnvironmentHelper;
21
use Symfony\Component\DependencyInjection\ContainerBuilder;
22
use Symfony\Component\DependencyInjection\Definition;
23

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

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

44
        ArrayList::collect($reflectionClass->getAttributes(AsService::class, \ReflectionAttribute::IS_INSTANCEOF))
2✔
45
            ->map(static fn (\ReflectionAttribute $reflectionAttribute) => $reflectionAttribute->newInstance())
2✔
46
            ->map(static fn (AsService $asService) => $container->getDefinition(DefinitionHelper::getServiceId($container, $reflectionClass, $asService->id)))
2✔
47
            ->appended($container->getDefinition($reflectionClass->getName()))
2✔
48
            ->tap(static fn (Definition $definition) => $definition->setDeprecated($attribute->package, $attribute->version, $attribute->message))
2✔
49
        ;
2✔
50
    }
51
}
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