Skip to content

Commit

Permalink
DOC Document PHPDoc as a PHP coding standard
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jan 28, 2024
1 parent fa82367 commit f30dfa8
Showing 1 changed file with 10 additions and 0 deletions.
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.
- All `DataObject` and `Extension` subclasses should 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

0 comments on commit f30dfa8

Please sign in to comment.