Skip to content

Commit

Permalink
Add phpstan command. (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
markdorison authored Aug 5, 2024
1 parent 64c65e6 commit e284f0d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
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](https://phpstan.org) 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
18 changes: 18 additions & 0 deletions commands/web/phpstan
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/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
# Add an empty baseline file to ensure it exists.
test -e phpstan-baseline.neon || touch phpstan-baseline.neon
phpstan analyse $DDEV_DOCROOT/modules/custom "$@"
1 change: 0 additions & 1 deletion commands/web/poser
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ export COMPOSER=composer.contrib.json
.ddev/commands/web/expand-composer-json "$DDEV_PROJECT_NAME"
composer install
rm composer.contrib.json composer.contrib.lock
yarn --cwd $DDEV_DOCROOT/core install
touch $DDEV_DOCROOT/core/.env
1 change: 1 addition & 0 deletions install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ project_files:
- commands/web/nightwatch
- commands/web/phpcbf
- commands/web/phpcs
- commands/web/phpstan
- commands/web/phpunit
- commands/web/poser
- commands/web/stylelint
Expand Down
2 changes: 2 additions & 0 deletions tests/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ teardown() {
echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR}/${PROJNAME} ($(pwd))" >&3
ddev get ${DIR}
ddev config --auto
ddev config --corepack-enable
ddev start
ddev expand-composer-json
ddev composer install
ddev symlink-project
ddev drush st
ddev phpcs --version
ddev phpstan --version
ls -al web/modules/custom/${PROJNAME}/tests
ddev phpunit --version
ddev yarn --cwd web/core install
Expand Down

0 comments on commit e284f0d

Please sign in to comment.