Skip to content

Commit

Permalink
Add Variable Naming Style Guideline to Common Language Guide. Include…
Browse files Browse the repository at this point in the history
…d a PHP Example for Good and Bad Examples. (#3)
  • Loading branch information
onairmarc authored Jul 30, 2024
1 parent 0ad5a19 commit d921843
Showing 1 changed file with 42 additions and 14 deletions.
56 changes: 42 additions & 14 deletions guides/common.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Common Language Style Guide

## Capitalization

The following terms describe different forms of capitalization

- StudlyCase
- camelCase
- UPPER_CASE
Expand All @@ -9,17 +12,42 @@ The following terms describe different forms of capitalization

If an identifier contains more than one word, do not use underscores ( _ ) or hyphens ( - ), except when the identifier is using UPPER_CASE or snake_case.

| Identifier | Casing |
| ----------- | ----------- |
| Class | StudlyCase |
| Interface | StudlyCase |
| Enum Type | StudlyCase |
| Enum Value | StudlyCase |
| Constants | UPPER_CASE |
| Properties | camelCase |
| Method Parameters | camelCase |
| Methods Names | camelCase |
| Function Name | snake_case |
| Function Parameters | camelCase |

If you encounter a scenario not covered here, please refer to the language-specific style guide. Please open a PR detailing your proposed solution if the scenario is still not covered.
| Identifier | Casing |
|---------------------|------------|
| Class | StudlyCase |
| Interface | StudlyCase |
| Enum Type | StudlyCase |
| Enum Value | StudlyCase |
| Constants | UPPER_CASE |
| Properties | camelCase |
| Method Parameters | camelCase |
| Methods Names | camelCase |
| Function Name | snake_case |
| Function Parameters | camelCase |


## Variable Naming

Variables should always be named descriptively and concisely. Single character variables should never be used unless otherwise specified in a language
specific style guide.

#### Bad Variable Naming

```php
foreach ($items as $i) {
//do things in the iteration
}
```

#### Good Variable Naming

```php
foreach ($items as $item) {
//do things in the iteration
}
```

## Other Scenarios

If you encounter a scenario not covered here, please refer to the language-specific style guide. Please open a PR detailing your proposed solution if
the scenario is still not covered.

0 comments on commit d921843

Please sign in to comment.