Skip to content

"ddev phpstan" creates wrong symlink for phpstan.neon, if run before symlink-project #164

@donquixote

Description

@donquixote

Preliminary checklist

  • I am using the latest stable version of DDEV
  • I am using the latest stable version of this add-on

Expected Behavior

"ddev phpstan" respects the phpstan.neon and phpstan-baseline.neon at my project root.
(e.g. "ignoreErrors" setting is respected)

Actual Behavior

"ddev phpstan" ignores phpstan.neon and phpstan-baseline.neon at my project root.
(e.g. "ignoreErrors" setting is not respected)

Symlinks to phpstan.neon are like this:

Steps To Reproduce

  1. Create a (Drupal) project with some php files that would cause phpstan errors.
  2. Install and start ddev-drupal-contrib following the usual instructions.
    • In config.yml there will be docroot: web.
  3. Create a phpstan.neon at project root, with ignoreErrors to ignore some of those errors.
  4. Run ls -lA web/modules/custom/<project name>/ | grep phpstan
    • The phpstan.neon is not found.
  5. Run ddev symlink-project.
    • We find `phpstan.neon -> /var/www/html/phpstan.neon
  6. Remove web/modules/custom/<project name>/phpstan.neon.
  7. Run ddev phpstan.
    • The settings in phpstan.neon are ignored.
  8. Run ls -lA web/modules/custom/<project name>/ | grep phpstan as before.
    • We find phpstan.neon -> web/phpstan.neon.

Anything else?

The problem seems to be coming from this commit:
733be88#r176975897

EXTENSION_DIRECTORY=$DDEV_DOCROOT/$DRUPAL_PROJECTS_PATH/${DDEV_SITENAME//-/_}
cd "$EXTENSION_DIRECTORY" || exit 1
# 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 . "$@"

For me, $DDEV_DOCROOT is just "web".
But this can never lead to a correct result.
The phpstan.neon is not in web root but in project root, and the path "web" would only work relative to project root, not relative to $EXTENSION_DIRECTORY.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions