Of course your service is an instance of YamlFileLoader
because you configured this in the class
attribute. The return value of the methods calls
doesn't influence the instance type. You have to call the method in php, if you want to get the return value.
# config.yml
file_locator:
class: Symfony\Component\Config\FileLocator
arguments: ['%app_root%/app/config']
yaml_file_loader:
class: Symfony\Component\Routing\Loader\YamlFileLoader
arguments: ["@file_locator"]
#app.php
$routes_collection = $container->get('yaml_file_loader')->load('routes.yml');