| Conditions | 5 |
| Paths | 10 |
| Total Lines | 27 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 13 | public function expand($values) { |
||
| 14 | $result = array(); |
||
| 15 | $entity_type = $this->fieldInfo['settings']['target_type']; |
||
| 16 | $entity_info = entity_get_info($entity_type); |
||
| 17 | // For users set label to username. |
||
| 18 | if ($entity_type == 'user') { |
||
| 19 | $entity_info['entity keys']['label'] = 'name'; |
||
| 20 | } |
||
| 21 | |||
| 22 | foreach ($values as $value) { |
||
| 23 | $query = db_select($entity_info['base table'], 't') |
||
| 24 | ->fields('t', array($entity_info['entity keys']['id'])); |
||
| 25 | if (is_numeric($value)) { |
||
| 26 | $query->condition('t.' . $entity_info['entity keys']['id'], $value); |
||
| 27 | } |
||
| 28 | else { |
||
| 29 | $query->condition('t.' . $entity_info['entity keys']['label'], $value); |
||
| 30 | } |
||
| 31 | $str_query = (string) $query; |
||
|
|
|||
| 32 | $str_arguments = print_r($query->getArguments(), TRUE); |
||
| 33 | $target_id = $query->execute()->fetchField(); |
||
| 34 | if ($target_id) { |
||
| 35 | $result[$this->language][] = array('target_id' => $target_id); |
||
| 36 | } |
||
| 37 | } |
||
| 38 | return $result; |
||
| 39 | } |
||
| 40 | |||
| 42 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.