diff --git a/.ci/deps.sh b/.ci/deps.sh index ebfd121b4f..17d72ec550 100644 --- a/.ci/deps.sh +++ b/.ci/deps.sh @@ -75,6 +75,10 @@ fi sudo rm -rf $(which alex) # Delete ghc-alex as it clashes with npm deps npm install +# Phan commands +git clone https://github.com/etsy/phan.git; +composer install; + # R commands echo '.libPaths( c( "'"$R_LIB_USER"'", .libPaths()) )' >> .Rprofile echo 'options(repos=structure(c(CRAN="http://cran.rstudio.com")))' >> .Rprofile diff --git a/bears/php/PhanBear.py b/bears/php/PhanBear.py new file mode 100644 index 0000000000..bc9b0beb77 --- /dev/null +++ b/bears/php/PhanBear.py @@ -0,0 +1,24 @@ +from coalib.bearlib.abstractions.Linter import linter + + +@linter(executable='phan', + output_format='regex', + output_regex=r'(?P.+):(?P\d+)\s(?P.+)') +class PhanBear: + """ + Phan is a static analyzer for PHP that looks for common issues and will + verify type compatibility on various operations when type information is + available or can be deduced. + + See for more information. + """ + LANGUAGES = {'PHP'} + AUTHORS = {'The coala developers'} + AUTHORS_EMAILS = {'coala-devel@googlegroups.com'} + LICENSE = 'AGPL-3.0' + CAN_DETECT = {'Formatting', 'Syntax', 'Documentation', + 'Code Simplification'} + ASCIINEMA_URL = '' + + def create_argument(file, filename, config_file): + return (filename,) diff --git a/tests/php/PhanBearTest.py b/tests/php/PhanBearTest.py new file mode 100644 index 0000000000..b7e03fce9e --- /dev/null +++ b/tests/php/PhanBearTest.py @@ -0,0 +1,23 @@ +from coalib.testing.LocalBearTestHelper import verify_local_bear +from bears.php.PhanBear import PhanBear + +bad_file_closure = '''a + $b); + }; + return $closure(3); + } +} +''' + +PhanBearTest = verify_local_bear( + PhanBear, + valid_files=(), + invalid_files=(bad_file_closure,))