Skip to content

Import PHP include and require targets - #875

Open
yzxcj797 wants to merge 1 commit into
tirth8205:mainfrom
yzxcj797:fix/819-php-include-imports
Open

Import PHP include and require targets#875
yzxcj797 wants to merge 1 commit into
tirth8205:mainfrom
yzxcj797:fix/819-php-include-imports

Conversation

@yzxcj797

Copy link
Copy Markdown
Contributor

Summary

PHP use declarations produced import edges, but procedural PHP files wired together with include, include_once, require, and require_once had no IMPORTS_FROM edges. Impact radius and importer queries therefore saw no cross-file structure for non-Composer codebases.

The parser now treats all four include/require expression forms as import nodes, extracts their string argument, and resolves relative paths ending in .php without appending a second extension.

Fixes #819.

Testing

  • Added end-to-end regressions for:
    • require_once 'includes/conexao.php';
    • include_once 'helper.php'.
  • Both tests fail on clean main with zero import edges and pass with the fix.
  • pytest tests/test_pr819_php_includes.py -q — 2 passed
  • pytest tests/test_php_scoped_calls.py tests/test_php_laravel.py tests/test_pr819_php_includes.py -q — 56 passed, 2 skipped, plus one pre-existing Windows path-separator assertion unchanged by this patch
  • ruff check on changed files — passes
  • git diff --check — passes

@github-actions

Copy link
Copy Markdown

code-review-graph review

Overall risk: 0.30 (LOW) — 5 changed function(s)/class(es), 0 affected flow(s), 2 test gap(s)

Risk-scored changes

Risk Level Symbol Location Tested
0.30 low code_review_graph/parser.py::CodeParser code_review_graph/parser.py:2411 yes
0.30 low code_review_graph/parser.py::CodeParser._extract_import code_review_graph/parser.py:15499 no
0.10 low code_review_graph/parser.py::CodeParser._do_resolve_module code_review_graph/parser.py:13602 no
0.05 low tests/test_pr819_php_includes.py::test_require_once_resolves_relative_php_file tests/test_pr819_php_includes.py:8 (test)
0.05 low tests/test_pr819_php_includes.py::test_include_once_resolves_relative_php_file tests/test_pr819_php_includes.py:26 (test)

Test gaps

  • code_review_graph/parser.py::CodeParser._do_resolve_module (code_review_graph/parser.py:13602)
  • code_review_graph/parser.py::CodeParser._extract_import (code_review_graph/parser.py:15499)

Token savings: this graph-backed report used ~163,666 fewer tokens (~99%) than reading every changed file in full (estimated, chars/4 approximation).


Powered by code-review-graph — local-first analysis; no code leaves the CI runner.

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.

PHP: include/require produce no IMPORTS_FROM edges — procedural (non-Composer) PHP repos get an empty cross-file graph

1 participant