Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion commands/web/phpstan
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,15 @@ test -e phpstan.neon || curl -OL https://git.drupalcode.org/project/gitlab_templ
sed -i 's/BASELINE_PLACEHOLDER/phpstan-baseline.neon/g' phpstan.neon
# Add an empty baseline file to ensure it exists.
test -e phpstan-baseline.neon || touch phpstan-baseline.neon
phpstan analyse $DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH "$@"

CONTRIB_MODULE_DIR=$(find "$DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH" -mindepth 1 -maxdepth 1 -type d | head -n 1)
if [ -n "$CONTRIB_MODULE_DIR" ]; then
cd "$CONTRIB_MODULE_DIR"
# Ensure PHPStan configuration is symlinked from project root.
ln -s $DDEV_DOCROOT/phpstan.neon 2>/dev/null || true
ln -s $DDEV_DOCROOT/phpstan-baseline.neon 2>/dev/null || true
phpstan analyze . "$@"
else
echo "The contrib module directory could not be identified in $DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH"
exit 1
fi