Skip to content

Lint: Constant-fold __DIR__ concatenation for include/require graph in phpc lint --all #462

@PurHur

Description

@PurHur

Problem

phpc lint --all walks include/require edges only when the path operand is a literal string. MiniWebApp and normal PHP apps use:

require __DIR__ . '/../config.php';
include __DIR__ . '/../templates/home.php';

lib/Lint/Linter.php emits stderr warnings (dynamic include/require (not followed)) and does not lint included files, so the project tree looks noisier than the real blocker set and MINIWEBAPP_LINT_GATE=1 cannot flip cleanly after #67.

Goal

When the include expression is __DIR__ concatenated with a literal suffix, resolve the path relative to the including file and recurse lint like a static include.

Scope

  • Extend literalStringOperand() / walkCfgBlock() in lib/Lint/Linter.php to fold Concat of MagicConst __DIR__ + literal (and optional single segment)
  • Reuse resolveIncludePath() for normalized absolute paths
  • Unit test in test/unit/PhpcLintProjectTest.php using examples/003-MiniWebApp/ (expect fewer dynamic warnings; ClassMethod blockers remain until Language: Class methods and property access in JIT #58)
  • Document in docs/unsupported-syntax.md if truly dynamic paths stay warnings

Out of scope

Acceptance criteria

docker run --rm -v "$(pwd):/compiler" -w /compiler php-compiler:22.04-dev \
  php bin/lint.php --all examples/003-MiniWebApp 2>&1 | tee /tmp/lint.txt

Verification (local / Docker only)

./script/ci-local.sh --filter PhpcLintProjectTest

Do not require GitHub Actions.

Dependencies

Links

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions