Skip to content

feat: PHP language support#67

Merged
makinzm merged 6 commits intomainfrom
feat/php-support
Mar 22, 2026
Merged

feat: PHP language support#67
makinzm merged 6 commits intomainfrom
feat/php-support

Conversation

@makinzm
Copy link
Copy Markdown
Owner

@makinzm makinzm commented Mar 22, 2026

Summary

  • Add PHP file analysis support using tree-sitter-php 0.22.8
  • Parse use statements: simple, aliased (as), grouped ({}), use function, use const
  • Classify imports as Internal / External / Stdlib (PHP built-ins like DateTime, PDO, Exception)
  • Auto-detect base namespace from composer.json autoload.psr-4
  • [resolve.php] config section with namespace and composer_json keys
  • .php extension registered in ext_to_language so mille init detects PHP projects

Changes

  • src/infrastructure/parser/php.rsPhpParser with tree-sitter AST walking
  • src/infrastructure/resolver/php.rsPhpResolver with Internal/External/Stdlib classification + read_namespace_from_composer_content
  • src/infrastructure/parser/mod.rs — dispatch .php to PhpParser
  • src/infrastructure/resolver/mod.rs — dispatch .php to PhpResolver, read [resolve.php] config
  • src/usecase/init.rs"php" => Some("php") in ext_to_language
  • Cargo.tomltree-sitter-php = "0.22"
  • README.md — PHP added to language support table, [resolve.php] reference, Laravel example config
  • docs/TODO.md — PHP support noted in summary and completed task list

Test plan

  • RED phase committed with --no-verify (10 parser tests failing with todo!())
  • GREEN phase: all 10 parser tests + 12 resolver tests pass
  • Full test suite: 348 tests pass, no regressions
  • cargo fmt applied, cargo clippy clean
  • lefthook pre-commit hook passes

Parser test coverage

  • test_parse_php_simple_useuse App\Models\User;
  • test_parse_php_aliased_use — alias ignored, original path returned
  • test_parse_php_group_useuse App\Services\{Auth, Logger}; expands to 2 imports
  • test_parse_php_function_useuse function App\Helpers\format_date;
  • test_parse_php_const_useuse const App\Config\MAX_RETRIES;
  • test_parse_php_multiple_use — 3 mixed use statements
  • test_parse_php_no_imports — empty for plain class file
  • test_parse_php_names_class, _function, _comment

Resolver test coverage

  • Internal classification (base namespace match)
  • Stdlib classification: DateTime, PDO, Exception, \DateTime (leading backslash stripped)
  • External classification (third-party vendor namespaces)
  • test_php_resolver_internal_resolved_pathApp\Models\UserApp/Models/User.php
  • test_php_resolver_external_no_path — no resolved_path for External
  • test_read_namespace_from_composer — PSR-4 key extraction
  • Empty base namespace → all External (except Stdlib)

Notes

  • use require/include are intentionally not parsed (as per scope)
  • mille init PHP support (scanning imports to generate layers) is not yet implemented — would require a follow-up PR

🤖 Generated with Claude Code

makinzm and others added 6 commits March 22, 2026 21:33
…lation detector for PHP support because of PHP support

- Add E2E fixture tests (tests/e2e_php.rs) covering all e2e_checklist items:
  dep opt-in/opt-out, external opt-in/opt-out, allow_call_patterns
- Add PHP fixture (tests/fixtures/php_sample/) with Laravel-style 4-layer architecture
- Add CI dogfooding step for PHP fixture in ci.yml
- Add website language guide pages (ja + en) for PHP
- Update website index pages and sidebar with PHP support
- Fix violation_detector: add backslash-separated crate name extraction for PHP imports
- Fix violation_detector: add backslash-separated type name extraction for PHP call patterns
- Fix PHP resolver: use PSR-4 src_dir mapping for resolved_path to match layer paths

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@makinzm makinzm merged commit 995e11b into main Mar 22, 2026
9 checks passed
@makinzm makinzm deleted the feat/php-support branch March 22, 2026 23:04
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.

1 participant