private function dumpMethodParameters($className, MethodInjection $methodInjection)
 {
     $methodReflection = new \ReflectionMethod($className, $methodInjection->getMethodName());
     $args = [];
     $definitionParameters = $methodInjection->getParameters();
     foreach ($methodReflection->getParameters() as $index => $parameter) {
         if (array_key_exists($index, $definitionParameters)) {
             $value = $definitionParameters[$index];
             if ($value instanceof EntryReference) {
                 $args[] = sprintf('$%s = get(%s)', $parameter->getName(), $value->getName());
             } else {
                 $args[] = sprintf('$%s = %s', $parameter->getName(), var_export($value, true));
             }
             continue;
         }
         // If the parameter is optional and wasn't specified, we take its default value
         if ($parameter->isOptional()) {
             try {
                 $value = $parameter->getDefaultValue();
                 $args[] = sprintf('$%s = (default value) %s', $parameter->getName(), var_export($value, true));
                 continue;
             } catch (ReflectionException $e) {
                 // The default value can't be read through Reflection because it is a PHP internal class
             }
         }
         $args[] = sprintf('$%s = #UNDEFINED#', $parameter->getName());
     }
     return implode(PHP_EOL . '        ', $args);
 }
Exemple #2
0
 /**
  * @param MethodInjection $methodInjection
  */
 public function addMethodInjection(MethodInjection $methodInjection)
 {
     $method = $methodInjection->getMethodName();
     if (!isset($this->methodInjections[$method])) {
         $this->methodInjections[$method] = [];
     }
     $this->methodInjections[$method][] = $methodInjection;
 }