Symfony\Component\Console\Formatter\OutputFormatter::escape PHP Метод

escape() публичный статический Метод

Escapes "<" special char in given text.
public static escape ( string $text ) : string
$text string Text to escape
Результат string Escaped text
    public static function escape($text)
    {
        $text = preg_replace('/([^\\\\]?)</', '$1\\<', $text);
        return self::escapeTrailingBackslash($text);
    }

Usage Example

Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function generate(ReportSummary $reportSummary)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     // new nodes should be added to this or existing children
     $root = $dom->createElement('report');
     $dom->appendChild($root);
     $filesXML = $dom->createElement('files');
     $root->appendChild($filesXML);
     $i = 1;
     foreach ($reportSummary->getChanged() as $file => $fixResult) {
         $fileXML = $dom->createElement('file');
         $fileXML->setAttribute('id', $i++);
         $fileXML->setAttribute('name', $file);
         $filesXML->appendChild($fileXML);
         if ($reportSummary->shouldAddAppliedFixers()) {
             $fileXML->appendChild($this->createAppliedFixersElement($dom, $fixResult));
         }
         if (!empty($fixResult['diff'])) {
             $fileXML->appendChild($this->createDiffElement($dom, $fixResult));
         }
     }
     if (null !== $reportSummary->getTime()) {
         $root->appendChild($this->createTimeElement($reportSummary->getTime(), $dom));
     }
     if (null !== $reportSummary->getTime()) {
         $root->appendChild($this->createMemoryElement($reportSummary->getMemory(), $dom));
     }
     $dom->formatOutput = true;
     return $reportSummary->isDecoratedOutput() ? OutputFormatter::escape($dom->saveXML()) : $dom->saveXML();
 }
All Usage Examples Of Symfony\Component\Console\Formatter\OutputFormatter::escape