mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
TextFormat: do not assume that an array given to toHTML() is actually a tokenized string
this is a far stretch, since the documentation doesn't mention that the string needs to be tokenized. Anyone passing an array in here is most likely doing so by mistake.
This commit is contained in:
parent
a59ac522ee
commit
34309bc810
@ -159,16 +159,11 @@ abstract class TextFormat{
|
||||
|
||||
/**
|
||||
* Returns an HTML-formatted string with colors/markup
|
||||
*
|
||||
* @param string|string[] $string
|
||||
*/
|
||||
public static function toHTML($string) : string{
|
||||
if(!is_array($string)){
|
||||
$string = self::tokenize($string);
|
||||
}
|
||||
public static function toHTML(string $string) : string{
|
||||
$newString = "";
|
||||
$tokens = 0;
|
||||
foreach($string as $token){
|
||||
foreach(self::tokenize($string) as $token){
|
||||
switch($token){
|
||||
case TextFormat::BOLD:
|
||||
$newString .= "<span style=font-weight:bold>";
|
||||
|
Loading…
x
Reference in New Issue
Block a user