original_string: protected function validateDependency(&$item, $items, $enabled = false)
      {
          if (empty($item['dependencies'])) {
              return null;
          }
  
          foreach ($item['dependencies'] as $id => $version) {
  
              if (!isset($items[$id])) {
                  $item['errors'][] = array('Unknown dependency @id', array('@id' => $id));
                  continue;
              }
  
              if ($enabled && empty($items[$id]['status'])) {
                  $item['errors'][] = array('Requires @id to be enabled', array('@id' => $items[$id]['name']));
                  continue;
              }
  
              $components = $this->getVersionComponents($version);
  
              if (empty($components)) {
                  $item['errors'][] = array('Unknown version of @name', array('@name' => $id));
                  continue;
              }
  
              list($operator, $number) = $components;
  
              if ($operator === '=' && strpos($number, 'x') !== false) {
                  $allowed = version_compare($items[$id]['version'], $number);
              } else {
                  $allowed = version_compare($items[$id]['version'], $number, $operator);
              }
  
              if (!$allowed) {
                  $item['errors'][] = array('Requires incompatible version of @name', array('@name' => $id));
              }
          }
  
          return null;
      }
code: protected function validateDependency(&$item, $items, $enabled = false)
      {
          if (empty($item['dependencies'])) {
              return null;
          }
  
          foreach ($item['dependencies'] as $id => $version) {
  
              if (!isset($items[$id])) {
                  $item['errors'][] = array('Unknown dependency @id', array('@id' => $id));
                  continue;
              }
  
              if ($enabled && empty($items[$id]['status'])) {
                  $item['errors'][] = array('Requires @id to be enabled', array('@id' => $items[$id]['name']));
                  continue;
              }
  
              $components = $this->getVersionComponents($version);
  
              if (empty($components)) {
                  $item['errors'][] = array('Unknown version of @name', array('@name' => $id));
                  continue;
              }
  
              list($operator, $number) = $components;
  
              if ($operator === '=' && strpos($number, 'x') !== false) {
                  $allowed = version_compare($items[$id]['version'], $number);
              } else {
                  $allowed = version_compare($items[$id]['version'], $number, $operator);
              }
  
              if (!$allowed) {
                  $item['errors'][] = array('Requires incompatible version of @name', array('@name' => $id));
              }
          }
  
          return null;
      }
code_tokens: protected function validateDependency ( & $ item , $ items , $ enabled = false ) { if ( empty ( $ item [ 'dependencies' ] ) ) { return null ; } foreach ( $ item [ 'dependencies' ] as $ id => $ version ) { if ( ! isset ( $ items [ $ id ] ) ) { $ item [ 'errors' ] [ ] = array ( 'Unknown dependency @id' , array ( '@id' => $ id ) ) ; continue ; } if ( $ enabled && empty ( $ items [ $ id ] [ 'status' ] ) ) { $ item [ 'errors' ] [ ] = array ( 'Requires @id to be enabled' , array ( '@id' => $ items [ $ id ] [ 'name' ] ) ) ; continue ; } $ components = $ this -> getVersionComponents ( $ version ) ; if ( empty ( $ components ) ) { $ item [ 'errors' ] [ ] = array ( 'Unknown version of @name' , array ( '@name' => $ id ) ) ; continue ; } list ( $ operator , $ number ) = $ components ; if ( $ operator === '=' && strpos ( $ number , 'x' ) !== false ) { $ allowed = version_compare ( $ items [ $ id ] [ 'version' ] , $ number ) ; } else { $ allowed = version_compare ( $ items [ $ id ] [ 'version' ] , $ number , $ operator ) ; } if ( ! $ allowed ) { $ item [ 'errors' ] [ ] = array ( 'Requires incompatible version of @name' , array ( '@name' => $ id ) ) ; } } return null ; }
docstring: Validates dependency for a single item
  @param array $item
  @param array $items
  @param bool $enabled
  @return null
docstring_tokens: Validates dependency for a single item