-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
19 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,37 @@ | ||
# PHP Language Style Guide | ||
|
||
## Overview | ||
|
||
This style guide expands on the [common style guide](./../common.md). | ||
|
||
## Naming | ||
|
||
### Affirmative Naming | ||
Always name identifiers in the affirmative. If you are setting a `bool` property that determines if redis should be used for a given class, method, or function, name it `$useRedis` instead of `$dontUseRedis`. The exception to this is if you are writing helper methods. It is much easier to determine the outcome of an `if` statement when the condition is `Http::wasSuccessful()` or `Http::wasNotSuccessful()` rather than using a negative modifier. | ||
|
||
Always name identifiers in the affirmative. If you are setting a `bool` property that determines if redis should be used | ||
for a given class, method, or function, name it `$useRedis` instead of `$dontUseRedis`. The exception to this is if you | ||
are writing helper methods. It is much easier to determine the outcome of an `if` statement when the condition | ||
is `Http::wasSuccessful()` or `Http::wasNotSuccessful()` rather than using a negative modifier. | ||
|
||
### Concise Naming | ||
Any identifier should be named as meaningful and concise as possible. If you are naming a parameter that accepts a duration, instead of naming that parameter `$duration`, name it `$durationInSeconds` or whatever unit of time is appropriate for that measurement. | ||
|
||
Any identifier should be named as meaningful and concise as possible. If you are naming a parameter that accepts a | ||
duration, instead of naming that parameter `$duration`, name it `$durationInSeconds` or whatever unit of time is | ||
appropriate for that measurement. | ||
|
||
### `DateTime` Properties | ||
When creating `DateTime` properties, they should be named in the past tense. For example, `publishedAt`, `unpublishedAt`, and `deletedAt` | ||
|
||
When creating `DateTime` properties, they should be named in the past tense. For | ||
example, `publishedAt`, `unpublishedAt`, and `deletedAt` | ||
|
||
## Properties | ||
|
||
### Exception to `camelCase` Property Naming Rule | ||
When writing Laravel Application and Package code, properties are created via the `$fillable` or `$gaurded` model properties. The Laravel convention dictates that these properties should be `snake_case`. | ||
|
||
When writing Laravel Application and Package code, properties are created via the `$fillable` or `$gaurded` model | ||
properties. The Laravel convention dictates that these properties should be `snake_case`. | ||
|
||
### Private Properties | ||
Properties should never be `private`. Only use `public` or `protected`. If you must treat a property as `private`, set it as `protected` and do not create the associated getter or setter methods. | ||
|
||
Properties should never be `private`. Only use `public` or `protected`. If you must treat a property as `private`, set | ||
it as `protected` and do not create the associated getter or setter methods. |