@@ -23,6 +23,8 @@ final class TreeSitterLanguagePack
2323 * assert_eq!(detect_language_from_extension("xyz"), None);
2424 * ```
2525 *
26+ * @param string $ext
27+ * @return ?string
2628 */
2729 public static function detectLanguageFromExtension (string $ ext ): ?string
2830 {
@@ -42,6 +44,8 @@ public static function detectLanguageFromExtension(string $ext): ?string
4244 * assert_eq!(detect_language_from_path("Makefile"), None);
4345 * ```
4446 *
47+ * @param string $path
48+ * @return ?string
4549 */
4650 public static function detectLanguageFromPath (string $ path ): ?string
4751 {
@@ -72,6 +76,8 @@ public static function detectLanguageFromPath(string $path): ?string
7276 * assert_eq!(detect_language_from_content("no shebang here"), None);
7377 * ```
7478 *
79+ * @param string $content
80+ * @return ?string
7581 */
7682 public static function detectLanguageFromContent (string $ content ): ?string
7783 {
@@ -81,6 +87,8 @@ public static function detectLanguageFromContent(string $content): ?string
8187 /**
8288 * Get a `NodeInfo` snapshot of the root node.
8389 *
90+ * @param Tree $tree
91+ * @return NodeInfo
8492 */
8593 public static function rootNodeInfo (Tree $ tree ): NodeInfo
8694 {
@@ -92,6 +100,8 @@ public static function rootNodeInfo(Tree $tree): NodeInfo
92100 *
93101 * Performs a depth-first traversal. Returns an empty vec if no matches.
94102 *
103+ * @param Tree $tree
104+ * @param string $node_type
95105 * @return array<NodeInfo>
96106 */
97107 public static function findNodesByType (Tree $ tree , string $ node_type ): array
@@ -105,6 +115,7 @@ public static function findNodesByType(Tree $tree, string $node_type): array
105115 * Useful for understanding the top-level structure of a file
106116 * (e.g., list of function definitions, class declarations, imports).
107117 *
118+ * @param Tree $tree
108119 * @return array<NodeInfo>
109120 */
110121 public static function namedChildrenInfo (Tree $ tree ): array
@@ -126,6 +137,9 @@ public static function namedChildrenInfo(Tree $tree): array
126137 * assert_eq!(tree.root_node().kind(), "module");
127138 * ```
128139 *
140+ * @param string $language
141+ * @param string $source
142+ * @return Tree
129143 * @throws \Tree\Sitter\Language\Pack\TreeSitterLanguagePackException
130144 */
131145 public static function parseString (string $ language , string $ source ): Tree
@@ -138,6 +152,9 @@ public static function parseString(string $language, string $source): Tree
138152 *
139153 * Performs a depth-first traversal using `TreeCursor`.
140154 *
155+ * @param Tree $tree
156+ * @param string $node_type
157+ * @return bool
141158 */
142159 public static function treeContainsNodeType (Tree $ tree , string $ node_type ): bool
143160 {
@@ -149,6 +166,8 @@ public static function treeContainsNodeType(Tree $tree, string $node_type): bool
149166 *
150167 * Useful for determining if the parse was clean or had syntax errors.
151168 *
169+ * @param Tree $tree
170+ * @return bool
152171 */
153172 public static function treeHasErrorNodes (Tree $ tree ): bool
154173 {
@@ -161,6 +180,8 @@ public static function treeHasErrorNodes(Tree $tree): bool
161180 * This is the standard tree-sitter debug format, useful for logging,
162181 * snapshot testing, and debugging grammars.
163182 *
183+ * @param Tree $tree
184+ * @return string
164185 */
165186 public static function treeToSexp (Tree $ tree ): string
166187 {
@@ -172,6 +193,8 @@ public static function treeToSexp(Tree $tree): string
172193 *
173194 * Returns 0 for a clean parse.
174195 *
196+ * @param Tree $tree
197+ * @return int
175198 */
176199 public static function treeErrorCount (Tree $ tree ): int
177200 {
@@ -196,6 +219,8 @@ public static function treeErrorCount(Tree $tree): int
196219 * assert!(missing.is_none());
197220 * ```
198221 *
222+ * @param string $language
223+ * @return ?string
199224 */
200225 public static function getHighlightsQuery (string $ language ): ?string
201226 {
@@ -219,6 +244,8 @@ public static function getHighlightsQuery(string $language): ?string
219244 * assert!(missing.is_none());
220245 * ```
221246 *
247+ * @param string $language
248+ * @return ?string
222249 */
223250 public static function getInjectionsQuery (string $ language ): ?string
224251 {
@@ -242,6 +269,8 @@ public static function getInjectionsQuery(string $language): ?string
242269 * assert!(missing.is_none());
243270 * ```
244271 *
272+ * @param string $language
273+ * @return ?string
245274 */
246275 public static function getLocalsQuery (string $ language ): ?string
247276 {
@@ -278,6 +307,10 @@ public static function getLocalsQuery(string $language): ?string
278307 * assert!(!matches.is_empty());
279308 * ```
280309 *
310+ * @param Tree $tree
311+ * @param string $language
312+ * @param string $query_source
313+ * @param string $source
281314 * @return array<QueryMatch>
282315 * @throws \Tree\Sitter\Language\Pack\TreeSitterLanguagePackException
283316 */
@@ -311,6 +344,8 @@ public static function runQuery(Tree $tree, string $language, string $query_sour
311344 * assert_eq!(tree.root_node().kind(), "module");
312345 * ```
313346 *
347+ * @param string $name
348+ * @return Language
314349 * @throws \Tree\Sitter\Language\Pack\TreeSitterLanguagePackException
315350 */
316351 public static function getLanguage (string $ name ): Language
@@ -339,6 +374,8 @@ public static function getLanguage(string $name): Language
339374 * assert!(!tree.root_node().has_error());
340375 * ```
341376 *
377+ * @param string $name
378+ * @return Parser
342379 * @throws \Tree\Sitter\Language\Pack\TreeSitterLanguagePackException
343380 */
344381 public static function getParser (string $ name ): Parser
@@ -386,6 +423,8 @@ public static function availableLanguages(): array
386423 * assert!(!has_language("nonexistent_language"));
387424 * ```
388425 *
426+ * @param string $name
427+ * @return bool
389428 */
390429 public static function hasLanguage (string $ name ): bool
391430 {
@@ -407,6 +446,7 @@ public static function hasLanguage(string $name): bool
407446 * println!("{} languages available", count);
408447 * ```
409448 *
449+ * @return int
410450 */
411451 public static function languageCount (): int
412452 {
@@ -436,6 +476,9 @@ public static function languageCount(): int
436476 * println!("Structures: {}", result.structure.len());
437477 * ```
438478 *
479+ * @param string $source
480+ * @param ProcessConfig $config
481+ * @return ProcessResult
439482 * @throws \Tree\Sitter\Language\Pack\TreeSitterLanguagePackException
440483 */
441484 public static function process (string $ source , ProcessConfig $ config ): ProcessResult
@@ -471,6 +514,9 @@ public static function process(string $source, ProcessConfig $config): ProcessRe
471514 * let result = extract_patterns("def hello(): pass", &config).unwrap();
472515 * ```
473516 *
517+ * @param string $source
518+ * @param ExtractionConfig $config
519+ * @return ExtractionResult
474520 * @throws \Tree\Sitter\Language\Pack\TreeSitterLanguagePackException
475521 */
476522 public static function extractPatterns (string $ source , ExtractionConfig $ config ): ExtractionResult
@@ -487,6 +533,8 @@ public static function extractPatterns(string $source, ExtractionConfig $config)
487533 *
488534 * Returns an error if the language cannot be loaded.
489535 *
536+ * @param ExtractionConfig $config
537+ * @return ValidationResult
490538 * @throws \Tree\Sitter\Language\Pack\TreeSitterLanguagePackException
491539 */
492540 public static function validateExtraction (ExtractionConfig $ config ): ValidationResult
@@ -518,6 +566,8 @@ public static function validateExtraction(ExtractionConfig $config): ValidationR
518566 * init(&config).unwrap();
519567 * ```
520568 *
569+ * @param PackConfig $config
570+ * @return void
521571 * @throws \Tree\Sitter\Language\Pack\TreeSitterLanguagePackException
522572 */
523573 public static function init (PackConfig $ config ): void
@@ -551,6 +601,8 @@ public static function init(PackConfig $config): void
551601 * configure(&config).unwrap();
552602 * ```
553603 *
604+ * @param PackConfig $config
605+ * @return void
554606 * @throws \Tree\Sitter\Language\Pack\TreeSitterLanguagePackException
555607 */
556608 public static function configure (PackConfig $ config ): void
@@ -579,6 +631,7 @@ public static function configure(PackConfig $config): void
579631 * ```
580632 *
581633 * @param array<string> $names
634+ * @return int
582635 * @throws \Tree\Sitter\Language\Pack\TreeSitterLanguagePackException
583636 */
584637 public static function download (array $ names ): int
@@ -604,6 +657,7 @@ public static function download(array $names): int
604657 * println!("Downloaded {} languages", count);
605658 * ```
606659 *
660+ * @return int
607661 * @throws \Tree\Sitter\Language\Pack\TreeSitterLanguagePackException
608662 */
609663 public static function downloadAll (): int
@@ -680,6 +734,7 @@ public static function downloadedLanguages(): array
680734 * println!("Cache cleared");
681735 * ```
682736 *
737+ * @return void
683738 * @throws \Tree\Sitter\Language\Pack\TreeSitterLanguagePackException
684739 */
685740 public static function cleanCache (): void
@@ -706,6 +761,7 @@ public static function cleanCache(): void
706761 * println!("Cache directory: {}", dir.display());
707762 * ```
708763 *
764+ * @return string
709765 * @throws \Tree\Sitter\Language\Pack\TreeSitterLanguagePackException
710766 */
711767 public static function cacheDir (): string
0 commit comments