Skip to content

Index an open document's global constants - #419

Draft
Firehed wants to merge 2 commits into
mainfrom
slice/SC.16
Draft

Index an open document's global constants#419
Firehed wants to merge 2 commits into
mainfrom
slice/SC.16

Conversation

@Firehed

@Firehed Firehed commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Three of the four symbol backends can enumerate the constants in a namespace; the open-document one could not, because nothing ever put a constant into the index it reads. That is the same lookup-versus-enumeration split that made a function_exists-guarded polyfill resolve on hover while being invisible to completion (SC.5) and dropped a class_exists-guarded class out of open-document lookup (SC.9), on the one symbol namespace where it was still standing. S3.8b adds constant lookup next, so closing it now is what stops that landing on an enumeration with a hole in it.

Slice SC.16. Plan step: 0002 Step 3b. RFC 1 §4.2, §5.1.

What changed

SymbolExtractor emits SymbolKind::Constant for the constants DeclarationScanner reports. Nine lines, because SC.3 already moved this class onto the scanner — the constants were being scanned and discarded.

Reading them from the scanner rather than matching Stmt\Const_ here is what makes the set agree with the on-disk backends: define() with a literal name, several declarators in one const statement, and a declaration nested in a function body all count, while a computed name does not.

Behaviour

No user-visible change. NamespaceCandidates still drops every catalog symbol that is not a class-like, so nothing surfaces these yet — S3.8b owns that, along with lookup.

Tests

  • SymbolExtractorTest gains a namespaced-constant case pinning name, FQN and location, and a case asserting the constants extracted equal the ones DeclarationScanner reports for the same AST, so this class cannot grow a second opinion about what declares a constant.
  • SymbolCoverageGridTest loses its OpenDocumentBackend|Constant|childrenOf not-applicable entry. The grid fails a registration on a cell that answers, so the removal is the proof the cell now answers rather than a claim about it.
  • Reuses the existing AutoloadFiles/helpers.php and AutoloadFiles/globals.php fixtures; no new ones.

Checklist

  • An open document's const and literal define() declarations reach the symbol index
  • The extracted set equals DeclarationScanner's for the same AST
  • The grid's not-applicable entry is removed, not re-pointed at another blocker
  • Baseline unchanged (39 -> 39): no new confined usage
  • No new fixtures

Candidate closes (pending review verification): none.

@codecov

codecov Bot commented Aug 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.61%. Comparing base (71835ac) to head (cf9eef0).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #419   +/-   ##
=========================================
  Coverage     98.61%   98.61%           
- Complexity     1805     1806    +1     
=========================================
  Files           128      128           
  Lines          4534     4540    +6     
=========================================
+ Hits           4471     4477    +6     
  Misses           63       63           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant