for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
import re
from coalib.bearlib.abstractions.Lint import Lint
from coalib.bears.LocalBear import LocalBear
from coalib.results.RESULT_SEVERITY import RESULT_SEVERITY
class PHPLintBear(LocalBear, Lint):
executable = 'php'
arguments = '-l -n -d display_errors=On -d log_errors=Off'
output_regex = re.compile(
r'(?P<severity>\S+) error: '
r'(?P<message>.*) in (?P<file_name>.*) on line (?P<line>\d+)')
@staticmethod
def _get_groupdict(match):
groups = Lint._get_groupdict(match)
# As `php -l` only shows Fatal errorsor Parsing errors both are
# considered as Major
groups['severity'] = RESULT_SEVERITY.MAJOR
return groups
def run(self, filename, file):
'''
Checks the code with `php -l`. This runs it on each file separately.
return self.lint(filename)