chore: add public API snapshot check#165
Draft
marandaneto wants to merge 3 commits into
Draft
Conversation
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
scripts/PublicApiSnapshot.php:170
`getInterfaceNames()` returns interfaces in an implementation-defined order. Sorting the list before storing it guarantees a stable snapshot regardless of PHP version or internal ordering changes, avoiding false-positive diffs.
```suggestion
'implements' => array_values(array_unique($class->getInterfaceNames())),
```
Reviews (1): Last reviewed commit: "fix: stabilize public API type snapshots" | Re-trigger Greptile |
| 'final' => $class->isFinal(), | ||
| 'readonly' => method_exists($class, 'isReadOnly') && $class->isReadOnly(), | ||
| 'extends' => $class->getParentClass() ? $class->getParentClass()->getName() : null, | ||
| 'implements' => array_values($class->getInterfaceNames()), |
There was a problem hiding this comment.
getInterfaceNames() returns interfaces in an implementation-defined order. Sorting the list before storing it guarantees a stable snapshot regardless of PHP version or internal ordering changes, avoiding false-positive diffs.
Suggested change
| 'implements' => array_values($class->getInterfaceNames()), | |
| 'implements' => array_values(array_unique($class->getInterfaceNames())), |
Prompt To Fix With AI
This is a comment left during a code review.
Path: scripts/PublicApiSnapshot.php
Line: 170
Comment:
`getInterfaceNames()` returns interfaces in an implementation-defined order. Sorting the list before storing it guarantees a stable snapshot regardless of PHP version or internal ordering changes, avoiding false-positive diffs.
```suggestion
'implements' => array_values(array_unique($class->getInterfaceNames())),
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Adds a public API snapshot check so accidental public API changes are caught in CI before release. The snapshot generator normalizes
self/parenttype names so the generated JSON stays stable across supported PHP versions.💚 How did you test it?
composer api:checkcomposer validate --no-check-lock --no-check-version --strictphp -l scripts/PublicApiSnapshot.phpphp phpcs.phar --standard=phpcs.xml --no-colors scripts/PublicApiSnapshot.php scripts/check-public-api.php📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file