forked from Cavemanon/cavepaintings
replace xml_tag with HTMLElement
This commit is contained in:
@@ -190,8 +190,8 @@ function stream_file(string $file, int $start, int $end): void
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('http_parse_headers')) { #http://www.php.net/manual/en/function.http-parse-headers.php#112917
|
||||
|
||||
# http://www.php.net/manual/en/function.http-parse-headers.php#112917
|
||||
if (!function_exists('http_parse_headers')) {
|
||||
/**
|
||||
* #return string[]
|
||||
*/
|
||||
@@ -478,25 +478,6 @@ function clamp(?int $val, ?int $min=null, ?int $max=null): int
|
||||
return $val;
|
||||
}
|
||||
|
||||
function xml_tag(string $name, array $attrs=[], array $children=[]): string
|
||||
{
|
||||
$xml = "<$name ";
|
||||
foreach ($attrs as $k => $v) {
|
||||
$xv = str_replace(''', ''', htmlspecialchars((string)$v, ENT_QUOTES));
|
||||
$xml .= "$k=\"$xv\" ";
|
||||
}
|
||||
if (count($children) > 0) {
|
||||
$xml .= ">\n";
|
||||
foreach ($children as $child) {
|
||||
$xml .= xml_tag($child);
|
||||
}
|
||||
$xml .= "</$name>\n";
|
||||
} else {
|
||||
$xml .= "/>\n";
|
||||
}
|
||||
return $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Original PHP code by Chirp Internet: www.chirp.com.au
|
||||
* Please acknowledge use of this code by including this header.
|
||||
|
@@ -76,14 +76,6 @@ class PolyfillsTest extends TestCase
|
||||
$this->assertEquals(clamp(15, 5, 10), 10);
|
||||
}
|
||||
|
||||
public function test_xml_tag()
|
||||
{
|
||||
$this->assertEquals(
|
||||
"<test foo=\"bar\" >\n<cake />\n</test>\n",
|
||||
xml_tag("test", ["foo"=>"bar"], ["cake"])
|
||||
);
|
||||
}
|
||||
|
||||
public function test_truncate()
|
||||
{
|
||||
$this->assertEquals(truncate("test words", 10), "test words");
|
||||
|
Reference in New Issue
Block a user