diff -ru SensioLabs/AnsiConverter/AnsiToHtmlConverter.php SensioLabs/AnsiConverter/AnsiToHtmlConverter.php
--- SensioLabs/AnsiConverter/AnsiToHtmlConverter.php 2020-01-13 08:09:35.503344920 +0000
+++ SensioLabs/AnsiConverter/AnsiToHtmlConverter.php 2020-01-13 08:09:36.061322574 +0000
@@ -30,11 +30,11 @@
$this->inlineStyles = $inlineStyles;
$this->charset = $charset;
$this->inlineColors = $this->theme->asArray();
- $this->colorNames = array(
+ $this->colorNames = [
'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white',
'', '',
'brblack', 'brred', 'brgreen', 'bryellow', 'brblue', 'brmagenta', 'brcyan', 'brwhite',
- );
+ ];
}
public function convert($text)
@@ -44,7 +44,7 @@
// remove character set sequences
$text = preg_replace('#\e(\(|\))(A|B|[0-2])#', '', $text);
- $text = htmlspecialchars($text, PHP_VERSION_ID >= 50400 ? ENT_QUOTES | ENT_SUBSTITUTE : ENT_QUOTES, $this->charset);
+ $text = htmlspecialchars($text, \PHP_VERSION_ID >= 50400 ? ENT_QUOTES | ENT_SUBSTITUTE : ENT_QUOTES, $this->charset);
// carriage return
$text = preg_replace('#\r+#m', "\r", $text);
@@ -57,7 +57,7 @@
if ('backspace' == $token[0]) {
$j = $i;
while (--$j >= 0) {
- if ('text' == $tokens[$j][0] && strlen($tokens[$j][1]) > 0) {
+ if ('text' == $tokens[$j][0] && \strlen($tokens[$j][1]) > 0) {
$tokens[$j][1] = substr($tokens[$j][1], 0, -1);
break;
@@ -113,16 +113,16 @@
}
// options: bold => 1, underscore => 4, blink => 5, reverse => 7, conceal => 8
- if (in_array(1, $options)) {
+ if (\in_array(1, $options)) {
$fg += 10;
$bg += 10;
}
- if (in_array(4, $options)) {
+ if (\in_array(4, $options)) {
$as = '; text-decoration: underline';
}
- if (in_array(7, $options)) {
+ if (\in_array(7, $options)) {
$tmp = $fg;
$fg = $bg;
$bg = $tmp;
@@ -138,19 +138,19 @@
protected function tokenize($text)
{
- $tokens = array();
+ $tokens = [];
preg_match_all("/(?:\e\[(.*?)m|(\x08))/", $text, $matches, PREG_OFFSET_CAPTURE);
$offset = 0;
foreach ($matches[0] as $i => $match) {
if ($match[1] - $offset > 0) {
- $tokens[] = array('text', substr($text, $offset, $match[1] - $offset));
+ $tokens[] = ['text', substr($text, $offset, $match[1] - $offset)];
}
- $tokens[] = array("\x08" == $match[0] ? 'backspace' : 'color', $matches[1][$i][0]);
- $offset = $match[1] + strlen($match[0]);
+ $tokens[] = ["\x08" == $match[0] ? 'backspace' : 'color', $matches[1][$i][0]];
+ $offset = $match[1] + \strlen($match[0]);
}
- if ($offset < strlen($text)) {
- $tokens[] = array('text', substr($text, $offset));
+ if ($offset < \strlen($text)) {
+ $tokens[] = ['text', substr($text, $offset)];
}
return $tokens;
diff -ru SensioLabs/AnsiConverter/Tests/AnsiToHtmlConverterTest.php SensioLabs/AnsiConverter/Tests/AnsiToHtmlConverterTest.php
--- SensioLabs/AnsiConverter/Tests/AnsiToHtmlConverterTest.php 2020-01-13 08:09:35.707336750 +0000
+++ SensioLabs/AnsiConverter/Tests/AnsiToHtmlConverterTest.php 2020-01-13 08:09:36.082321733 +0000
@@ -26,35 +26,35 @@
public function getConvertData()
{
- return array(
+ return [
// text is escaped
- array('foo <br />', 'foo
'),
+ ['foo <br />', 'foo
'],
// newlines are preserved
- array("foo\nbar", "foo\nbar"),
+ ["foo\nbar", "foo\nbar"],
// backspaces
- array('foo ', "foobar\x08\x08\x08 "),
- array('foo ', "foob\e[31;41ma\e[0mr\x08\x08\x08 "),
+ ['foo ', "foobar\x08\x08\x08 "],
+ ['foo ', "foob\e[31;41ma\e[0mr\x08\x08\x08 "],
// color
- array('foo', "\e[31;41mfoo\e[0m"),
+ ['foo', "\e[31;41mfoo\e[0m"],
// color with [m as a termination (equivalent to [0m])
- array('foo', "\e[31;41mfoo\e[m"),
+ ['foo', "\e[31;41mfoo\e[m"],
// bright color
- array('foo', "\e[31;41;1mfoo\e[0m"),
+ ['foo', "\e[31;41;1mfoo\e[0m"],
// carriage returns
- array('foobar\r\nbar', "foo\r\r\nbar"),
- array('foobar', "foo\rbar\rfoobar"),
+ ['foobar\r\nbar', "foo\r\r\nbar"],
+ ['foobar', "foo\rbar\rfoobar"],
// underline
- array('foo', "\e[4mfoo\e[0m"),
+ ['foo', "\e[4mfoo\e[0m"],
// non valid unicode codepoints substitution (only available with PHP >= 5.4)
- PHP_VERSION_ID < 50400 ?: array('foo '."\xEF\xBF\xBD".'', "foo \xF4\xFF\xFF\xFF"),
- );
+ \PHP_VERSION_ID < 50400 ?: ['foo '."\xEF\xBF\xBD".'', "foo \xF4\xFF\xFF\xFF"],
+ ];
}
}