original_string: protected static function buildMessage(
          /*# string */ $template,
          array $arguments
      )/*# : string */ {
          // use formatter
          if (self::hasFormatter()) {
              return self::getFormatter()
                      ->formatMessage($template, $arguments);
  
          // default is vsprintf()
          } else {
              // make sure arguments are all strings
              array_walk($arguments, function (&$value) {
                  $value = is_scalar($value) ? (string) $value :
                      substr(print_r($value, true), 0, 50);
              });
  
              // make sure '%s' count in $template is same as size of $arguments
              $count = substr_count($template, '%s');
              $size  = sizeof($arguments);
              if ($count > $size) {
                  $arguments = $arguments + array_fill($size, $count - $size, '');
              } else {
                  $template .= str_repeat(' %s', $size - $count);
              }
              return vsprintf($template, $arguments);
          }
      }
code: protected static function buildMessage(
          /*# string */ $template,
          array $arguments
      )/*# : string */ {
          // use formatter
          if (self::hasFormatter()) {
              return self::getFormatter()
                      ->formatMessage($template, $arguments);
  
          // default is vsprintf()
          } else {
              // make sure arguments are all strings
              array_walk($arguments, function (&$value) {
                  $value = is_scalar($value) ? (string) $value :
                      substr(print_r($value, true), 0, 50);
              });
  
              // make sure '%s' count in $template is same as size of $arguments
              $count = substr_count($template, '%s');
              $size  = sizeof($arguments);
              if ($count > $size) {
                  $arguments = $arguments + array_fill($size, $count - $size, '');
              } else {
                  $template .= str_repeat(' %s', $size - $count);
              }
              return vsprintf($template, $arguments);
          }
      }
code_tokens: protected static function buildMessage ( /*# string */ $ template , array $ arguments ) /*# : string */ { // use formatter if ( self :: hasFormatter ( ) ) { return self :: getFormatter ( ) -> formatMessage ( $ template , $ arguments ) ; // default is vsprintf() } else { // make sure arguments are all strings array_walk ( $ arguments , function ( & $ value ) { $ value = is_scalar ( $ value ) ? ( string ) $ value : substr ( print_r ( $ value , true ) , 0 , 50 ) ; } ) ; // make sure '%s' count in $template is same as size of $arguments $ count = substr_count ( $ template , '%s' ) ; $ size = sizeof ( $ arguments ) ; if ( $ count > $ size ) { $ arguments = $ arguments + array_fill ( $ size , $ count - $ size , '' ) ; } else { $ template .= str_repeat ( ' %s' , $ size - $ count ) ; } return vsprintf ( $ template , $ arguments ) ; } }
docstring: Build message from template and arguments.
  
  - Make sure '%s' matches the arguments provided.
  - Use message formatter if exists
  
  @param  string $template message template
  @param  array $arguments arguments for the template
  @return string
  @access protected
  @static
docstring_tokens: Build message from template and arguments .