Index: src/__phutil_library_map__.php =================================================================== --- src/__phutil_library_map__.php +++ src/__phutil_library_map__.php @@ -263,6 +263,7 @@ 'PhutilRemarkupRuleMonospace' => 'markup/engine/remarkup/markuprule/PhutilRemarkupRuleMonospace.php', 'PhutilSafeHTML' => 'markup/PhutilSafeHTML.php', 'PhutilSafeHTMLProducerInterface' => 'markup/PhutilSafeHTMLProducerInterface.php', + 'PhutilSafeHTMLTestCase' => 'markup/__tests__/PhutilSafeHTMLTestCase.php', 'PhutilSaturateStdoutDaemon' => 'daemon/torture/PhutilSaturateStdoutDaemon.php', 'PhutilServiceProfiler' => 'serviceprofiler/PhutilServiceProfiler.php', 'PhutilShellLexer' => 'lexer/PhutilShellLexer.php', @@ -605,6 +606,7 @@ 'PhutilRemarkupRuleItalic' => 'PhutilRemarkupRule', 'PhutilRemarkupRuleLinebreaks' => 'PhutilRemarkupRule', 'PhutilRemarkupRuleMonospace' => 'PhutilRemarkupRule', + 'PhutilSafeHTMLTestCase' => 'PhutilTestCase', 'PhutilSaturateStdoutDaemon' => 'PhutilTortureTestDaemon', 'PhutilShellLexer' => 'PhutilLexer', 'PhutilShellLexerTestCase' => 'PhutilTestCase', Index: src/markup/PhutilSafeHTML.php =================================================================== --- src/markup/PhutilSafeHTML.php +++ src/markup/PhutilSafeHTML.php @@ -30,4 +30,15 @@ return new PhutilSafeHTML(call_user_func_array($function, $args)); } +// Requires http://pecl.php.net/operator. + + public function __concat($html) { + $clone = clone $this; + return $clone->appendHTML($html); + } + + public function __assign_concat($html) { + return $this->appendHTML($html); + } + } Index: src/markup/__tests__/PhutilSafeHTMLTestCase.php =================================================================== --- /dev/null +++ src/markup/__tests__/PhutilSafeHTMLTestCase.php @@ -0,0 +1,22 @@ +assertSkipped("Operator extension not available."); + } + + $a = phutil_tag('a'); + $ab = $a.phutil_tag('b'); + $this->assertEqual('', $ab->getHTMLContent()); + $this->assertEqual('', $a->getHTMLContent()); + + $a .= phutil_tag('a'); + $this->assertEqual('', $a->getHTMLContent()); + } + +}