Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add phpstan command #53

Closed
wants to merge 11 commits into from
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Run tests on the `web/modules/custom` directory:
- `ddev nightwatch` Run Nightwatch tests, requires [DDEV Selenium Standalone Chrome](https://github.com/ddev/ddev-selenium-standalone-chrome).
- `ddev phpcs` Run [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer).
- `ddev phpcbf` Fix phpcs findings.
- `ddev phpstan`. Run phpstan on the web/modules/custom directory.
- `ddev eslint` Run [ESLint](https://github.com/eslint/eslint) on JavaScript files.
- `ddev stylelint` Run [Stylelint](https://github.com/stylelint/stylelint) on CSS files.

Expand Down
19 changes: 19 additions & 0 deletions commands/web/phpstan
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

#ddev-generated
## Command provided by https://github.com/ddev/ddev-drupal-contrib
## Description: Run phpstan inside the web container
## Usage: phpstan [flags] [args]
## Example: "ddev phpstan" or "ddev phpstan -n"
## ProjectTypes: drupal,drupal8,drupal9,drupal10
## ExecRaw: true

if ! command -v phpstan >/dev/null; then
echo "phpstan is not available. You may need to 'ddev poser'"
exit 1
fi
test -e phpstan.neon || curl -OL https://git.drupalcode.org/project/gitlab_templates/-/raw/default-ref/assets/phpstan.neon
export COMPOSER=composer.contrib.json
.ddev/commands/web/expand-composer-json "$DDEV_PROJECT_NAME"
phpstan analyse $DDEV_DOCROOT/modules/custom "$@"
rm composer.contrib.json