Skip to content

Commit

Permalink
feat: executando Phan como external tool no PHPStorm (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
elvishp2006 authored Aug 5, 2020
1 parent 981d20f commit 852199d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Renomeie todas as strings abaixo para algo que faça sentido para o projeto que
* `my-app`
* `plugin-boilerplate`
* `GPL-2.0-only`
## Configurando Phan como `external tool` no PHPStorm
* Em Preferences -> Tools -> External Tools clique para adicionar uma nova tool. Coloque o nome que achar melhor, selecione
`run_phan.sh` script como "Program" e selecione o diretório do projeto como "Working directory" e por ultimo coloque `$FILE_PATH$:$LINE$`
como "Output filters" clicando em "Advanced Options". Você consegue executar `external tools` em Tools -> External Tools.

Caso dê algum erro de permissão, execute `chmod +x run_phan.sh` no seu terminal.
## Exemplo de uso
Consulte os arquivos dentro de `src/WordPress/`, lá vai encontrar bons exemplos de como declarar hooks nesta estrutura,
caso queira registrar um CPT consulte `src/WordPress/Services/ExampleServiceProvider.php` ou se caso quer registrar uma
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
"@static-analysis",
"@test"
],
"download-phan": "php -r \"copy('https://github.com/phan/phan/releases/latest/download/phan.phar', 'phan.phar');\"",
"download-phan": [
"php -r \"copy('https://github.com/phan/phan/releases/latest/download/phan.phar', 'phan.phar');\"",
"php -r \"chmod('./phan.phar', 0750);\""
],
"download-tools": [
"@download-phan"
],
Expand Down
10 changes: 10 additions & 0 deletions run_phan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
./phan.phar --allow-polyfill-parser > phan.out
cat phan.out | sed G | sed -E 's|([a-zA-Z0-9 _\./\-]+:[[:digit:]]+)|'"$(pwd)"'/\1\
|g' | fold -sw 150
num_matches=$(cat phan.out | wc -l | xargs);
if [ -s phan.out ]; then
echo "There are ${num_matches} errors";
else
echo "No errors";
fi
rm phan.out

0 comments on commit 852199d

Please sign in to comment.