14
14
use Symfony \Component \Console \Exception \ExceptionInterface ;
15
15
use Symfony \Component \Console \Formatter \OutputFormatter ;
16
16
use Symfony \Component \Console \Helper \DebugFormatterHelper ;
17
+ use Symfony \Component \Console \Helper \Helper ;
17
18
use Symfony \Component \Console \Helper \ProcessHelper ;
18
19
use Symfony \Component \Console \Helper \QuestionHelper ;
19
20
use Symfony \Component \Console \Input \InputInterface ;
@@ -638,7 +639,7 @@ public function renderException(\Exception $e, OutputInterface $output)
638
639
$ output ->isVerbose () && 0 !== ($ code = $ e ->getCode ()) ? ' ( ' .$ code .') ' : ''
639
640
);
640
641
641
- $ len = $ this -> stringWidth ($ title );
642
+ $ len = Helper:: strlen ($ title );
642
643
643
644
$ width = $ this ->terminal ->getWidth () ? $ this ->terminal ->getWidth () - 1 : PHP_INT_MAX ;
644
645
// HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is a 64 bit integer: https://github.com/facebook/hhvm/issues/1327
@@ -649,7 +650,7 @@ public function renderException(\Exception $e, OutputInterface $output)
649
650
foreach (preg_split ('/\r?\n/ ' , $ e ->getMessage ()) as $ line ) {
650
651
foreach ($ this ->splitStringByWidth ($ line , $ width - 4 ) as $ line ) {
651
652
// pre-format lines to get the right string length
652
- $ lineLength = $ this -> stringWidth ($ line ) + 4 ;
653
+ $ lineLength = Helper:: strlen ($ line ) + 4 ;
653
654
$ lines [] = array ($ line , $ lineLength );
654
655
655
656
$ len = max ($ lineLength , $ len );
@@ -658,7 +659,7 @@ public function renderException(\Exception $e, OutputInterface $output)
658
659
659
660
$ messages = array ();
660
661
$ messages [] = $ emptyLine = sprintf ('<error>%s</error> ' , str_repeat (' ' , $ len ));
661
- $ messages [] = sprintf ('<error>%s%s</error> ' , $ title , str_repeat (' ' , max (0 , $ len - $ this -> stringWidth ($ title ))));
662
+ $ messages [] = sprintf ('<error>%s%s</error> ' , $ title , str_repeat (' ' , max (0 , $ len - Helper:: strlen ($ title ))));
662
663
foreach ($ lines as $ line ) {
663
664
$ messages [] = sprintf ('<error> %s %s</error> ' , OutputFormatter::escape ($ line [0 ]), str_repeat (' ' , $ len - $ line [1 ]));
664
665
}
@@ -1038,15 +1039,6 @@ public function setDefaultCommand($commandName, $isSingleCommand = false)
1038
1039
return $ this ;
1039
1040
}
1040
1041
1041
- private function stringWidth ($ string )
1042
- {
1043
- if (false === $ encoding = mb_detect_encoding ($ string , null , true )) {
1044
- return strlen ($ string );
1045
- }
1046
-
1047
- return mb_strwidth ($ string , $ encoding );
1048
- }
1049
-
1050
1042
private function splitStringByWidth ($ string , $ width )
1051
1043
{
1052
1044
// str_split is not suitable for multi-byte characters, we should use preg_split to get char array properly.
0 commit comments