Skip to content

Commit e284f0d

Browse files
authored
Add phpstan command. (#14)
1 parent 64c65e6 commit e284f0d

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Run tests on the `web/modules/custom` directory:
3838
- `ddev nightwatch` Run Nightwatch tests, requires [DDEV Selenium Standalone Chrome](https://github.com/ddev/ddev-selenium-standalone-chrome).
3939
- `ddev phpcs` Run [PHP_CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer).
4040
- `ddev phpcbf` Fix phpcs findings.
41+
- `ddev phpstan`. Run [phpstan](https://phpstan.org) on the web/modules/custom directory.
4142
- `ddev eslint` Run [ESLint](https://github.com/eslint/eslint) on JavaScript files.
4243
- `ddev stylelint` Run [Stylelint](https://github.com/stylelint/stylelint) on CSS files.
4344

commands/web/phpstan

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
#ddev-generated
4+
## Command provided by https://github.com/ddev/ddev-drupal-contrib
5+
## Description: Run phpstan inside the web container
6+
## Usage: phpstan [flags] [args]
7+
## Example: "ddev phpstan" or "ddev phpstan -n"
8+
## ProjectTypes: drupal,drupal8,drupal9,drupal10
9+
## ExecRaw: true
10+
11+
if ! command -v phpstan >/dev/null; then
12+
echo "phpstan is not available. You may need to 'ddev poser'"
13+
exit 1
14+
fi
15+
test -e phpstan.neon || curl -OL https://git.drupalcode.org/project/gitlab_templates/-/raw/default-ref/assets/phpstan.neon
16+
# Add an empty baseline file to ensure it exists.
17+
test -e phpstan-baseline.neon || touch phpstan-baseline.neon
18+
phpstan analyse $DDEV_DOCROOT/modules/custom "$@"

commands/web/poser

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ export COMPOSER=composer.contrib.json
1111
.ddev/commands/web/expand-composer-json "$DDEV_PROJECT_NAME"
1212
composer install
1313
rm composer.contrib.json composer.contrib.lock
14-
yarn --cwd $DDEV_DOCROOT/core install
1514
touch $DDEV_DOCROOT/core/.env

install.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ project_files:
55
- commands/web/nightwatch
66
- commands/web/phpcbf
77
- commands/web/phpcs
8+
- commands/web/phpstan
89
- commands/web/phpunit
910
- commands/web/poser
1011
- commands/web/stylelint

tests/test.bats

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ teardown() {
2323
echo "# ddev get ${DIR} with project ${PROJNAME} in ${TESTDIR}/${PROJNAME} ($(pwd))" >&3
2424
ddev get ${DIR}
2525
ddev config --auto
26+
ddev config --corepack-enable
2627
ddev start
2728
ddev expand-composer-json
2829
ddev composer install
2930
ddev symlink-project
3031
ddev drush st
3132
ddev phpcs --version
33+
ddev phpstan --version
3234
ls -al web/modules/custom/${PROJNAME}/tests
3335
ddev phpunit --version
3436
ddev yarn --cwd web/core install

0 commit comments

Comments
 (0)