protected function initContext($context)
    {
        foreach ($context as $key => &$value) {
            switch (gettype($value)) {
                case 'string':
                case 'integer':
                case 'double':
                    // These types require no conversion
                    break;
                case 'array':
                case 'boolean':
                    $value = json_encode($value);
                    break;
                case 'object':
                    if (method_exists($value, '__toString')) {
                        $value = (string)$value;
                    } else {
                        $value = '[object (' . get_class($value) . ')]';
                    }
                    break;
                case 'NULL':
                    $value = 'NULL';
                    break;
                default:
                    $value = '[' . gettype($value) . ']';
                    break;
            }
        }

        return $context;
    }
protected function initContext($context)
    {
        foreach ($context as $key => &$value) {
            switch (gettype($value)) {
                case 'string':
                case 'integer':
                case 'double':
                    // These types require no conversion
                    break;
                case 'array':
                case 'boolean':
                    $value = json_encode($value);
                    break;
                case 'object':
                    if (method_exists($value, '__toString')) {
                        $value = (string)$value;
                    } else {
                        $value = '[object (' . get_class($value) . ')]';
                    }
                    break;
                case 'NULL':
                    $value = 'NULL';
                    break;
                default:
                    $value = '[' . gettype($value) . ']';
                    break;
            }
        }

        return $context;
    }
protected function initContext ( $ context ) { foreach ( $ context as $ key => & $ value ) { switch ( gettype ( $ value ) ) { case 'string' : case 'integer' : case 'double' : // These types require no conversion break ; case 'array' : case 'boolean' : $ value = json_encode ( $ value ) ; break ; case 'object' : if ( method_exists ( $ value , '__toString' ) ) { $ value = ( string ) $ value ; } else { $ value = '[object (' . get_class ( $ value ) . ')]' ; } break ; case 'NULL' : $ value = 'NULL' ; break ; default : $ value = '[' . gettype ( $ value ) . ']' ; break ; } } return $ context ; }
Initializes context array, ensuring all values are string-safe

@param array $context
@return array
Initializes context array ensuring all values are string - safe