Skip to content

Fix #164. Symlink PHPStan configuration from the project root - #187

Open
claudiu-cristea wants to merge 1 commit into
ddev:mainfrom
claudiu-cristea:fix-phpstan-config-symlinks
Open

claudiu-cristea wants to merge 1 commit into
ddev:mainfrom
claudiu-cristea:fix-phpstan-config-symlinks

Conversation

@claudiu-cristea

@claudiu-cristea claudiu-cristea commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

The Issue

ddev phpstan symlinks $DDEV_DOCROOT/phpstan.neon into the extension directory. $DDEV_DOCROOT is relative (web), so the link resolves to web/modules/custom/<project>/web/phpstan.neon, which doesn't exist. PHPStan then runs with no configuration, skipping ignoreErrors and the baseline, and its results differ from the GitLab CI phpstan job.

Also, ln -s … || true never replaces an existing link, so a broken link stays broken.

How This PR Solves The Issue

The command starts in the project root, where it creates phpstan.neon, so it now records that directory before changing into the extension directory. It then links both files with absolute targets, using ln -sfn so stale links get replaced. A real file in the extension directory is never overwritten.

Manual Testing Instructions

ddev add-on get https://github.com/claudiu-cristea/ddev-drupal-contrib/tarball/fix-phpstan-config-symlinks
ddev restart
ddev phpstan

ddev phpstan now prints Note: Using configuration file …/phpstan.neon, and readlink web/modules/custom/<project>/phpstan.neon returns /var/www/html/phpstan.neon. The same holds when an old broken link is already present.

Automated Testing Overview

New test in tests/full.bats, "phpstan uses the project root configuration". It recreates the broken relative link from earlier versions, runs ddev phpstan, and asserts that PHPStan uses a configuration file and that both links point to the project root.

Release/Deployment Notes

None. Existing broken links are repaired the next time ddev phpstan runs.

🤖 Generated with Claude Code

The phpstan command linked $DDEV_DOCROOT/phpstan.neon into the extension
directory, but $DDEV_DOCROOT is relative, so the link never resolved and
PHPStan ran without any configuration. Link to the project root with
absolute targets, and replace stale links, never real files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant