1. Georg Brandl
  2. pygments-main
Issue #160 resolved

Pygments php lexer doesn't recognize byref functions

Anonymous created an issue

New-style by-reference function names are prefixed with & in the declaration. Here's a patch.

{{{

!diff

Index: tests/examplefiles/test.php

--- tests/examplefiles/test.php (revision 2492) +++ tests/examplefiles/test.php (working copy) @@ -490,4 +490,9 @@ return true; } } + +function &byref() { + $x = array(); + return $x; +} ?> Index: pygments/lexers/web.py =================================================================== --- pygments/lexers/web.py (revision 2492) +++ pygments/lexers/web.py (working copy) @@ -259,7 +259,8 @@ bygroups(Operator, Text, Name.Attribute)), (r'[~!%^&()+=|\[\]:;,.<>/?{}-]', Text), (r'(class)(\s+)', bygroups(Keyword, Text), 'classname'), - (r'(function)(\s+)', bygroups(Keyword, Text), 'functionname'), + (r'(function)(\s+)(&?)(\s)', + bygroups(Keyword, Text, Operator, Text), 'functionname'), (r'(and|E_PARSE|old_function|E_ERROR|or|as|E_WARNING|parent|' r'eval|PHP_OS|break|exit|case|extends|PHP_VERSION|cfunction|' r'FALSE|print|for|require|continue|foreach|require_once|' }}}

Reported by Tim Hatch trac@timhatch.com

Comments (2)

  1. Log in to comment