Repository: symfony/symfony
File: src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php (PHP)

Code before:
                    }
                }
            }

            if (null !== $target) {
                return null;
            }
        }

        if ($this->container->has($type) && $this->canDefinitionBeAutowired($this->container->findDefinition($type))) {
            return new TypedReference($type, $type, $reference->getInvalidBehavior());
        }

        if (null !== ($alias = $this->getCombinedAlias($type)) && $this->canDefinitionBeAutowired($this->container->findDefinition($alias))) {
            return new TypedReference($alias, $type, $reference->getInvalidBehavior());
        }

        return null;
    }

    private function canDefinitionBeAutowired(Definition $definition): bool
    {
        return !$definition->isAbstract() && !$definition->hasTag('container.excluded');
    }

    /**
     * Populates the list of available types.
     */
    private function populateAvailableTypes(ContainerBuilder $container): void
    {
        $this->types = [];
        $this->ambiguousServiceTypes = [];
        $this->autowiringAliases = [];

        foreach ($container->getDefinitions() as $id => $definition) {
            $this->populateAvailableType($container, $id, $definition);
        }

        $prev = null;
        foreach ($container->getAliases() as $id => $alias) {
            $this->populateAutowiringAlias($id, $prev);
            $prev = $id;
        }
    }

    /**
     * Populates the list of available types for a given definition.
     */
    private function populateAvailableType(ContainerBuilder $container, string $id, Definition $definition): void
    {
        // Never use abstract services

Review comment (refactor):
Nitpick: you can move the `findDefinition` in the new method.

```suggestion
    private function canDefinitionBeAutowired(string $id): bool
    {
        $definition = $this->container->findDefinition($id);

        return !$definition->isAbstract() && !$definition->hasTag('container.excluded');
    }
```

Code after:
                    }
                }
            }

            if (null !== $target) {
                return null;
            }
        }

        if ($this->container->has($type) && $this->canDefinitionBeAutowired($type)) {
            return new TypedReference($type, $type, $reference->getInvalidBehavior());
        }

        if (null !== ($alias = $this->getCombinedAlias($type)) && $this->canDefinitionBeAutowired($alias)) {
            return new TypedReference($alias, $type, $reference->getInvalidBehavior());
        }

        return null;
    }

    private function canDefinitionBeAutowired(string $id): bool
    {
        $definition = $this->container->findDefinition($id);

        return !$definition->isAbstract() && !$definition->hasTag('container.excluded');
    }

    /**
     * Populates the list of available types.
     */
    private function populateAvailableTypes(ContainerBuilder $container): void
    {
        $this->types = [];
        $this->ambiguousServiceTypes = [];
        $this->autowiringAliases = [];

        foreach ($container->getDefinitions() as $id => $definition) {
            $this->populateAvailableType($container, $id, $definition);
        }

        $prev = null;
        foreach ($container->getAliases() as $id => $alias) {
            $this->populateAutowiringAlias($id, $prev);
            $prev = $id;
        }
    }

    /**
     * Populates the list of available types for a given definition.
     */
    private function populateAvailableType(ContainerBuilder $container, string $id, Definition $definition): void