Repository navigation
Description
Problem
A Scope::MEMBER access (enum case or class constant) that appears in a class-level initializer produces no edge. Only accesses inside a function or method body are linked, because the call-graph pass walks function bodies and nothing else.
Affected positions:
- class constant values:
private const array CATALOG = ['posts.read' => Role::Viewer]; - property defaults:
private Role $fallback = Role::Viewer; - parameter defaults, including promoted constructor properties:
public function __construct(private Role $default = Role::Viewer) {}
This is common in real PHP code. Permission catalogs, state-machine transition maps and config-like classes are often a single const array full of enum cases. On a private Laravel codebase (~3.4k PHP files), one such catalog class has about 80 enum-case accesses and none of them reaches the graph, so the enum looks almost unused and the report flags its cases as weakly connected.
Reproduction
Tested on #4628 (f30d8ef), which adds the corpus-wide resolution for Scope::MEMBER accesses. Without that PR none of the accesses below resolve across files, so the gap is easiest to see on top of it.
src/Role.php:
<?php
enum Role: string
{
case Viewer = 'viewer';
case Editor = 'editor';
case Admin = 'admin';
}src/Permissions.php:
<?php
final class Permissions
{
private const array CATALOG = [
'posts.read' => Role::Viewer,
'posts.write' => Role::Editor,
];
private Role $fallback = Role::Viewer;
public function __construct(private Role $default = Role::Viewer) {}
public function canDelete(Role $role): bool
{
return $role === Role::Admin;
}
}from pathlib import Path
from graphify.extract import extract
root = Path(".")
r = extract(sorted((root / "src").glob("*.php")), cache_root=root / "cache", root=root)
for e in r["edges"]:
if e.get("relation") == "references_constant":
print(e["source"], "->", e["target"], e["source_location"])Output:
src_permissions_permissions_candelete -> src_role_role L16
src_permissions_permissions_candelete -> src_role_role_admin L16
Expected: also edges for lines 6, 7, 10 and 12 (Role::Viewer and Role::Editor).
Suggested direction
When a class_constant_access_expression sits in a const_declaration or property_declaration of a class, use the class node as the caller. For a parameter default, use the function or method that declares the parameter. The rest of the path from #4628 (parking the access in raw_calls and resolving it corpus-wide) should then work unchanged.
Open question: should the class own these edges, or should each constant become its own node? There is no node per class constant today (see #3012), so linking to the class seems like the smallest change that fits the current model.
Happy to send a PR for this once #4628 lands, since it would build on that resolver.
Activity
github-actions commentedon Oct 21, 2026
Thanks for opening this issue, @LucasrsRodrigues. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
niteshyaduvanshi2008-create commentedon Oct 22, 2026
you did not work hard thats why your code is not working ???////
whatnowhater-oss commentedon Oct 22, 2026
fix(extract): link PHP Scope::MEMBER accesses in class-level initiali…