original_string: protected function buildGraphComponents(array $components)
      {
          $graphComponents = array_fill_keys(
              array_column($components, 'class'),
              [
                  'class'        => null,
                  'id'           => null,
                  'type'         => null,
                  'label'        => null,
                  'variant'      => null,
                  'master'       => null,
                  'variants'     => [],
                  'dependencies' => [],
                  'path'         => [],
              ]
          );
  
          // Run through all components
          /** @var array $component */
          foreach ($components as $component) {
              $graphComponents[$componentClass]['class']   = $componentClass = $component['class'];
              $graphComponents[$componentClass]['id']      = $component['name'];
              $graphComponents[$componentClass]['type']    = $component['type'];
              $graphComponents[$componentClass]['label']   = $component['label'] ?: $component['name'];
              $graphComponents[$componentClass]['variant'] = $component['variant'];
              $graphComponents[$componentClass]['path']    = $component['path'];
  
              // Link the component dependencies
              foreach ((new $componentClass)->getDependencies() as $componentDependency) {
                  if (isset($graphComponents[$componentDependency])) {
                      $graphComponents[$componentClass]['dependencies'][$componentDependency] =& $graphComponents[$componentDependency];
                  }
              }
  
              // If this is a variant: Register it with its master component
              if ($component['variant']) {
                  list ($masterClass) = explode('_', $componentClass, 2);
                  $masterClass .= 'Component';
                  if (isset($graphComponents[$masterClass])) {
                      $graphComponents[$componentClass]['master']                 =& $graphComponents[$masterClass];
                      $graphComponents[$masterClass]['variants'][$componentClass] =& $graphComponents[$componentClass];
                  }
              }
          }
  
          return $graphComponents;
      }
code: protected function buildGraphComponents(array $components)
      {
          $graphComponents = array_fill_keys(
              array_column($components, 'class'),
              [
                  'class'        => null,
                  'id'           => null,
                  'type'         => null,
                  'label'        => null,
                  'variant'      => null,
                  'master'       => null,
                  'variants'     => [],
                  'dependencies' => [],
                  'path'         => [],
              ]
          );
  
          // Run through all components
          /** @var array $component */
          foreach ($components as $component) {
              $graphComponents[$componentClass]['class']   = $componentClass = $component['class'];
              $graphComponents[$componentClass]['id']      = $component['name'];
              $graphComponents[$componentClass]['type']    = $component['type'];
              $graphComponents[$componentClass]['label']   = $component['label'] ?: $component['name'];
              $graphComponents[$componentClass]['variant'] = $component['variant'];
              $graphComponents[$componentClass]['path']    = $component['path'];
  
              // Link the component dependencies
              foreach ((new $componentClass)->getDependencies() as $componentDependency) {
                  if (isset($graphComponents[$componentDependency])) {
                      $graphComponents[$componentClass]['dependencies'][$componentDependency] =& $graphComponents[$componentDependency];
                  }
              }
  
              // If this is a variant: Register it with its master component
              if ($component['variant']) {
                  list ($masterClass) = explode('_', $componentClass, 2);
                  $masterClass .= 'Component';
                  if (isset($graphComponents[$masterClass])) {
                      $graphComponents[$componentClass]['master']                 =& $graphComponents[$masterClass];
                      $graphComponents[$masterClass]['variants'][$componentClass] =& $graphComponents[$componentClass];
                  }
              }
          }
  
          return $graphComponents;
      }
code_tokens: protected function buildGraphComponents ( array $ components ) { $ graphComponents = array_fill_keys ( array_column ( $ components , 'class' ) , [ 'class' => null , 'id' => null , 'type' => null , 'label' => null , 'variant' => null , 'master' => null , 'variants' => [ ] , 'dependencies' => [ ] , 'path' => [ ] , ] ) ; // Run through all components /** @var array $component */ foreach ( $ components as $ component ) { $ graphComponents [ $ componentClass ] [ 'class' ] = $ componentClass = $ component [ 'class' ] ; $ graphComponents [ $ componentClass ] [ 'id' ] = $ component [ 'name' ] ; $ graphComponents [ $ componentClass ] [ 'type' ] = $ component [ 'type' ] ; $ graphComponents [ $ componentClass ] [ 'label' ] = $ component [ 'label' ] ? : $ component [ 'name' ] ; $ graphComponents [ $ componentClass ] [ 'variant' ] = $ component [ 'variant' ] ; $ graphComponents [ $ componentClass ] [ 'path' ] = $ component [ 'path' ] ; // Link the component dependencies foreach ( ( new $ componentClass ) -> getDependencies ( ) as $ componentDependency ) { if ( isset ( $ graphComponents [ $ componentDependency ] ) ) { $ graphComponents [ $ componentClass ] [ 'dependencies' ] [ $ componentDependency ] = & $ graphComponents [ $ componentDependency ] ; } } // If this is a variant: Register it with its master component if ( $ component [ 'variant' ] ) { list ( $ masterClass ) = explode ( '_' , $ componentClass , 2 ) ; $ masterClass .= 'Component' ; if ( isset ( $ graphComponents [ $ masterClass ] ) ) { $ graphComponents [ $ componentClass ] [ 'master' ] = & $ graphComponents [ $ masterClass ] ; $ graphComponents [ $ masterClass ] [ 'variants' ] [ $ componentClass ] = & $ graphComponents [ $ componentClass ] ; } } } return $ graphComponents ; }
docstring: Prepare the list of graph components
  
  @param array $components Components
  
  @return array Graph components
docstring_tokens: Prepare the list of graph components