Skip to content

Commit db179cd

Browse files
nicklemgithub-actions[bot]
authored andcommitted
gpt: Automated pattern documentation updates
1 parent ad91389 commit db179cd

12 files changed

+15111
-12188
lines changed
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
Classes: Return Type Hint
1+
Validates that return types are properly hinted in CakePHP classes. This improves code readability and reduces runtime errors. For example:
2+
3+
```php
4+
public function getName(): string {
5+
return $this->name;
6+
}
7+
```
8+
Ensures `getName` returns a string.
9+
10+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:33:40.325Z -->
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
Commenting: Doc Block Alignment
1+
DocBlock comments should be properly aligned to enhance readability and consistency in CakePHP codebases. Ensure each line of the DocBlock starts evenly, maintaining the structure and alignment guidelines provided. For example:
2+
```php
3+
/**
4+
* This is a sample DocBlock.
5+
*
6+
* @param string $example Description of parameter.
7+
* @return void
8+
*/
9+
```
10+
11+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:33:51.613Z -->
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,16 @@
1-
Commenting: Function Comment
1+
Ensure all functions in CakePHP are documented using PHPDoc comments for clarity and maintainability. Proper documentation helps in understanding the function's purpose, parameters, and return types. These comments can be used by IDEs for better code completion.
2+
3+
```php
4+
/**
5+
* Adds two numbers.
6+
*
7+
* @param int $a First number.
8+
* @param int $b Second number.
9+
* @return int Sum of the numbers.
10+
*/
11+
function add($a, $b) {
12+
return $a + $b;
13+
}
14+
```
15+
16+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:34:01.575Z -->
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
Commenting: Inherit Doc
1+
Ensures child class members in CakePHP inherit documentation from parent class members. Use the `{@inheritdoc}` tag to seamlessly extend or insert parent documentation into child class comments. Example:
2+
3+
```php
4+
/**
5+
* {@inheritdoc}
6+
*/
7+
```
8+
9+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:34:10.161Z -->
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
Control Structures: Control Structures
1+
Use CakePHP guidelines for control structures to enhance code readability and maintainability. Ensure one space before parentheses, place opening brackets on the same line, and always use curly brackets. Example:
2+
```
3+
if (condition) {
4+
// action
5+
}
6+
```
7+
8+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:34:15.144Z -->
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
Control Structures: Else If Declaration
1+
Adopts the PSR-12 coding style, enforcing use of `elseif` keyword in control structures for consistency and readability. Avoid using `else if` split into two words.
2+
3+
**Example:**
4+
```php
5+
// Incorrect
6+
if ($a == $b) {
7+
// Code
8+
} else if ($a > $b) {
9+
// Code
10+
}
11+
12+
// Correct
13+
if ($a == $b) {
14+
// Code
15+
} elseif ($a > $b) {
16+
// Code
17+
}
18+
```
19+
20+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:34:20.775Z -->
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
Control Structures: While Structures
1+
Apply consistent spaces and curly brackets to while loops for clarity. Always use one space before the parenthesis and employ curly brackets even for single-line statements.
2+
3+
Example:
4+
```
5+
while (condition) {
6+
// code block
7+
}
8+
```
9+
10+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:34:24.767Z -->
Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,23 @@
1-
Formatting: Blank Line Before Return
1+
This pattern recommends adding a blank line before a return statement to enhance code readability and maintain consistency. Adding this line helps visually separate the return from other logic, improving the code's clarity.
2+
```php
3+
// Before
4+
function example() {
5+
if ($condition) {
6+
return $value;
7+
}
8+
$value += 1;
9+
return $value;
10+
}
11+
12+
// After
13+
function example() {
14+
if ($condition) {
15+
return $value;
16+
}
17+
18+
$value += 1;
19+
return $value;
20+
}
21+
```
22+
23+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:34:32.064Z -->
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
Functions: Closure Declaration
1+
Ensures that closures (anonymous functions) in CakePHP are declared following PSR-12 standards, enhancing readability and consistency. Always include spaces around the use keyword and after the function keyword when declaring closures.
2+
3+
```php
4+
// Issue: Non-compliant closure declaration
5+
$closure = function($param){ /* code */ };
6+
7+
// Solution: PSR-12 compliant closure declaration
8+
$closure = function ($param) use ($dependency) { /* code */ };
9+
```
10+
11+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:34:44.285Z -->
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
Naming Conventions: Valid Function Name
1+
Ensure function names in your code adhere to CakePHP's camelBack conventions. Incorrect naming can cause errors and inconsistencies. For example, replace `send_system_email__to_user` with `sendSystemEmailToUser` to meet the standard.
2+
3+
```php
4+
// Incorrect:
5+
function send_system_email__to_user() {
6+
// ...
7+
}
8+
9+
// Correct:
10+
function sendSystemEmailToUser() {
11+
// ...
12+
}
13+
```
14+
15+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:34:49.126Z -->

0 commit comments

Comments
 (0)