You are here

function test1 in Coder 8.2

Same name in this branch
  1. 8.2 coder_sniffer/DrupalPractice/Test/good/good.php \test1()
  2. 8.2 coder_sniffer/Drupal/Test/Commenting/DocCommentStarUnitTest.inc \test1()
  3. 8.2 coder_sniffer/Drupal/Test/Commenting/FunctionCommentUnitTest.inc \test1()
  4. 8.2 coder_sniffer/Drupal/Test/bad/bad.php \test1()
  5. 8.2 coder_sniffer/Drupal/Test/good/good.php \test1()
Same name and namespace in other branches
  1. 8.3 tests/DrupalPractice/good/good.php \test1()
  2. 8.3 tests/Drupal/Commenting/DocCommentStarUnitTest.inc \test1()
  3. 8.3 tests/Drupal/Commenting/FunctionCommentUnitTest.inc \test1()
  4. 8.3 tests/Drupal/bad/bad.php \test1()
  5. 7.2 coder_sniffer/Test/bad/bad.php \test1()
  6. 7.2 coder_sniffer/Test/good/good.php \test1()
  7. 8.3.x tests/DrupalPractice/good/good.php \test1()
  8. 8.3.x tests/Drupal/Commenting/DocCommentStarUnitTest.inc \test1()
  9. 8.3.x tests/Drupal/Commenting/FunctionCommentUnitTest.inc \test1()
  10. 8.3.x tests/Drupal/bad/bad.php \test1()

Ignoring the array value in a foreach loop is OK.

File

coder_sniffer/DrupalPractice/Test/good/good.php, line 28

Code

function test1() {
  $array = array(
    1,
    2,
  );
  foreach ($array as $key => $value) {
    print $key;
  }
  try {
    print 'foo';
  } catch (Exception $e) {

    // $e is unused here, which is fine.
    print 'error';
  }

  // Initializing an array on the fly is allowed.
  $items['foo'] = 'bar';
  return $items;
}