[drupal-devel] Use more constants?

Gabor Hojtsy gabor at hojtsy.hu
Sun Jul 24 20:23:54 UTC 2005


> Busy doing some menu things, and I was wondering why we are using 
> strings for the properties, when constants would be more readable imo.
> 
>  $items[] = array('path' => 'admin/display/regions/configure',  'title'
> => t('configure block'),
>       'access' => user_access('administer blocks'),
>       'callback' => 'block_admin_configure',
>       'type' => MENU_CALLBACK
> );
> 
> versus
> 
>  $items[] = array( path => 'admin/display/regions/configure', title  =>
> t('configure block'),
>       access => user_access('administer blocks'),
>       callback => 'block_admin_configure',
>       type => MENU_CALLBACK
> );
> 
> The only place I see it being impossible to use constants would be 
> 'callback arguments' , and imo ..
> arguments => array(1, 2, 3)
> is far more readable than :
> 'callback arguments' => array(1, 2, 3)
> 
> I'm not trying to champion a cause or anything, I was just wondering 
> what the reasoning behind it was.

Constants are uppercase by practice, and using lowercase constants look
like we are doing some buggy practice of not quoting our strings. I
guess this might be the reason.

Goba



More information about the drupal-devel mailing list