Skip to content

chore: add public API snapshot check#165

Draft
marandaneto wants to merge 3 commits into
mainfrom
chore/add-public-api-snapshot
Draft

chore: add public API snapshot check#165
marandaneto wants to merge 3 commits into
mainfrom
chore/add-public-api-snapshot

Conversation

@marandaneto

@marandaneto marandaneto commented Jun 12, 2026

Copy link
Copy Markdown
Member

💡 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/parent type names so the generated JSON stays stable across supported PHP versions.

💚 How did you test it?

  • composer api:check
  • composer validate --no-check-lock --no-check-version --strict
  • php -l scripts/PublicApiSnapshot.php
  • php phpcs.phar --standard=phpcs.xml --no-colors scripts/PublicApiSnapshot.php scripts/check-public-api.php

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

@greptile-apps

greptile-apps Bot commented Jun 12, 2026

Copy link
Copy Markdown
Prompt To Fix All With AI
Fix 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()),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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!

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