Skip to content

Commit

Permalink
Reformat MD for php.md
Browse files Browse the repository at this point in the history
  • Loading branch information
onairmarc committed Apr 12, 2024
1 parent 0e88df6 commit 1935d5b
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions guides/lang/php.md
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.

0 comments on commit 1935d5b

Please sign in to comment.