Create the parameter name in steps

This patch does not change any existing functionality.  It only
extracts the logic for creating the name of each parameter out of the
sprintf() call and into individual steps before calling sprintf().
This will let us more easily add or modifying parameter names based on
other information, such as optional parameters, default values, etc.
Wrap optional parameters in square braces

This follows the convention of the PHP manual itself, which places
optional parameters in square braces.