graphify-php 0.0.6__tar.gz → 0.0.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {graphify_php-0.0.6 → graphify_php-0.0.8}/.graphifyignore +4 -0
- graphify_php-0.0.8/PKG-INFO +488 -0
- graphify_php-0.0.8/README.md +467 -0
- graphify_php-0.0.8/src/graphify_php/frameworks/__init__.py +16 -0
- graphify_php-0.0.8/src/graphify_php/frameworks/codeigniter.py +1760 -0
- graphify_php-0.0.8/src/graphify_php/frameworks/detect.py +62 -0
- graphify_php-0.0.8/src/graphify_php/frameworks/laravel.py +2129 -0
- graphify_php-0.0.8/src/graphify_php/frameworks/matching.py +64 -0
- graphify_php-0.0.8/src/graphify_php/frameworks/provider.py +252 -0
- graphify_php-0.0.8/src/graphify_php/frameworks/symfony.py +821 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/graph_adapter.py +293 -6
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/resolver.py +236 -12
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/sources/route_source.py +79 -11
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/sources/tree_sitter_source.py +1 -1
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/status.py +42 -0
- graphify_php-0.0.8/src/graphify_php/syntax/access_control.py +836 -0
- graphify_php-0.0.8/src/graphify_php/syntax/attributes.py +190 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/syntax/facts.py +9 -4
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/syntax/file_scan.py +55 -14
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/syntax/names.py +27 -0
- graphify_php-0.0.8/src/graphify_php/syntax/routes.py +782 -0
- graphify_php-0.0.8/tests/conftest.py +15 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Config/AdminRoutes.php +4 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Config/Filters.php +46 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Config/Modules.php +12 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Config/Routes.php +39 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Config/Routing.php +19 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Controllers/Account.php +11 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Controllers/Admin/Users.php +8 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Controllers/Albums.php +9 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Controllers/Api/Tokens.php +8 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Controllers/Contact.php +8 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Controllers/Files.php +8 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Controllers/Home.php +8 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Controllers/Panel.php +11 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Controllers/Photos.php +14 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Controllers/Reports.php +8 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Controllers/Search.php +8 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/app/Controllers/Users.php +10 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/composer.json +8 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/codeigniter/composer.lock +6 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/app/Http/Controllers/Api/TokenController.php +20 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/app/Http/Controllers/Controller.php +10 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/app/Http/Controllers/PhotoController.php +10 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/app/Http/Controllers/PostController.php +25 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/app/Http/Controllers/ReportController.php +24 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/app/Http/Controllers/ShowDashboard.php +8 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/app/Http/Controllers/UserController.php +33 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/bootstrap/app.php +16 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/composer.json +7 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/composer.lock +10 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/routes/admin.php +6 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/routes/api.php +8 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/routes/console.php +7 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/routes/orphan.php +6 -0
- graphify_php-0.0.8/tests/fixtures/frameworks/laravel/routes/web.php +53 -0
- graphify_php-0.0.8/tests/test_access_checks.py +561 -0
- graphify_php-0.0.8/tests/test_access_control_segments.py +911 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_cli_end_to_end.py +18 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_core_guard.py +9 -0
- graphify_php-0.0.8/tests/test_framework_codeigniter.py +1228 -0
- graphify_php-0.0.8/tests/test_framework_laravel.py +1843 -0
- graphify_php-0.0.8/tests/test_framework_providers.py +461 -0
- graphify_php-0.0.8/tests/test_namespace_blocks.py +208 -0
- graphify_php-0.0.8/tests/test_route_schema.py +520 -0
- graphify_php-0.0.8/tests/test_routes_stacked_guards.py +367 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_syntax_routes.py +27 -27
- graphify_php-0.0.6/PKG-INFO +0 -218
- graphify_php-0.0.6/README.md +0 -197
- graphify_php-0.0.6/src/graphify_php/syntax/routes.py +0 -288
- {graphify_php-0.0.6 → graphify_php-0.0.8}/.github/workflows/ci.yml +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/.github/workflows/pages.yml +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/.github/workflows/release.yml +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/.github/workflows/stage-build.yml +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/.github/workflows/stage-security.yml +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/.github/workflows/stage-tests.yml +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/.gitignore +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/.gitleaks.toml +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/.trufflehog-exclude.txt +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/LICENSE +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/docs/_config.yml +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/docs/architecture.md +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/docs/assets/css/style.scss +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/docs/configuration.md +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/docs/evaluation.md +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/docs/index.md +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/docs/install.md +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/docs/phpstan.md +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/docs/setup.md +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/README.md +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/__init__.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/canaries.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/chained.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/ctor_body_assign.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/declared_property.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/dynamic.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/handler_shapes.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/inheritance.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/interfaces.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/locals_new.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/mail.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/nullable_union.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/promoted.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/same_name_traps.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/secrets.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/services.yaml +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/fixtures/traits.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/reference_set.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/eval/score.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/php/README.md +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/php/autoload.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/php/src/CallGraph/CallEdge.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/php/src/CallGraph/CallEdgeRule.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/php/src/CallGraph/CallEdgeWriter.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/php/src/CallGraph/JsonLinesWriter.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/php/src/CallGraph/MethodCallCollector.php +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/pyproject.toml +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/__init__.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/cli.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/config/__init__.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/config/class_lookup.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/config/discovery.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/config/document.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/config/emit.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/config/environment.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/config/facts.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/config/messaging.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/config/ports.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/config/safe_yaml.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/config_resolver.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/container/__init__.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/container/facts.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/container/layer.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/container/locator.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/container/overlay.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/container/ports.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/container/reader.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/container/reasons.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/core_guard.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/ports.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/shrink.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/shrink_cli.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/sources/phpstan_source.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/syntax/call_sites.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/syntax/class_index.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/syntax/collectors.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/src/graphify_php/syntax/nodes.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/fixtures/shrink/ckeditor/new_graph.json +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/fixtures/shrink/ckeditor/new_manifest.json +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/fixtures/shrink/ckeditor/old_graph.json +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/fixtures/shrink/ckeditor/old_manifest.json +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/fixtures/shrink/ckeditor/present.txt +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/fixtures/shrink/games/new_graph.json +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/fixtures/shrink/games/new_manifest.json +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/fixtures/shrink/games/old_graph.json +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/fixtures/shrink/games/old_manifest.json +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/fixtures/shrink/games/present.txt +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_adapter_graph.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_cli_attribution.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_cli_gate.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_cli_shrink_gate.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_config_readers.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_config_resolver.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_container_integration.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_container_layer.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_container_overlay.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_container_reader.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_engine_contradictions.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_engine_extracted.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_eval_canaries.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_eval_reference_set.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_eval_score.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_new_site_edges.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_phpstan_integration.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_phpstan_source.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_resolver_precedence.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_shrink.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_shrink_attribution.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_shrink_cli.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_status_record.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_syntax_parameters.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_syntax_scan.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_syntax_writes.py +0 -0
- {graphify_php-0.0.6 → graphify_php-0.0.8}/tests/test_tree_sitter_source.py +0 -0
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: graphify-php
|
|
3
|
+
Version: 0.0.8
|
|
4
|
+
Summary: PHP member-call resolution for graphify: binds $this->service->method() to the method node it calls.
|
|
5
|
+
Author: Andrii Afanasiev
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Keywords: call-graph,code-graph,graphify,php,static-analysis
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Requires-Dist: pyyaml>=6.0
|
|
15
|
+
Provides-Extra: lint
|
|
16
|
+
Requires-Dist: ruff>=0.15; extra == 'lint'
|
|
17
|
+
Provides-Extra: test
|
|
18
|
+
Requires-Dist: graphifyy>=0.9.66; extra == 'test'
|
|
19
|
+
Requires-Dist: pytest>=7.0; extra == 'test'
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# graphify-php
|
|
23
|
+
|
|
24
|
+
PHP member-call resolution for [graphify](https://github.com/OxCom/graphify). It binds
|
|
25
|
+
`$this->emails->reminderSubmitWeek($user)` to the method node it actually calls, so a PHP graph
|
|
26
|
+
has a call graph instead of a list of names.
|
|
27
|
+
|
|
28
|
+
## The measurement
|
|
29
|
+
|
|
30
|
+
graphify ships cross-file member-call resolvers for Swift, Python, Ruby, TypeScript, C#, Java
|
|
31
|
+
and Rust, and none for PHP. Its PHP extractor marks `$obj->method()` as a member call and the
|
|
32
|
+
shared cross-file pass then drops it, because a bare `method` collides across the corpus and a
|
|
33
|
+
name-only match is not evidence.
|
|
34
|
+
|
|
35
|
+
On a reference Symfony application (584 PHP files, not shipped with this package), measured
|
|
36
|
+
from the published graph:
|
|
37
|
+
|
|
38
|
+
| | |
|
|
39
|
+
|---|---|
|
|
40
|
+
| PHP callable nodes | 3426 |
|
|
41
|
+
| `calls` edges in the whole graph | 2172 |
|
|
42
|
+
| PHP callables with an outgoing `calls` edge | 24.4 % |
|
|
43
|
+
| PHP callables with an incoming `calls` edge | 20.1 % |
|
|
44
|
+
|
|
45
|
+
Three quarters of the PHP callables in that graph are connected to nothing they call. Every
|
|
46
|
+
"what calls this", "what does this touch" and blast-radius question over PHP is answered from
|
|
47
|
+
that quarter.
|
|
48
|
+
|
|
49
|
+
## What it does
|
|
50
|
+
|
|
51
|
+
The pass runs inside graphify's build, after extraction:
|
|
52
|
+
|
|
53
|
+
1. collects every member call graphify left unresolved, from `per_file[*]["raw_calls"]`;
|
|
54
|
+
2. hands the sources the PHP files graphify parsed as the `corpus` they may read declarations
|
|
55
|
+
from. A leaf service class has nothing unresolved in it, so it never appears among the sites,
|
|
56
|
+
and a source indexing only those files cannot tell whether it declares the method being
|
|
57
|
+
called on it. The set is bounded by the build, never by a filesystem walk;
|
|
58
|
+
3. asks each configured **call target source** in precedence order for the receiver's class —
|
|
59
|
+
the precise source (a PHP type engine that already knows the project's types) first, the
|
|
60
|
+
tree-sitter parser second. A site the first source proves is never offered to the second, so
|
|
61
|
+
a weaker source can add reach but can never overwrite a stronger source's answer;
|
|
62
|
+
4. maps each `(class FQN, method)` to a graphify node id;
|
|
63
|
+
5. appends `calls` edges carrying the target's confidence (`EXTRACTED` when the type was read
|
|
64
|
+
from source, `INFERRED` when it was derived) and `_resolver: "graphify-php"`, which is how a
|
|
65
|
+
reader tells our edges from graphify's own and can drop them without a rebuild. `_via` names
|
|
66
|
+
the technique that proved each one (`tree_sitter:promoted-parameter`, `tree_sitter:self-scope`,
|
|
67
|
+
...).
|
|
68
|
+
|
|
69
|
+
The marker is not `_origin`: graphify overwrites that on every edge with `"ast"` after the
|
|
70
|
+
resolvers run (`extract.py:8285-8289`), where it means the eviction tier rather than the author.
|
|
71
|
+
|
|
72
|
+
### Scoped calls
|
|
73
|
+
|
|
74
|
+
`self::`, `parent::`, `static::` and `Class::method()` reach graphify with `is_member_call`
|
|
75
|
+
false and the **scope** as the callee — the method name is dropped
|
|
76
|
+
(`extractors/engine.py:6147-6152`). The resolver recovers it without parsing PHP: it asks the
|
|
77
|
+
graph which methods that class declares and offers each as a candidate, and the type source
|
|
78
|
+
refuses every name not actually written on that line. A class with ten methods costs ten
|
|
79
|
+
lookups and yields at most one edge.
|
|
80
|
+
|
|
81
|
+
`Class::method()` additionally already has a coarse `caller -> Class` edge, because graphify
|
|
82
|
+
resolves the scope name to the class node. Our method-level edge is a **second** edge between
|
|
83
|
+
different endpoints, so both are published. The narrow one carries `_refines` naming the coarse
|
|
84
|
+
one, so a consumer can collapse the pair instead of counting the call twice.
|
|
85
|
+
|
|
86
|
+
A source returns a target only when it can prove it. Chained calls, dynamic names, `static::`
|
|
87
|
+
and anything through `__call` are counted by reason, not guessed at: a wrong call edge is worse
|
|
88
|
+
than a missing one, and every counted reason is a line on the next version's work list.
|
|
89
|
+
|
|
90
|
+
## Install and register
|
|
91
|
+
|
|
92
|
+
graphify-php is not on PyPI. Install a clone in editable mode into graphify's own environment;
|
|
93
|
+
the PHPStan source needs the `php/` directory of the checkout, which the wheel does not ship:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
git clone https://github.com/OxCom/graphify-php.git ~/src/graphify-php
|
|
97
|
+
pipx inject --editable --include-apps graphifyy ~/src/graphify-php
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The one runtime dependency is pyyaml. graphify and tree-sitter come from the environment that
|
|
101
|
+
runs the build; pinning them here would fight graphify's own pins. Virtual environments,
|
|
102
|
+
PHPStan, verification and troubleshooting: [docs/install.md](docs/install.md).
|
|
103
|
+
|
|
104
|
+
Registration is one call, made before graphify builds:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
import graphify_php
|
|
108
|
+
|
|
109
|
+
graphify_php.register()
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
It is idempotent and imports graphify lazily, so importing the package never requires graphify
|
|
113
|
+
to be installed.
|
|
114
|
+
|
|
115
|
+
## Run a build
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
graphify-php-build -- update .
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Everything after `--` is passed to graphify unchanged; options before it belong to the wrapper:
|
|
122
|
+
|
|
123
|
+
| Option | Meaning |
|
|
124
|
+
|---|---|
|
|
125
|
+
| `--graph PATH` | the graph artifact to protect (default `$GRAPHIFY_OUT/graph.json`) |
|
|
126
|
+
| `--expect RESOLVER` | a resolver that must report; repeatable, defaults to `php_member_calls` |
|
|
127
|
+
|
|
128
|
+
Exit codes:
|
|
129
|
+
|
|
130
|
+
| Code | Meaning |
|
|
131
|
+
|---|---|
|
|
132
|
+
| 0 | every expected resolver reported `completed` or `skipped` |
|
|
133
|
+
| 2 | an expected resolver reported `failed`, or never finished |
|
|
134
|
+
| 3 | an expected resolver never reported at all |
|
|
135
|
+
| other | graphify's own exit code, when graphify itself failed |
|
|
136
|
+
|
|
137
|
+
The wrapper sets `PYTHONHASHSEED=0` before calling graphify. graphify re-execs itself to pin
|
|
138
|
+
that seed for `update`, `extract`, `cluster-only` and `label` (`__main__.py:486-525`), and the
|
|
139
|
+
re-exec would replace the process — losing both the registration and the gate. Setting the seed
|
|
140
|
+
graphify would have set skips the re-exec and keeps its determinism guarantee.
|
|
141
|
+
|
|
142
|
+
## Why the wrapper exists
|
|
143
|
+
|
|
144
|
+
graphify runs registered resolvers like this:
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
try:
|
|
148
|
+
resolver.resolve(per_file, all_nodes, all_edges)
|
|
149
|
+
except Exception as exc:
|
|
150
|
+
_LOG.warning("%s resolution failed, skipping: %s", resolver.name, exc)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
A resolver that raises is skipped and the build still publishes. A resolver that was never
|
|
154
|
+
registered — because the seam moved in a graphify upgrade, or because an install left this
|
|
155
|
+
package out — is not even logged. Both produce a valid graph with fewer `calls` edges, which is
|
|
156
|
+
exactly the shape of the defect this package was written to fix. The failure would be invisible
|
|
157
|
+
at the one moment it matters, and the warning goes to graphify's logger, which nothing running
|
|
158
|
+
the build reads.
|
|
159
|
+
|
|
160
|
+
So each resolver writes its own record — state, and counters that include the denominator,
|
|
161
|
+
because "resolved 400 calls" says nothing without "out of how many" — and `graphify-php-build`
|
|
162
|
+
reads that record and refuses to publish when an expected resolver did not complete. On a
|
|
163
|
+
refusal the previous graph is restored and the exit code is non-zero.
|
|
164
|
+
|
|
165
|
+
`skipped` with a reason is a success: a repository with no PHP type engine in `vendor/` is a
|
|
166
|
+
normal skip, and conflating it with a failure is how a missing layer becomes noise. `failed`,
|
|
167
|
+
and silence, are not.
|
|
168
|
+
|
|
169
|
+
The record path defaults to `graphify-out/.graphify-php-status.json` and is overridable with
|
|
170
|
+
`GRAPHIFY_PHP_STATUS`, so one machine can index many repositories without their builds sharing
|
|
171
|
+
a file.
|
|
172
|
+
|
|
173
|
+
## Routes
|
|
174
|
+
|
|
175
|
+
A second registered pass publishes what `#[Route]` attributes declare. Each declaration becomes
|
|
176
|
+
one node — labelled with the path template, carrying the route name, the HTTP methods and
|
|
177
|
+
whether the path was composed whole — and one `handled_by` edge to the controller method that
|
|
178
|
+
serves it. `route_path` holds the full composed path, `""` when it could not be composed.
|
|
179
|
+
|
|
180
|
+
Every `#[Route]` on a method is a route of its own, stacked in separate groups or listed in one.
|
|
181
|
+
Only the first class-level `#[Route]` is the prefix. An invokable class with no method routes
|
|
182
|
+
turns each class-level `#[Route]` into a route for `__invoke`. A path may be a string literal,
|
|
183
|
+
`self::NAME` for a string constant declared in the same class body, or a `.` concatenation of
|
|
184
|
+
those; `static::NAME`, inherited constants and any `self::NAME` in a trait (where `self` is the
|
|
185
|
+
using class) are refused as `path-not-literal`.
|
|
186
|
+
|
|
187
|
+
The node key is `Class::method#path`, so two controller methods declaring the same path stay two
|
|
188
|
+
nodes. An older measurement of the reference application found more route declarations than
|
|
189
|
+
distinct path templates, the repeats being different HTTP verbs on one path.
|
|
190
|
+
|
|
191
|
+
The relation is `handled_by`, not `routed_to` — the latter already means messenger transport
|
|
192
|
+
routing, and merging the two would put HTTP paths and message transports in one query.
|
|
193
|
+
|
|
194
|
+
A declaration whose controller method is missing from the graph still gets its node; only the
|
|
195
|
+
edge is withheld, and the omission is counted under `controller_not_in_graph`. The path is a
|
|
196
|
+
fact about the codebase either way.
|
|
197
|
+
|
|
198
|
+
Route nodes follow `route_schema: 2` and carry these fields after the ones above. The reason a
|
|
199
|
+
template is `""` or only partly trusted is also on the node, in `route_template_reason` (`""`
|
|
200
|
+
when there is none):
|
|
201
|
+
|
|
202
|
+
- `route_template`: the path with `{name}` placeholders and a leading `/`, `{name?}` for an
|
|
203
|
+
optional one. Symfony inline requirements and defaults are dropped: `{id<\d+>}` is `{id}`,
|
|
204
|
+
`{page<\d+>?1}` and `{page?1}` are `{page?}`. A `defaults:` key also makes a trailing
|
|
205
|
+
placeholder optional. It is `""` when the path could not be composed, or with a counted
|
|
206
|
+
reason: `route-template-multi-segment` when an inline or `requirements:` regex may match `/`
|
|
207
|
+
(anything not provably slash-free counts), `route-template-optional-literal` for an optional
|
|
208
|
+
literal part such as `[/edit]` (other providers), `route-template-unparsed` for a brace that is
|
|
209
|
+
not a placeholder. A `requirements:` value reads like a route path: a string literal,
|
|
210
|
+
`self::NAME` for a string constant declared once in the same class body, or a `.` of those.
|
|
211
|
+
The whole `requirements:` array may be `self::NAME` for a literal array constant declared once
|
|
212
|
+
in the same class body, and that array or an inline one may spread (`...self::OTHER`) another
|
|
213
|
+
such constant; later keys win, and a cycle or any unreadable element leaves the whole array
|
|
214
|
+
unread. Any other value (`static::`, another class, an inherited or trait constant) keeps the template
|
|
215
|
+
and is counted as `route-template-requirement-unread`. The status record shows these under the
|
|
216
|
+
route source's prefix, e.g. `tree_sitter_routes:route-template-multi-segment`.
|
|
217
|
+
- `declared_in`: the declaring file, equal to `source_file`.
|
|
218
|
+
- `effective_guards`: the sorted ids of the guard nodes proved to apply: route-scoped guards
|
|
219
|
+
(`access_control`), guards on the handler method and guards on its class. `checks_access`
|
|
220
|
+
targets are not included. `[]` when none.
|
|
221
|
+
- `authorization_state`: `covered` when an effective guard has `guard_kind: "authorization"`;
|
|
222
|
+
otherwise `undecided` when the `access_control` step could not decide the route or an
|
|
223
|
+
effective guard is `unknown`; otherwise `not_proven`.
|
|
224
|
+
- `authorization_reason`: `""` unless undecided, then `access-control-undecided`,
|
|
225
|
+
`access-control-blocked` (unread `security.yaml`, a config blocker, or a route path or prefix
|
|
226
|
+
that is not a literal) or `guard-kind-unknown`.
|
|
227
|
+
- `handler_kind`: `method` when the node has a `handled_by` edge, `closure` when the action is a
|
|
228
|
+
closure or arrow function (no handler node exists, so no edge), `unresolved` when the named
|
|
229
|
+
handler is not in the graph (counted under `controller_not_in_graph`, no edge). `method` holds
|
|
230
|
+
exactly when a `handled_by` edge leaves the node. A node shared by several declarations is
|
|
231
|
+
`method` when any of them produced the edge.
|
|
232
|
+
|
|
233
|
+
### Laravel provider
|
|
234
|
+
|
|
235
|
+
The Laravel provider (`frameworks/laravel.py`) reads routes files loaded from
|
|
236
|
+
`bootstrap/app.php` `withRouting(web:, api:, apiPrefix:)`. Behaviour follows the framework source
|
|
237
|
+
as recorded in a docs check; each rule cites its item in a `docs-check laravel` comment.
|
|
238
|
+
|
|
239
|
+
Covered:
|
|
240
|
+
|
|
241
|
+
- Verbs, `match`, and `any` as the installed `Router::$verbs`. The version comes from
|
|
242
|
+
`composer.lock` `packages` at minor precision. QUERY and `Route::query()` start at v13.35.0.
|
|
243
|
+
With no version or no minor read (`13.x-dev`), `any` leaves QUERY out and
|
|
244
|
+
`laravel-version-unread` is counted once.
|
|
245
|
+
- Registrar calls straight before a verb (`Route::prefix('p')->get('b', ...)`) are the route
|
|
246
|
+
action, not a group. Inside a group with prefix `g` the path is `p/g/b`. Group middleware comes
|
|
247
|
+
before registrar middleware, and the registrar `as` is appended. A repeated registrar call
|
|
248
|
+
replaces the earlier one; only `withoutMiddleware` accumulates.
|
|
249
|
+
- `Route::controller(X)->get('b', 'm')` does not bind `X`: the route is published with
|
|
250
|
+
`handler_kind: "unresolved"` under `laravel-registrar-controller-rejected-by-framework`,
|
|
251
|
+
unless an enclosing group sets a controller. Laravel itself rejects such a route at
|
|
252
|
+
registration (`RouteAction::makeInvokable` throws "Invalid route action"), so it is not an
|
|
253
|
+
unguarded endpoint.
|
|
254
|
+
- Groups: prefix, `as`, middleware, `withoutMiddleware`, `where`, `controller` (an inner one
|
|
255
|
+
overrides), `namespace` (joined unless it starts with `\`). Array groups take the aliased keys
|
|
256
|
+
`as`, `scope_bindings` and `excluded_middleware`.
|
|
257
|
+
- Route-level `->prefix()` in front of the built URI, applied in written order. Route-level
|
|
258
|
+
`->name()` appends to the name the route already has.
|
|
259
|
+
- String actions get the group namespace unless they start with `\` or with that namespace.
|
|
260
|
+
A `use` line never applies to a string. In a `controller` group, `Foo@bar` keeps its class and
|
|
261
|
+
a bare method name takes the group controller. A bare string that contains `\` or names a
|
|
262
|
+
corpus class is refused, because `class_exists()` decides it at runtime. Array actions get
|
|
263
|
+
neither the controller nor the namespace.
|
|
264
|
+
- Name prefixes (`as`) concatenate with no separator: `name('admin')` and `name('index')` give
|
|
265
|
+
`adminindex`.
|
|
266
|
+
- `resource`, `apiResource`, `resources`, `apiResources`, nested `photos.comments`, `->shallow()`,
|
|
267
|
+
`singleton` and `apiSingleton` with `creatable()` and `destroyable()`. A name with `/`
|
|
268
|
+
(`admin/photos`) registers its last segment inside a prefix group of the rest.
|
|
269
|
+
- Controller middleware from `HasMiddleware::middleware()` and the `#[Middleware]` and
|
|
270
|
+
`#[Authorize]` attributes (from v13.0.0) and `#[WithoutMiddleware]` (from v13.20.0) on a class
|
|
271
|
+
or a method. `#[Authorize('x')]` shares the guard node of `->can('x')` and `can:x`.
|
|
272
|
+
`#[WithoutMiddleware]` removes route and group middleware as well as controller middleware.
|
|
273
|
+
From v13.5.0 a parent class's attributes apply too: they are counted under
|
|
274
|
+
`laravel-controller-attribute-inherited`, not published. From v13.20.0 an inherited
|
|
275
|
+
`#[WithoutMiddleware]`, or a parent outside the corpus (`laravel-controller-parent-unread`),
|
|
276
|
+
leaves that handler with no proved route guard. `Illuminate\Routing\Controller` ends the walk.
|
|
277
|
+
- `withRouting(using:, then:)`: a closure `then` makes Laravel ignore `using` and load the
|
|
278
|
+
`web` / `api` files.
|
|
279
|
+
- Guard kinds: `can` is `authorization`; `auth`, `auth:*`, `auth.basic`, `auth.session`, `guest`,
|
|
280
|
+
`verified` and `password.confirm` are `authentication`; any other alias is `middleware`.
|
|
281
|
+
- Grant calls: `$this->authorize` and `Gate::authorize` (throwing), `Gate::allows`, `denies`,
|
|
282
|
+
`check`, `any` and `none` (conditional).
|
|
283
|
+
|
|
284
|
+
Counted under a `laravel-*` reason, never published: `redirect`, `permanentRedirect` and `view`
|
|
285
|
+
routes (`laravel-route-no-controller`), the `health:` route (`laravel-health-route`), a
|
|
286
|
+
non-literal namespace, a class string in a `controller` group, and a bare `Route::` when
|
|
287
|
+
`config/app.php` lists literal `aliases` without the facade (`laravel-route-alias-removed`).
|
|
288
|
+
Resource `create` and `edit` routes are refused when any file calls `resourceVerbs(...)`
|
|
289
|
+
(`laravel-resource-verbs-changed`). A registrar `prefix`, `name`, `where`, `namespace` or
|
|
290
|
+
`controller` before a resource is refused (`laravel-resource-registrar-attribute`):
|
|
291
|
+
`ResourceRegistrar` gets them as options and does not apply them as a group would.
|
|
292
|
+
|
|
293
|
+
Not covered: Laravel 10 `RouteServiceProvider`, Lumen, `Route::fallback`, invokable string
|
|
294
|
+
actions (`'App\Ctl'`), nested singletons, and `$this->middleware()` in a controller constructor.
|
|
295
|
+
|
|
296
|
+
### Laravel closure routes
|
|
297
|
+
|
|
298
|
+
A Laravel route whose action is a closure or arrow function (`Route::get('/', fn () => ...)`) is
|
|
299
|
+
published like an array action: path, methods, name, template and route-scope guards
|
|
300
|
+
(`middleware`, `can`). It gets `handler_kind: "closure"` and no `handled_by` edge, and it is
|
|
301
|
+
still counted under `laravel-closure-action`. Its node key is
|
|
302
|
+
`laravel:closure:<routes file>:<line>#<path>`, with the routes file repo-relative. A closure has
|
|
303
|
+
no method or class, so no method-scope or class-scope guard and no `checks_access` edge applies;
|
|
304
|
+
`authorization_state` comes from the route-scope guards alone.
|
|
305
|
+
|
|
306
|
+
### CodeIgniter 4 provider
|
|
307
|
+
|
|
308
|
+
The CodeIgniter provider (`frameworks/codeigniter.py`) is selected by a direct
|
|
309
|
+
`codeigniter4/framework` or `codeigniter4/codeigniter4` requirement. It reads the route files of
|
|
310
|
+
`app/Config/Routing.php` `$routeFiles` (a literal list of `APPPATH . 'Config/...'`), else
|
|
311
|
+
`app/Config/Routes.php`, in order. Each rule cites its item in a `docs-check ci4` comment. The
|
|
312
|
+
`codeigniter4/framework` version comes from `composer.lock`; where it matters and is unread,
|
|
313
|
+
`codeigniter-version-unread` is counted once.
|
|
314
|
+
|
|
315
|
+
Covered:
|
|
316
|
+
|
|
317
|
+
- `get`, `post`, `put`, `patch`, `delete`, `options`, `head`; `match()` (verbs lowercased);
|
|
318
|
+
`add()` and `map()` as all nine `Router::HTTP_METHODS`.
|
|
319
|
+
- String handlers `Ctl::method/$1`, prefixed with the `namespace` option or the default namespace
|
|
320
|
+
(`App\Controllers`, `Routing::$defaultNamespace`, or a literal `setDefaultNamespace()`) unless
|
|
321
|
+
they start with `\`: `Admin\Users::index` is prefixed. Array callables `[Ctl::class, 'm']` are
|
|
322
|
+
fully qualified through the imports. Closures are published with `handler_kind: "closure"`.
|
|
323
|
+
- `route_path` is the path as written, with a leading `/`. `(:num)`, `(:alpha)`, `(:alphanum)`,
|
|
324
|
+
`(:segment)`, `(:hash)`, a literal `addPlaceholder()` declared before use, and a raw group
|
|
325
|
+
that cannot match `/` become `{1}`, `{2}`... by position. `(:any)`, `.*`, or a `.` in the path
|
|
326
|
+
give `route_template: ""` with `route-template-multi-segment`.
|
|
327
|
+
- `group()` prefixes. Group options merge into inner groups from 4.5.0 (inner replaces before);
|
|
328
|
+
group filters merge into route filters from 4.5.4. Before 4.5.4, or with no version read, no
|
|
329
|
+
group filter is claimed (`codeigniter-group-filter-version`).
|
|
330
|
+
- `resource()` and `presenter()` tables with `only`, `except` (list or CSV), `websafe`,
|
|
331
|
+
`controller` and `placeholder`. The id placeholder follows the source (`any`, `.*`), not the
|
|
332
|
+
guide's `(:segment)`, so member templates are `""` unless a placeholder is given.
|
|
333
|
+
- Route `filter` options as route-scope guards (`_via: "filter"`, the label keeps arguments).
|
|
334
|
+
`app/Config/Filters.php` before-filters as route-scope guards keyed
|
|
335
|
+
`codeigniter:config#app/Config/Filters.php:<index>` (`_via: "filter_config"`): `$required`
|
|
336
|
+
(4.5.0+), `$globals` minus `except`, `$methods` for routes of only that verb, and `$filters`
|
|
337
|
+
when a pattern provably matches every URL of the route. A partial or undecidable match is
|
|
338
|
+
counted, and makes the route `undecided` when the filter is authorization or unknown.
|
|
339
|
+
- Guard kinds: Shield (only with a direct `codeigniter4/shield` requirement) `session`,
|
|
340
|
+
`tokens`, `hmac`, `jwt`, `chain` are authentication, `group` and `permission` authorization;
|
|
341
|
+
the built-ins, `auth-rates` and `force-reset` are middleware. An alias the application maps to
|
|
342
|
+
another class, and every other alias or class, is `unknown`.
|
|
343
|
+
- `#[Filter(by, having)]` on controller classes and methods from 4.7.0, where
|
|
344
|
+
`Routing::$useControllerAttributes` defaults to true: the label is the route filter spec
|
|
345
|
+
`by` or `by:having,csv`, on the route filter's guard node. A literal `false` is counted per
|
|
346
|
+
attribute (`codeigniter-controller-attributes-disabled`), as is any attribute before 4.7.0
|
|
347
|
+
(`codeigniter-controller-attributes-version`). A non-literal setting, no readable
|
|
348
|
+
`Routing.php`, or no version read is counted once and leaves the routes of `#[Filter]`
|
|
349
|
+
holders `undecided`. A string `having` is a TypeError at runtime
|
|
350
|
+
(`codeigniter-controller-attribute-invalid`). `#[Restrict]` is a route condition
|
|
351
|
+
(`codeigniter-controller-attribute-restrict`), not a guard; `#[Cache]` is ignored.
|
|
352
|
+
- Per key, a verb route beats an `add()`/`map()` route (`RouteCollection.php:504`), which keeps
|
|
353
|
+
the remaining verbs. A verb route with no `filter` option key runs the `*` route's filters
|
|
354
|
+
(`loadRoutesOptions()`, `:1568-1575`); when either key's presence or the `*` route is
|
|
355
|
+
runtime-dependent the route is `undecided` (`codeigniter-route-any-options-undecided`).
|
|
356
|
+
- `$methods`: the exact uppercase key, or from 4.5.0 the deprecated lowercase key when the
|
|
357
|
+
uppercase one is missing. An empty `$filters` path (`''` or `[]`) matches every route; an
|
|
358
|
+
empty `except` matches none. A filter spec with more than one `:` is unread
|
|
359
|
+
(`codeigniter-filter-spec-unread`) and makes a route it may apply to `undecided`.
|
|
360
|
+
`codeigniter-methods-filter-case-bypass` means a route's only authorization guard is a
|
|
361
|
+
`$methods` filter, which a lowercase request method skips, so the route is `undecided`
|
|
362
|
+
(`access-control-undecided`) while the guard edge stays published.
|
|
363
|
+
|
|
364
|
+
Counted under a `codeigniter-*` reason, never published: `cli()`, `view()`, `addRedirect()`,
|
|
365
|
+
routes inside `environment()`, a `$routes` passed to any call (`service('auth')->routes($routes)`),
|
|
366
|
+
module route discovery, auto routing, a duplicate path and verb after the first, an
|
|
367
|
+
unconditional route that shares its key and table with a conditional one, and `match()` with
|
|
368
|
+
TRACE or CONNECT (`codeigniter-match-verb-no-method`: no such `RouteCollection` method).
|
|
369
|
+
Hostname routes are published and counted (`codeigniter-hostname-route`); a `subdomain` is
|
|
370
|
+
ignored when `hostname` is set, else counted as `codeigniter-subdomain-route`.
|
|
371
|
+
A route that loses its GET to a `view()` on its key is refused as
|
|
372
|
+
`codeigniter-route-key-view-collision`; its other verbs still publish. Every route on the key of
|
|
373
|
+
an `addRedirect()` is refused as `codeigniter-route-key-redirect-collision`, unless an
|
|
374
|
+
unconditional `add()`/`map()` route on that key came first and voids the redirect.
|
|
375
|
+
|
|
376
|
+
Not covered: auto-routed controllers, module `Config/Routes.php` files, Shield's own routes,
|
|
377
|
+
`$user->can()` grant calls (a typed receiver; follow-up), filter regex patterns beyond `*`,
|
|
378
|
+
Registrar-added globals, and `{locale}` rewriting.
|
|
379
|
+
|
|
380
|
+
### Access guards
|
|
381
|
+
|
|
382
|
+
Guards are `access_guard` nodes. Three relations reach them:
|
|
383
|
+
|
|
384
|
+
- `guarded_by` with `_via: "attribute"`: from a method or class to each `#[IsGranted]` on it.
|
|
385
|
+
A literal role is one shared node (`guard#ROLE_X`); any other first argument is kept as source
|
|
386
|
+
text and scoped to its class. The edge carries `guard_scope` and `guard_attribute: "IsGranted"`.
|
|
387
|
+
- `checks_access` with `_via: "call"`: from a route handler to the guard named by a direct
|
|
388
|
+
`$this->isGranted(...)` (`conditional: true`) or `$this->denyAccessUnlessGranted(...)`
|
|
389
|
+
(`conditional: false`) in its body. These share the `#[IsGranted]` node. A call whose name
|
|
390
|
+
matches `^can[A-Z]` or `^assert\w*Access` goes to a class-scoped node labelled with the method
|
|
391
|
+
name (`conditional: null`). `GRAPHIFY_PHP_ACCESS_CHECK_PATTERNS` replaces the patterns with a
|
|
392
|
+
comma-separated list; an invalid list falls back to the defaults and is counted. Every
|
|
393
|
+
`checks_access` edge carries `check_kind`: `framework` for `isGranted` and
|
|
394
|
+
`denyAccessUnlessGranted`, `pattern` for a name-matched project method.
|
|
395
|
+
- `guarded_by` with `_via: "access_control"`: from a route node to the
|
|
396
|
+
`config/packages/security.yaml` rule Symfony applies to it. The edge is added only when that
|
|
397
|
+
rule is proved to be the first match for every URL the route template can produce.
|
|
398
|
+
Otherwise the route is counted under `access-control-undecided`. The proof compares the
|
|
399
|
+
literal text before the first placeholder, then goes segment by segment: a placeholder is one
|
|
400
|
+
segment with the value set of its literal requirement (`\d+`, a bounded `\d{n}` or `\d{n,m}`
|
|
401
|
+
with n >= 1, a word alternation, or Symfony's default `[^/]+`), checked against rule segments that are literal, `\d+` or `[^/]+`, an optional
|
|
402
|
+
trailing group of literal alternatives, and an optional `$`. A rule without `$` is a prefix
|
|
403
|
+
match. A same-class `self::NAME` requirement counts as literal, as in `route_template`. Any
|
|
404
|
+
other non-literal requirement, a defaulted or optional placeholder at the deciding segment,
|
|
405
|
+
`{_locale}`/`{_format}`, or any other rule shape leaves the route undecided. A routes import
|
|
406
|
+
that sets `requirements`, `defaults`, `locale` or `format` turns the segment step off
|
|
407
|
+
(`access-control-segment-facts-unread`).
|
|
408
|
+
|
|
409
|
+
Every guard node and every `guarded_by` and `checks_access` edge carries `guard_kind`, and every
|
|
410
|
+
guard node carries `guard_key`, the key its id is hashed from. Symfony keys are unchanged
|
|
411
|
+
(`guard#ROLE_X`, `Class::guard#<text>`, `Class::check#<method>`, `access_control#<index>`).
|
|
412
|
+
Other providers key a guard `guard#<provider>:<guard_kind>:<label>` (or
|
|
413
|
+
`Class::guard#<provider>:<guard_kind>:<text>`) and a config rule
|
|
414
|
+
`<provider>:config#<file>:<index>`. Symfony's `guard_kind`:
|
|
415
|
+
|
|
416
|
+
- an `access_control` rule without `allow_if`: `public` for no roles or a `PUBLIC_ACCESS` /
|
|
417
|
+
`IS_AUTHENTICATED_ANONYMOUSLY` role, `authentication` for an `IS_AUTHENTICATED_*`,
|
|
418
|
+
`IS_REMEMBERED` or `IS_IMPERSONATOR` role, else `authorization`. A request passes on any one
|
|
419
|
+
role, so the weakest role decides;
|
|
420
|
+
- `allow_if`: split at top-level `and` / `&&`; `authorization` when one of those conjuncts is
|
|
421
|
+
exactly a positive `is_granted('X')` with X a role, else `unknown`. A top-level `or` or `||`
|
|
422
|
+
gives `unknown`; one inside parentheses does not. With `roles` too, the weaker of the two kinds
|
|
423
|
+
wins;
|
|
424
|
+
- `#[IsGranted]` and `isGranted` / `denyAccessUnlessGranted`: a literal goes through the role
|
|
425
|
+
rule, anything else is `unknown`;
|
|
426
|
+
- a pattern-matched helper call is `unknown`.
|
|
427
|
+
|
|
428
|
+
The `php_routes` status record carries `route_schema: 2`, `authorization_state` (route nodes per
|
|
429
|
+
state) and `authorization_reason` (undecided routes per reason). It counts `handlers_total` and
|
|
430
|
+
`handlers_unguarded` (handlers with no `authorization` guard edge from the method, its class or
|
|
431
|
+
its routes, and no `check_kind: framework` edge). A
|
|
432
|
+
pattern-only check does not cover a handler. Handlers with no `guarded_by` edge fall into exactly
|
|
433
|
+
one of `handlers_check_framework`, `handlers_check_pattern_only` and `handlers_unchecked`, and
|
|
434
|
+
`handlers_unguarded` equals the last two summed. The record also counts
|
|
435
|
+
`checks_access_declarations`, `checks_access_edges_added`, `access_control_edges_added` and
|
|
436
|
+
`routes_access_control_undecided`.
|
|
437
|
+
|
|
438
|
+
Route schema 2 changes what the `handlers_*` counters mean, so their numbers move without any
|
|
439
|
+
change in the application. Before, any guard counted; now only an `authorization` guard does,
|
|
440
|
+
and a sign-in-only or public `access_control` rule no longer covers a handler. On the reference
|
|
441
|
+
Symfony application (220 handlers) `handlers_unguarded` went from 40 to 130,
|
|
442
|
+
`handlers_check_framework` from 2 to 17, `handlers_check_pattern_only` from 13 to 20 and
|
|
443
|
+
`handlers_unchecked` from 27 to 110. That is a stricter count, not a regression.
|
|
444
|
+
|
|
445
|
+
Limits:
|
|
446
|
+
|
|
447
|
+
- Inherited route methods are not followed, although Symfony reads routes from parent methods.
|
|
448
|
+
- A `use ... as` alias for `Route` or `IsGranted` is not followed.
|
|
449
|
+
- Two stacked routes with the same path on one method collapse to one node.
|
|
450
|
+
- A shared literal guard node keeps the subject and location of the first declaration seen.
|
|
451
|
+
- `access_control` is read from top-level `security.yaml` only, and only a proved first match
|
|
452
|
+
gets an edge. When a `when@<env>` block, another file under `config/packages/`, or a PHP/XML
|
|
453
|
+
file there may declare `access_control`, every such edge is refused as
|
|
454
|
+
`access-control-overridden-elsewhere`.
|
|
455
|
+
- `route_path` is the attribute-declared path. A routes-config import prefix is not applied,
|
|
456
|
+
and when one exists access_control edges are refused as `access-control-route-prefix-unread`.
|
|
457
|
+
Routing PHP and XML files and `src/Kernel.php` get a text check for `prefix` calls only.
|
|
458
|
+
- `checks_access` reads only direct `$this` calls in handler bodies. Closures, arrow functions,
|
|
459
|
+
anonymous classes and helper methods are not followed.
|
|
460
|
+
|
|
461
|
+
## Verifying it works
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
PYTHONPATH=src python -m pytest tests/test_cli_end_to_end.py -q
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
That test generates a small PHP project in a temporary directory, runs graphify over it twice —
|
|
468
|
+
once plain, once with `register()` called first — and asserts the difference. On the generated
|
|
469
|
+
fixture the plain build produces **1** `calls` edge and the registered build **5**. It needs no
|
|
470
|
+
reference application and writes nothing outside `tmp_path`.
|
|
471
|
+
|
|
472
|
+
## Extending
|
|
473
|
+
|
|
474
|
+
Adding a third source — a language server, an LSIF index — means implementing one protocol,
|
|
475
|
+
`CallTargetSource` in `ports.py`, and adding it to the factory in `__init__.py`. `resolver.py`
|
|
476
|
+
depends on the protocols and nothing else, and does not change.
|
|
477
|
+
|
|
478
|
+
## CI
|
|
479
|
+
|
|
480
|
+
GitHub Actions runs three stages in order: **security** (gitleaks, trufflehog, pip-audit,
|
|
481
|
+
`php -l` over `php/`), **tests** (ruff lint and format check, pytest on Python 3.10–3.14) and
|
|
482
|
+
**build** (`python -m build`, then import and `graphify-php-build --help` from the installed
|
|
483
|
+
wheel). The same checks locally: `pip install -e ".[test,lint]"`, then `ruff check .`,
|
|
484
|
+
`ruff format --check .`, `python -m pytest`, and `for f in php/autoload.php php/src/CallGraph/*.php; do php -l "$f"; done`.
|
|
485
|
+
|
|
486
|
+
## License
|
|
487
|
+
|
|
488
|
+
Apache-2.0.
|