Drupal utilizes the Symfony service container, however some features such as autowiring and autoconfiguration were not leveraged in Drupal 8.
Services can be autowired, and Drupal core now includes tests for this functionality. This means that when defining a service in *.services.yml, in many cases the arguments can be automatically inferred from the typehints on constructor arguments. Service definitions must contain autowire: true to enable autowiring. (Enabling autowiring by default for all services in a file is not yet supported.)
The service will be instantiated in exactly the same way as before, but there is no need to explicitly specify which services are required; the interfaces that are declared in the service constructor will be used to discover which services should be injected.
While Drupal's container builder/Yaml services file parser now supports autowiring, this pattern is not yet implemented in core. As Drupal's current service naming convention uses strings and not class names for service IDs, site developers will not immediately be able to autowire services from core. A follow-up issue exists to add a backwards-compatibility layer of service aliases for existing core service interfaces.
In cases where there is more than one service that applies to an interface, for example cache backends, we cannot add an alias as we do not know which of the services should be wired. In this case we can specify the required service only. For example:
token:
class: Drupal\Core\Utility\Token
autowire: true
arguments:
$cache: '@cache.default'
Here, the $cache argument is a \Drupal\Core\Cache\CacheBackendInterface service, but we have many of these - so we specify exactly which cache is required for this service. The other dependencies of this service can still be automatically inferred.
For more information please see the Symfony autowiring documentation: https://symfony.com/doc/current/service_container/autowiring.html