PHPStan

Static analysis setup and configuration

Required: PHPstan

Static analysis is configured via phpstan.neon (Level 6, baseline in phpstan-baseline.neon).

Run

composer analyse

The analysis requires a webtrees installation (for app/ classes + vendor/autoload.php). Run it from the bind-mounted path:

cd /path/to/webtrees/modules_v4/linkenhancer
composer analyse

Configuration

  • Level: 6
  • Baseline: phpstan-baseline.neon (known issues)
  • Bootstrap: phpstan-bootstrap.php registers PSR-4 namespaces directly (bypasses the version-gated autoloader in wt-shared-libs)
  • Scan directories: ../../app/ (webtrees core classes)
  • Exclude paths: LinkEnhancerModuleExt.php (use in conjunction with Vesta modules)
  • Memory limit: 1G
  • Parallel: disabled (single process, more reliable in CI)

Key settings

  • treatPhpDocTypesAsCertain: false — prevents false positives from @var assertions
  • ignoreErrors for:
    • AccessLevel Enum (WT 2.3-only class, not available in 2.2 runtime)
    • DB::prefix('') — intentional (getting prefix without identifier)

Regenerating the baseline

After intentional changes that introduce new (acceptable) errors:

vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=1G --generate-baseline=phpstan-baseline.neon

Note: Run this via the direct vendor/bin/phpstan call — the composer script wrapper does not forward extra arguments.

Last modified November 5, 2026: added cross-links (9b8168b)