@@ -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,41 @@ 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+ filePath = decodeURIComponent ( new URL ( args . source . path ) . pathname )
1555+ }
1556+
1557+ const lines = fs . readFileSync ( filePath , 'utf-8' ) . split ( '\n' )
1558+ const srcLine = lines [ args . line - 1 ]
1559+ if ( ! srcLine ) {
1560+ return false
1561+ }
1562+
1563+ const searchStart = args . column !== undefined ? Math . max ( 0 , args . column - 1 - args . expression . length ) : 0
1564+ const idx = srcLine . indexOf ( args . expression , searchStart )
1565+ if ( idx === - 1 ) {
1566+ return false
1567+ }
1568+
1569+ return srcLine
1570+ . substring ( idx + args . expression . length )
1571+ . trimStart ( )
1572+ . startsWith ( '(' )
1573+ } catch {
1574+ return false
1575+ }
1576+ }
1577+
15381578 protected async evaluateRequest (
15391579 response : VSCodeDebugProtocol . EvaluateResponse ,
15401580 args : EvaluateExtendedArguments
@@ -1554,6 +1594,10 @@ class PhpDebugSession extends vscode.DebugSession {
15541594 let tryEval = true
15551595
15561596 if ( args . context === 'hover' ) {
1597+ if ( this . isHoverOnCallable ( args ) ) {
1598+ this . sendErrorResponse ( response , 0 , '' )
1599+ return
1600+ }
15571601 tryPropertyGet = tryPropertyGetGlobal = true
15581602 tryEval = false
15591603 } else if ( args . context === 'repl' ) {
@@ -1571,7 +1615,7 @@ class PhpDebugSession extends vscode.DebugSession {
15711615 tryEval = true
15721616 }
15731617
1574- // TODO, we need to parse the expression to avoid using propery for things like
1618+ // TODO, we need to parse the expression to avoid using property for things like
15751619 // - $arr[$key]
15761620 // - $x->$key
15771621 // - $$var
0 commit comments