public function testMergeConfigList()
 {
     /*
      * When a configuration is comprised solely of integer ids, then it
      * is a list, and we should let the child have precedence
      */
     $result = ServiceBuilderUtil::mergeConfig(array(1, 2, 3, 4, 5, 6), array('a', 'b', 'c'));
     $this->assertEquals(array('a', 'b', 'c'), $result);
 }
 /**
  * Apply any extension on services
  * @param string $serviceName
  * @param array $serviceConfig
  * @param string $prefix
  * @throws NoSuchServiceException
  * @return array
  */
 protected function applyServiceExtension($serviceName, array $serviceConfig, $prefix)
 {
     $config = null;
     /*
      * Look for any fully prefixed service to extend first
      */
     if (strlen($prefix) > 0) {
         if (array_key_exists($prefix . '.' . $serviceName, $serviceConfig)) {
             $config = $serviceConfig[$prefix . '.' . $serviceName];
         }
     }
     /*
      * If we are at this point the service must exist unprefixed
      */
     if (null === $config) {
         if (array_key_exists($serviceName, $serviceConfig)) {
             $config = $serviceConfig[$serviceName];
         } else {
             throw new NoSuchServiceException('Unable to find serviceName: ' . $serviceName);
         }
     }
     /*
      * Apply any configuration from a parent, doing so recursively
      * and ensuring that the child overrides the parent
      */
     if (isset($config['extends'])) {
         $parentService = $config['extends'];
         unset($config['extends']);
         $parentConfig = $this->applyServiceExtension($parentService, $serviceConfig, $prefix);
         $config = ServiceBuilderUtil::mergeConfig($parentConfig, $config);
     }
     return $config;
 }
 /**
  * Get the configuration that would be used to instantiate a service
  * but without doing any actual instantiations
  *
  * @param string $serviceName
  * @param array|null $instanceParams
  * @throws NoSuchServiceException
  * @return array
  */
 public function getConfig($serviceName, $instanceParams = null)
 {
     if (!isset($this->serviceConfig[$serviceName])) {
         throw new NoSuchServiceException('No such service: ' . $serviceName);
     }
     $config = $this->serviceConfig[$serviceName];
     /*
      * Safely get and alter some parameters to use in instantiating
      */
     if (isset($config['params'])) {
         $params = $config['params'];
     } else {
         $params = array();
     }
     /*
      * Apply overrides passed at the time of instantiation
      */
     if (is_array($instanceParams)) {
         $params = ServiceBuilderUtil::mergeConfig($params, $instanceParams);
     }
     $config['params'] = $params;
     return $config;
 }