Isn't it bad code style if i surround integers with quotes? This is out of D6 systems.module

  $form['admin_theme'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#title' => t('Administration theme'),
    '#description' => t('Choose which theme the administration pages should display in. If you choose "System default" the administration pages will use the same theme as the rest of the site.'),
    '#default_value' => variable_get('admin_theme', '0'),
  );

  $form['node_admin_theme'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use administration theme for content editing'),
    '#description' => t('Use the administration theme when editing existing posts or creating new ones.'),
    '#default_value' => variable_get('node_admin_theme', '0'),
  );

Looks better:

  $form['admin_theme'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#title' => t('Administration theme'),
    '#description' => t('Choose which theme the administration pages should display in. If you choose "System default" the administration pages will use the same theme as the rest of the site.'),
    '#default_value' => variable_get('admin_theme', 0),
  );

  $form['node_admin_theme'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use administration theme for content editing'),
    '#description' => t('Use the administration theme when editing existing posts or creating new ones.'),
    '#default_value' => variable_get('node_admin_theme', 0),
  );

Comments

chx’s picture

Status: Active » Closed (won't fix)
hass’s picture

Status: Closed (won't fix) » Active

why are you not commenting on this code examples?

jody lynn’s picture

Priority: Normal » Minor
jody lynn’s picture

Status: Active » Closed (won't fix)
hass’s picture

Status: Closed (won't fix) » Active

Any comment on the above code style?

jody lynn’s picture

Comment: If it's so important to you, then submit a patch.

hass’s picture

Category: bug » support

I'm not talking about - if there should be a patch or not - it's more about what is faster and correct code.

So changing to support request for now.

ainigma32’s picture

what is faster and correct code

I don't think that there is a big difference in speed in using the one or the other. Both options use the same function, both values get serialized. The option using an integer will use less storage i:1; = 4 + 2 = 6 bytes vs s:1:"1"; = 8 + 2 = 10 bytes but these differences are negligible.

As to what's correct; that is a matter of opinion. Personally I think it doesn't really matter what you choose as long as you do it consistently.

And finally I would like to suggest that these matters are taken care of on IRC or in one of the forums. It seems to me that this is not the correct place to do this ;-)

- Arie

ainigma32’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.