title: How handle router with container's services/parameters dynamically?
body: <p>I've used the Symfony route bundle and DI bundle in my non Symfony project.
  I inject dependencies to the controllers/actions by the code below:</p>
  <pre><code>    // Find the current route
      $parameters = $router-&gt;match($requestContext-&gt;getPathInfo());
  
      $parts = explode(':', $parameters['_controller']);
  
      $controller = $parts[0];
      $action = $parts[2];
  
      $arguments = array();
      $reflectionMethod = new ReflectionMethod($controller, $action);
      foreach( $reflectionMethod-&gt;getParameters() as $arg ) {
      if( isset($parameters[$arg-&gt;name]) ) {
          $arguments[$arg-&gt;name] = $parameters[$arg-&gt;name];
      }
      else if( $arg-&gt;isDefaultValueAvailable() ) {
          $arguments[$arg-&gt;name] = $arg-&gt;getDefaultValue();
      }
      else {
          echo $arg-&gt;getType();
          $arguments[$arg-&gt;name] = null;
      }
  }
  
  call_user_func_array( array($controller, $action) , $arguments );
  </code></pre>
  <p>My problem is that the code just finds the name of the arguments and not the classes. My question is how should I connect the founded argument to the registered service in the container based on the class type? and another problem is how can I realize if the argument is matched with a container's parameter(which is a class object)?</p>