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

DOC Document PHPDoc as a PHP coding standard #448

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ Order code in classes in the following order:
- If you do write raw SQL, use double quotes around table/column names and use parameterised queries, for example `->where(['"Score" > ?' => 50])`.
- Use [ANSI SQL](https://en.wikipedia.org/wiki/SQL#Standardization) format.

## PHPDoc

PHPDocs are not only useful when looking at the source code, but are also used in the API documentation at <https://api.silverstripe.org>.

- All [public API](/project_governance/public_api) should have a PHPDoc to describe its purpose, unless the API name and signature describe everything about its usage and purposes without any additional context.
- All `DataObject` and `Extension` subclasses must have `@method` annotations in their PHPDoc for relations (`has_one`, `has_many`, etc).
- Do not add the annotation if a real method is declared with the same name.
- Include the relevant `use` statements for all classes mentioned in the annotation
- Return types should include generics, e.g. `@method HasManyList<Member> Members()`

## Other conventions

- Prefer the identical `===` operator over the equality `==` operator for comparisons.
Expand Down
Loading