Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new CI check for appropriate generic typehints #181

Open
GuySartorelli opened this issue Jan 14, 2024 · 0 comments
Open

Add new CI check for appropriate generic typehints #181

GuySartorelli opened this issue Jan 14, 2024 · 0 comments

Comments

@GuySartorelli
Copy link
Member

GuySartorelli commented Jan 14, 2024

silverstripe/silverstripe-framework#11066 introduced generic typehints in a bunch of places. We should have a CI check to ensure code changes don't deteriorate this level of type hinting.

Related

Notes

  • While it would be awesome to have CI check that the correct type is being hinted, the most important part is that a type is hinted. We don't have any CI checking for correct types right now, so adding that is out of scope for this card unless it's trivial.

Acceptance criteria

  • CI rules are added using a standardised tool (e.g. PHPStan or PHPCodeSniffer)
  • All subclasses of ContentController, Extension, and implementations of SS_List have a @extends PHPDoc annotation if the class they're a direct subclass of uses a @template annotation
  • If the type in the @extends annotation is a generic type, there is a corresponding @template annotation
  • Methods which return an implementation of SS_List include a generic hint (e.g. instead of just @return DataList it should be @return DataList<SomeDataModel>
  • Classes mentioned in annotations must either be in the same namespace as the class referencing them, or have a use statement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant