@@ -1304,3 +1304,62 @@ async fn test_goto_definition_this_property_vs_method_disambiguation() {
13041304 other => panic ! ( "Expected Scalar location, got: {:?}" , other) ,
13051305 }
13061306}
1307+
1308+ // ── @method tag: method name matches a type keyword ─────────────────────────
1309+
1310+ #[ tokio:: test]
1311+ async fn test_goto_definition_method_tag_name_matches_type_keyword ( ) {
1312+ let backend = create_test_backend ( ) ;
1313+
1314+ let uri = Url :: parse ( "file:///method_string.php" ) . unwrap ( ) ;
1315+ let text = concat ! (
1316+ "<?php\n " , // 0
1317+ "/**\n " , // 1
1318+ " * @method static string string(string $key, \\ Closure|string|null $default = null)\n " , // 2
1319+ " */\n " , // 3
1320+ "class Config {\n " , // 4
1321+ "}\n " , // 5
1322+ "\n " , // 6
1323+ "Config::string('hello');\n " , // 7
1324+ ) ;
1325+
1326+ let open_params = DidOpenTextDocumentParams {
1327+ text_document : TextDocumentItem {
1328+ uri : uri. clone ( ) ,
1329+ language_id : "php" . to_string ( ) ,
1330+ version : 1 ,
1331+ text : text. to_string ( ) ,
1332+ } ,
1333+ } ;
1334+ backend. did_open ( open_params) . await ;
1335+
1336+ // Click on "string" in `Config::string('hello')` on line 7, character 8
1337+ let params = GotoDefinitionParams {
1338+ text_document_position_params : TextDocumentPositionParams {
1339+ text_document : TextDocumentIdentifier { uri : uri. clone ( ) } ,
1340+ position : Position {
1341+ line : 7 ,
1342+ character : 10 ,
1343+ } ,
1344+ } ,
1345+ work_done_progress_params : WorkDoneProgressParams :: default ( ) ,
1346+ partial_result_params : PartialResultParams :: default ( ) ,
1347+ } ;
1348+
1349+ let result = backend. goto_definition ( params) . await . unwrap ( ) ;
1350+ assert ! (
1351+ result. is_some( ) ,
1352+ "Should resolve Config::string() to the @method tag declaration"
1353+ ) ;
1354+
1355+ match result. unwrap ( ) {
1356+ GotoDefinitionResponse :: Scalar ( location) => {
1357+ assert_eq ! ( location. uri, uri) ;
1358+ assert_eq ! (
1359+ location. range. start. line, 2 ,
1360+ "@method string string(...) is declared on line 2"
1361+ ) ;
1362+ }
1363+ other => panic ! ( "Expected Scalar location, got: {:?}" , other) ,
1364+ }
1365+ }
0 commit comments