@@ -108,9 +108,9 @@ static public function color($color) {
108108 * Colorize a string using helpful string formatters. If the `Streams::$out` points to a TTY coloring will be enabled,
109109 * otherwise disabled. You can control this check with the `$colored` parameter.
110110 *
111- * @param string $string
111+ * @param string $string
112112 * @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
114114 */
115115 static public function colorize ($ string , $ colored = null ) {
116116 $ passed = $ string ;
@@ -146,6 +146,8 @@ static public function colorize($string, $colored = null) {
146146 * @return string A string with color information removed.
147147 */
148148 static public function decolorize ( $ string , $ keep = 0 ) {
149+ $ string = (string ) $ string ;
150+
149151 if ( ! ( $ keep & 1 ) ) {
150152 // Get rid of color tokens if they exist
151153 $ string = str_replace ('%% ' , '%¾ ' , $ string );
@@ -182,7 +184,7 @@ static public function cacheString( $passed, $colorized, $deprecated = null ) {
182184 * Return the length of the string without color codes.
183185 *
184186 * @param string $string the string to measure
185- * @return int
187+ * @return int
186188 */
187189 static public function length ($ string ) {
188190 return safe_strlen ( self ::decolorize ( $ string ) );
@@ -194,7 +196,7 @@ static public function length($string) {
194196 * @param string $string The string to measure.
195197 * @param bool $pre_colorized Optional. Set if the string is pre-colorized. Default false.
196198 * @param string|bool $encoding Optional. The encoding of the string. Default false.
197- * @return int
199+ * @return int
198200 */
199201 static public function width ( $ string , $ pre_colorized = false , $ encoding = false ) {
200202 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
208210 * @param bool $pre_colorized Optional. Set if the string is pre-colorized. Default false.
209211 * @param string|bool $encoding Optional. The encoding of the string. Default false.
210212 * @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
212214 */
213215 static public function pad ( $ string , $ length , $ pre_colorized = false , $ encoding = false , $ pad_type = STR_PAD_RIGHT ) {
216+ $ string = (string ) $ string ;
217+
214218 $ real_length = self ::width ( $ string , $ pre_colorized , $ encoding );
215219 $ diff = strlen ( $ string ) - $ real_length ;
216220 $ length += $ diff ;
0 commit comments