PHP: `extends` with a fully qualified name or an aliased import is resolved by short name — wrong or missing INHERITS edge
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start by locating the PHP inheritance edge resolver and its tests; the issue does not name their paths. Compare how it resolves imported names and fully qualified names against the eight-file reproduction in the issue. Done means all listed INHERITS edges point to the expected parent, including aliased imports and duplicate short names.
索引モデルが issue の本文から書いたものです。
説明
Version
codebase-memory-mcp 0.12.1
Platform
Linux (x64)
Install channel
GitHub release archive / install.sh
Binary variant
ui
What happened, and what did you expect?
For a PHP class, the INHERITS edge is resolved by the short name of the parent, not by the name the extends clause gives. Two things follow:
extends \Fully\Qualified\Namelinks to the wrong class when another class with the same short name exists in the child's own namespace. When that other class is the child itself, no edge is written.extends Alias, withuse Some\Class as Alias, writes no edge at all, also when the target is unique.
Expected: the edge goes to the class the fully qualified name or the alias names.
This pattern is common where one package overrides a controller of another package and keeps its class name (TYPO3 extensions, Symfony bundles). A query for all subclasses of a base class then misses the overriding classes, or follows a wrong edge.
Reproduction
- Code, a dummy project of eight files:
<?php // src/Base.php
namespace Acme\Shop;
class Base { public function run(): void {} }
<?php // src/Model/Imported.php
namespace Acme\Shop\Model;
use Acme\Shop\Base;
class Imported extends Base {}
<?php // src/Model/Qualified.php
namespace Acme\Shop\Model;
class Qualified extends \Acme\Shop\Base {}
<?php // src/Controller/NewController.php
namespace Acme\Shop\Controller;
class NewController extends \Acme\Shop\Base {}
<?php // portal/Controller/NewController.php
namespace Acme\Portal\Controller;
class NewController extends \Acme\Shop\Controller\NewController {}
<?php // portal/Controller/ListController.php
namespace Acme\Portal\Controller;
class ListController extends \Acme\Shop\Controller\NewController {}
<?php // portal/Controller/EditController.php
namespace Acme\Portal\Controller;
use Acme\Shop\Controller\NewController as ShopNewController;
class EditController extends ShopNewController {}
<?php // portal/Controller/AliasController.php
namespace Acme\Portal\Controller;
use Acme\Shop\Base as ShopBase;
class AliasController extends ShopBase {}
composer.json: {"name": "acme/shop", "autoload": {"psr-4": {"Acme\\Shop\\": "src/", "Acme\\Portal\\": "portal/"}}}
- MCP tool calls:
index_repository {"repo_path": "/tmp/repro-php", "mode": "full"}
query_graph {"project": "tmp-repro-php", "format": "json",
"query": "MATCH (a:Class)-[r:INHERITS]->(b) RETURN a.name, a.file_path, b.name, b.file_path"}
- Result against expectation:
| Child | extends |
Expected parent | Actual |
|---|---|---|---|
src/Model/Imported.php |
Base (imported) |
src/Base.php |
correct |
src/Model/Qualified.php |
\Acme\Shop\Base |
src/Base.php |
correct |
src/Controller/NewController.php |
\Acme\Shop\Base |
src/Base.php |
correct |
portal/Controller/ListController.php |
\Acme\Shop\Controller\NewController |
src/Controller/NewController.php |
edge to portal/Controller/NewController.php (wrong class) |
portal/Controller/NewController.php |
\Acme\Shop\Controller\NewController |
src/Controller/NewController.php |
no edge |
portal/Controller/EditController.php |
ShopNewController (alias) |
src/Controller/NewController.php |
no edge |
portal/Controller/AliasController.php |
ShopBase (alias) |
src/Base.php |
no edge |
The index reported no gaps: not_indexed_files_count 0, parse_partial_count 0.
My reading, not verified in the source: the resolver takes the last segment of the name and prefers the child's namespace, and it does not map use … as aliases for extends. #2923 describes a similar short-name fallback for Rust.
Project scale (if relevant)
32 nodes / 42 edges / 9 files
Confirmations
- I searched existing issues and this is not a duplicate.
- My reproduction uses shareable code (a dummy snippet or a public OSS repository), not proprietary code.
- 主要言語
- C
- スター
- 45.8k
- フォーク
- 3.8k
- 平均マージ
- 2日 18時間
- マージ済み PR(30日)
- 108
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
DeusData/codebase-memory-mcp のほかの issue
-
bug ux/behavior
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
DeusData/codebase-memory-mcp#3191 ·
メンテナーはふだん 1 日以内に返信
-
documentation enhancement parsing/quality ux/behavior
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
DeusData/codebase-memory-mcp#3131 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
hook-augment: the five-row cap keeps the first five search_graph rows, so variables and modules displace function definitions (v0.12.1)対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug editor/integration parsing/quality ux/behavior
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
DeusData/codebase-memory-mcp#3062 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug documentation editor/integration parsing/quality
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
DeusData/codebase-memory-mcp#3050 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
editor/integration parsing/quality
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
DeusData/codebase-memory-mcp#2286 ·
メンテナーはふだん 1 日以内に返信
DeusData/codebase-memory-mcp の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NVIDIA/open-gpu-kernel-modules#1635 ·
メンテナーはふだん 1 日以内に返信
-
iOS: the "Edit controls" button never hides, even with a controller connected, and covers the gameオープンgame: 010065A014024000 ios
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
seedds/nxnative#3714 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信