@@ -108,9 +108,9 @@ static public function color($color) {
108
108
* Colorize a string using helpful string formatters. If the `Streams::$out` points to a TTY coloring will be enabled,
109
109
* otherwise disabled. You can control this check with the `$colored` parameter.
110
110
*
111
- * @param string $string
111
+ * @param string $string
112
112
* @param boolean $colored Force enable or disable the colorized output. If left as `null` the TTY will control coloring.
113
- * @return string
113
+ * @return string
114
114
*/
115
115
static public function colorize ($ string , $ colored = null ) {
116
116
$ passed = $ string ;
@@ -146,6 +146,8 @@ static public function colorize($string, $colored = null) {
146
146
* @return string A string with color information removed.
147
147
*/
148
148
static public function decolorize ( $ string , $ keep = 0 ) {
149
+ $ string = (string ) $ string ;
150
+
149
151
if ( ! ( $ keep & 1 ) ) {
150
152
// Get rid of color tokens if they exist
151
153
$ string = str_replace ('%% ' , '%¾ ' , $ string );
@@ -182,7 +184,7 @@ static public function cacheString( $passed, $colorized, $deprecated = null ) {
182
184
* Return the length of the string without color codes.
183
185
*
184
186
* @param string $string the string to measure
185
- * @return int
187
+ * @return int
186
188
*/
187
189
static public function length ($ string ) {
188
190
return safe_strlen ( self ::decolorize ( $ string ) );
@@ -194,7 +196,7 @@ static public function length($string) {
194
196
* @param string $string The string to measure.
195
197
* @param bool $pre_colorized Optional. Set if the string is pre-colorized. Default false.
196
198
* @param string|bool $encoding Optional. The encoding of the string. Default false.
197
- * @return int
199
+ * @return int
198
200
*/
199
201
static public function width ( $ string , $ pre_colorized = false , $ encoding = false ) {
200
202
return strwidth ( $ pre_colorized || self ::shouldColorize () ? self ::decolorize ( $ string , $ pre_colorized ? 1 /*keep_tokens*/ : 0 ) : $ string , $ encoding );
@@ -208,9 +210,11 @@ static public function width( $string, $pre_colorized = false, $encoding = false
208
210
* @param bool $pre_colorized Optional. Set if the string is pre-colorized. Default false.
209
211
* @param string|bool $encoding Optional. The encoding of the string. Default false.
210
212
* @param int $pad_type Optional. Can be STR_PAD_RIGHT, STR_PAD_LEFT, or STR_PAD_BOTH. If pad_type is not specified it is assumed to be STR_PAD_RIGHT.
211
- * @return string
213
+ * @return string
212
214
*/
213
215
static public function pad ( $ string , $ length , $ pre_colorized = false , $ encoding = false , $ pad_type = STR_PAD_RIGHT ) {
216
+ $ string = (string ) $ string ;
217
+
214
218
$ real_length = self ::width ( $ string , $ pre_colorized , $ encoding );
215
219
$ diff = strlen ( $ string ) - $ real_length ;
216
220
$ length += $ diff ;
0 commit comments