Bladeren bron

[Console] Extract the OutputFormatter's regular expression into the inteface.

Laszlo Korte 14 jaren geleden
bovenliggende
commit
9a829242fb

+ 1 - 1
src/Symfony/Component/Console/Formatter/OutputFormatter.php

@@ -125,7 +125,7 @@ class OutputFormatter implements OutputFormatterInterface
      */
     public function format($message)
     {
-        return preg_replace_callback('#<([a-z][a-z0-9_=;-]+)>(.*?)</\\1?>#is', array($this, 'replaceStyle'), $message);
+        return preg_replace_callback(OutputFormatterStyleInterface::FORMAT_PATTERN, array($this, 'replaceStyle'), $message);
     }
 
     /**

+ 5 - 0
src/Symfony/Component/Console/Formatter/OutputFormatterInterface.php

@@ -20,6 +20,11 @@ namespace Symfony\Component\Console\Formatter;
  */
 interface OutputFormatterInterface
 {
+    /**
+     * The pattern to phrase the format.
+     */
+    const FORMAT_PATTERN = '#<([a-z][a-z0-9_=;-]+)>(.*?)</\\1?>#is';
+
     /**
      * Sets the decorated flag.
      *