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 @method PHPDoc annotations for relations #163

Closed
GuySartorelli opened this issue Nov 23, 2023 · 3 comments
Closed

Add @method PHPDoc annotations for relations #163

GuySartorelli opened this issue Nov 23, 2023 · 3 comments

Comments

@GuySartorelli
Copy link
Member

GuySartorelli commented Nov 23, 2023

Currently there are no @method annotations for most relations in the Silverstripe CMS codebase. This means there is nothing telling developers which methods they can call to get those lists of relations, let alone what the type of list and items are for those relations. Developers have to refer to the source code to see what relations exist, and for which classes.

We should add @method annotations for all relations added on classes. Member already has some of these as an example.

We should add these using an automated tool, and add a CI component to validate that they are present. That way, as new relations are added, we will see if we've forgotten to add the @method annotations through failed CI jobs, and be able to add them at the time the new relation is added.

Related

Acceptance criteria

  • @method annotations are added to class PHPDoc comments for all relations directly added on that class
    • This applies for all relations (has_one, has_many, many_many)
    • The return type for the method is correct for all @method annotations, including generics (e.g. ManyManyList<SiteTree> for a non-through type many_many to SiteTree, or Image for a has_one to Image)
  • For relations added via extensions, the @method annotation is added to the extension class's PHPDoc
  • Missing @method annotations are picked up by CI (e.g. using phpstan or psalm)
  • Extra @method annotations that don't relate to anything on the class are picked up by CI (e.g. using phpstan or psalm)
  • Update PHP Codding standards to mentioned @method annotation.

Notes

New issues created

Code writer

PRs

@GuySartorelli GuySartorelli changed the title Add @method PHPDoc annotations for relation lists Add @method PHPDoc annotations for relations Nov 23, 2023
@emteknetnz emteknetnz self-assigned this Dec 8, 2023
@emteknetnz
Copy link
Member

emteknetnz commented Dec 12, 2023

I've linked a PR for a new module, this will need to be merged before setting up the CI side of things

@emteknetnz
Copy link
Member

Have added just one PR to framework for peer review for now, if this is OK will do all the other modules on sink

@GuySartorelli
Copy link
Member Author

All linked PRs merged

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

2 participants