@@ -62,6 +62,11 @@ export interface EvaluateExtendedArguments extends VSCodeDebugProtocol.EvaluateA
6262 variablesReference ?: number
6363}
6464
65+ interface EvaluateArgsWithSource extends VSCodeDebugProtocol . EvaluateArguments {
66+ /** Extended evaluate args that include source location for hover context. */
67+ source ?: VSCodeDebugProtocol . Source
68+ }
69+
6570/**
6671 * This interface should always match the schema found in the mock-debug extension manifest.
6772 */
@@ -1535,6 +1540,39 @@ class PhpDebugSession extends vscode.DebugSession {
15351540 return
15361541 }
15371542
1543+ /** Checks if the hovered expression is being called (followed by parentheses). */
1544+ private isHoverOnCallable ( args : EvaluateArgsWithSource ) : boolean {
1545+ if ( ! args . expression || ! args . source ?. path || ! args . line ) {
1546+ return false
1547+ }
1548+
1549+ try {
1550+ let filePath = args . source . path
1551+ if ( filePath . startsWith ( 'file://' ) ) {
1552+ filePath = url . fileURLToPath ( filePath )
1553+ }
1554+
1555+ const lines = fs . readFileSync ( filePath , 'utf-8' ) . split ( '\n' )
1556+ const srcLine = lines [ args . line - 1 ]
1557+ if ( ! srcLine ) {
1558+ return false
1559+ }
1560+
1561+ const searchStart = args . column !== undefined ? Math . max ( 0 , args . column - 1 - args . expression . length ) : 0
1562+ const idx = srcLine . indexOf ( args . expression , searchStart )
1563+ if ( idx === - 1 ) {
1564+ return false
1565+ }
1566+
1567+ return srcLine
1568+ . substring ( idx + args . expression . length )
1569+ . trimStart ( )
1570+ . startsWith ( '(' )
1571+ } catch {
1572+ return false
1573+ }
1574+ }
1575+
15381576 protected async evaluateRequest (
15391577 response : VSCodeDebugProtocol . EvaluateResponse ,
15401578 args : EvaluateExtendedArguments
@@ -1554,6 +1592,10 @@ class PhpDebugSession extends vscode.DebugSession {
15541592 let tryEval = true
15551593
15561594 if ( args . context === 'hover' ) {
1595+ if ( this . isHoverOnCallable ( args ) ) {
1596+ this . sendErrorResponse ( response , 0 , '' )
1597+ return
1598+ }
15571599 tryPropertyGet = tryPropertyGetGlobal = true
15581600 tryEval = false
15591601 } else if ( args . context === 'repl' ) {
@@ -1571,7 +1613,7 @@ class PhpDebugSession extends vscode.DebugSession {
15711613 tryEval = true
15721614 }
15731615
1574- // TODO, we need to parse the expression to avoid using propery for things like
1616+ // TODO, we need to parse the expression to avoid using property for things like
15751617 // - $arr[$key]
15761618 // - $x->$key
15771619 // - $$var
0 commit comments