@@ -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,45 @@ 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 : string
1551+ if ( args . source . path . startsWith ( 'file://' ) ) {
1552+ filePath = url . fileURLToPath ( args . source . path )
1553+ } else {
1554+ try {
1555+ filePath = decodeURIComponent ( new URL ( args . source . path ) . pathname )
1556+ } catch {
1557+ return false
1558+ }
1559+ }
1560+
1561+ const lines = fs . readFileSync ( filePath , 'utf-8' ) . split ( '\n' )
1562+ const srcLine = lines [ args . line - 1 ]
1563+ if ( ! srcLine ) {
1564+ return false
1565+ }
1566+
1567+ const searchStart = args . column !== undefined ? Math . max ( 0 , args . column - 1 - args . expression . length ) : 0
1568+ const idx = srcLine . indexOf ( args . expression , searchStart )
1569+ if ( idx === - 1 ) {
1570+ return false
1571+ }
1572+
1573+ return srcLine
1574+ . substring ( idx + args . expression . length )
1575+ . trimStart ( )
1576+ . startsWith ( '(' )
1577+ } catch {
1578+ return false
1579+ }
1580+ }
1581+
15381582 protected async evaluateRequest (
15391583 response : VSCodeDebugProtocol . EvaluateResponse ,
15401584 args : EvaluateExtendedArguments
@@ -1554,6 +1598,10 @@ class PhpDebugSession extends vscode.DebugSession {
15541598 let tryEval = true
15551599
15561600 if ( args . context === 'hover' ) {
1601+ if ( this . isHoverOnCallable ( args ) ) {
1602+ this . sendErrorResponse ( response , 0 , '' )
1603+ return
1604+ }
15571605 tryPropertyGet = tryPropertyGetGlobal = true
15581606 tryEval = false
15591607 } else if ( args . context === 'repl' ) {
@@ -1571,7 +1619,7 @@ class PhpDebugSession extends vscode.DebugSession {
15711619 tryEval = true
15721620 }
15731621
1574- // TODO, we need to parse the expression to avoid using propery for things like
1622+ // TODO, we need to parse the expression to avoid using property for things like
15751623 // - $arr[$key]
15761624 // - $x->$key
15771625 // - $$var
0 commit comments