Skip to content

Commit

Permalink
[TwigBridge] Prevent code extension to display warning
Browse files Browse the repository at this point in the history
  • Loading branch information
lyrixx committed Aug 12, 2013
1 parent 36e4b8c commit e8e76ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Symfony/Bridge/Twig/Extension/CodeExtension.php
Expand Up @@ -137,7 +137,9 @@ public function formatArgsAsText($args)
public function fileExcerpt($file, $line)
{
if (is_readable($file)) {
$code = highlight_file($file, true);
// highlight_file could throw warnings
// see https://bugs.php.net/bug.php?id=25725
$code = @highlight_file($file, true);
// remove main code/span tags
$code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s', '\\1', $code);
$content = preg_split('#<br />#', $code);
Expand Down
Expand Up @@ -131,7 +131,9 @@ public function fileExcerpt($file, $line)
}
}

$code = highlight_file($file, true);
// highlight_file could throw warnings
// see https://bugs.php.net/bug.php?id=25725
$code = @highlight_file($file, true);
// remove main code/span tags
$code = preg_replace('#^<code.*?>\s*<span.*?>(.*)</span>\s*</code>#s', '\\1', $code);
$content = preg_split('#<br />#', $code);
Expand Down

0 comments on commit e8e76ec

Please sign in to comment.