feat: Add PHP inheritance extraction and improve method call handling
Addresses PHP's base_clause syntax for class inheritance (extends) and implements clause for interface implementation. Adds trait_declaration support and separates property_declaration into fieldTypes. Improves PHP method call extraction by handling member_call_expression and scoped_call_expression with proper receiver name processing, including $ prefix stripping and self/this/parent/static receiver filtering.
This commit is contained in:
@@ -815,6 +815,37 @@ class UserController
|
||||
expect(classNode).toBeDefined();
|
||||
expect(classNode?.name).toBe('UserController');
|
||||
});
|
||||
|
||||
it('should extract class inheritance (extends) and interface implementation', () => {
|
||||
const code = `<?php
|
||||
|
||||
class ChildController extends BaseController implements Serializable, JsonSerializable
|
||||
{
|
||||
public function serialize(): string
|
||||
{
|
||||
return json_encode($this);
|
||||
}
|
||||
}
|
||||
`;
|
||||
const result = extractFromSource('ChildController.php', code);
|
||||
|
||||
const classNode = result.nodes.find((n) => n.kind === 'class');
|
||||
expect(classNode).toBeDefined();
|
||||
expect(classNode?.name).toBe('ChildController');
|
||||
|
||||
const extendsRef = result.unresolvedReferences.find(
|
||||
(r) => r.referenceKind === 'extends'
|
||||
);
|
||||
expect(extendsRef).toBeDefined();
|
||||
expect(extendsRef?.referenceName).toBe('BaseController');
|
||||
|
||||
const implementsRefs = result.unresolvedReferences.filter(
|
||||
(r) => r.referenceKind === 'implements'
|
||||
);
|
||||
expect(implementsRefs.length).toBe(2);
|
||||
expect(implementsRefs.map((r) => r.referenceName)).toContain('Serializable');
|
||||
expect(implementsRefs.map((r) => r.referenceName)).toContain('JsonSerializable');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Swift Extraction', () => {
|
||||
|
||||
Reference in New Issue
Block a user