Remove unnecessary explicit calls to __toString()
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 25 Jun 2015 21:51:02 +0000 (23:51 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 25 Jun 2015 21:59:31 +0000 (23:59 +0200)
These are a left over from PHP 5.0 / 5.1 times when __toString()
only was called within echo or print.

wcfsetup/install/files/lib/data/tag/Tag.class.php
wcfsetup/install/files/lib/util/StringUtil.class.php

index a1094c5ec27fc12ed9b05aefdb181496caf6ec47..d2b5d2a9b24261581b781f85a34f71310226b6f0 100644 (file)
@@ -65,13 +65,8 @@ class Tag extends DatabaseObject implements IRouteController {
         * @return      string
         */
        public static function buildString(array $tags, $separator = ', ') {
-               $string = '';
-               foreach ($tags as $tag) {
-                       if (!empty($string)) $string .= $separator;
-                       $string .= (is_object($tag) ? $tag->__toString() : $tag);
-               }
-               
-               return $string;
+               // TODO: This method seems to be unused and unnecessary, as it is a simply wrapper around implode now
+               return implode($separator, $tags);
        }
        
        /**
index 9f5b7eae936d80f0b9ec400d7bcde9521b4f58db..9a2bbea60108ef2c6655c1b4e36ee028252c1356 100644 (file)
@@ -92,9 +92,6 @@ final class StringUtil {
         * @return      string
         */
        public static function encodeHTML($string) {
-               if (is_object($string)) 
-                       $string = $string->__toString();
-               
                return @htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
        }
        
@@ -105,8 +102,6 @@ final class StringUtil {
         * @return      string
         */
        public static function encodeJS($string) {
-               if (is_object($string)) $string = $string->__toString();
-               
                // unify newlines
                $string = self::unifyNewlines($string);