original_string: private function generateForeignKey($table)
      {
          if (empty($table->foreignKeys)) {
              return;
          }
          $definition = "// fk: $table->name\n";
  
          foreach ($table->foreignKeys as $fk) {
              $refTable = '';
              $refColumns = '';
              $columns = '';
  
              foreach ($fk as $k => $v) {
                  if (0 === $k) {
                      $refTable = $v;
                  } else {
                      $columns = $k;
                      $refColumns = $v;
                  }
              }
              $definition .= sprintf("\$this->addForeignKey('%s', '{{%%%s}}', '%s', '{{%%%s}}', '%s');\n",
                  'fk_'.$table->name.'_'.$columns, $table->name, $columns, $refTable, $refColumns);
          }
          return "$definition\n";
      }
code: private function generateForeignKey($table)
      {
          if (empty($table->foreignKeys)) {
              return;
          }
          $definition = "// fk: $table->name\n";
  
          foreach ($table->foreignKeys as $fk) {
              $refTable = '';
              $refColumns = '';
              $columns = '';
  
              foreach ($fk as $k => $v) {
                  if (0 === $k) {
                      $refTable = $v;
                  } else {
                      $columns = $k;
                      $refColumns = $v;
                  }
              }
              $definition .= sprintf("\$this->addForeignKey('%s', '{{%%%s}}', '%s', '{{%%%s}}', '%s');\n",
                  'fk_'.$table->name.'_'.$columns, $table->name, $columns, $refTable, $refColumns);
          }
          return "$definition\n";
      }
code_tokens: private function generateForeignKey ( $ table ) { if ( empty ( $ table -> foreignKeys ) ) { return ; } $ definition = "// fk: $table->name\n" ; foreach ( $ table -> foreignKeys as $ fk ) { $ refTable = '' ; $ refColumns = '' ; $ columns = '' ; foreach ( $ fk as $ k => $ v ) { if ( 0 === $ k ) { $ refTable = $ v ; } else { $ columns = $ k ; $ refColumns = $ v ; } } $ definition .= sprintf ( "\$this->addForeignKey('%s', '{{%%%s}}', '%s', '{{%%%s}}', '%s');\n" , 'fk_' . $ table -> name . '_' . $ columns , $ table -> name , $ columns , $ refTable , $ refColumns ) ; } return "$definition\n" ; }
docstring: Returns the foreign key definition.
  @param TableSchema[] $table
  @return string|null foreign key definition or null
docstring_tokens: Returns the foreign key definition .