Skip to content

Commit 96f5a62

Browse files
nicklemgithub-actions[bot]
authored andcommitted
gpt: Automated pattern documentation updates
1 parent 2f07e43 commit 96f5a62

12 files changed

+15099
-12188
lines changed
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
Classes: Return Type Hint
1+
This pattern identifies methods in classes that lack return type hints. Adding explicit return type hints improves code readability and ensures consistency. For instance:
2+
```php
3+
function getUser(): User { /* ... */ }
4+
```
5+
Use the appropriate return type based on what the method returns.
6+
7+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:18:30.605Z -->
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
Commenting: Doc Block Alignment
1+
Ensures that the opening tag of a DocBlock comment is the sole content on its line. This improves code readability and compliance with PHPDoc standards. For example:
2+
```php
3+
/**
4+
* This is a correctly aligned DocBlock comment.
5+
*/
6+
function example() {}
7+
```
8+
9+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:18:35.027Z -->
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1-
Commenting: Function Comment
1+
This pattern checks for thorough PHPDoc comments on functions. Such comments assist in generating documentation and enhance code readability, especially in IDEs.
2+
3+
**Example Issue:**
4+
```php
5+
/**
6+
* Adds two numbers
7+
*
8+
* @param int $a First number
9+
* @param int $b Second number
10+
* @return int Sum of numbers
11+
*/
12+
function add($a, $b) {
13+
return $a + $b;
14+
}
15+
```
16+
Ensure the comment reflects function purpose, parameters, and return type.
17+
18+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:18:39.545Z -->
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
Commenting: Inherit Doc
1+
This pattern highlights the use of `@inheritDoc` to inherit documentation from a parent class, reducing redundancy and maintaining consistency. Ensure that inherited methods have appropriate docblocks, even if they use the parent class documentation.
2+
```php
3+
/**
4+
* {@inheritDoc}
5+
*/
6+
public function exampleMethod() {
7+
// Method implementation
8+
}
9+
```
10+
11+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:18:47.121Z -->
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
Control Structures: Control Structures
1+
This pattern checks compliance with CakePHP's guidelines for control structures. Ensure a space before parentheses, always use curly brackets, and maintain consistent indentation for improved readability. Aim for uniformity across the codebase.
2+
3+
Example Issue:
4+
```php
5+
if($condition){
6+
doSomething();
7+
}
8+
9+
Example Solution:
10+
if ($condition) {
11+
doSomething();
12+
}
13+
```
14+
15+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:18:51.507Z -->
Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
1-
Control Structures: Else If Declaration
1+
This pattern ensures that `elseif` is used instead of `else if` in control structures for better readability and consistency. The `elseif` keyword should be utilized to maintain uniformity.
2+
```php
3+
// Incorrect
4+
if ($a > $b) {
5+
echo "a is greater";
6+
} else if ($a == $b) {
7+
echo "a is equal";
8+
}
9+
10+
// Correct
11+
if ($a > $b) {
12+
echo "a is greater";
13+
} elseif ($a == $b) {
14+
echo "a is equal";
15+
}
16+
```
17+
18+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:18:56.366Z -->
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
Control Structures: While Structures
1+
Ensures 'while' control structures follow specified style: one space before the opening parenthesis, one space after the closing parenthesis, and curly brackets around the loop body. Enhances readability and consistency.
2+
Example that violates the standard:
3+
```php
4+
while($condition)
5+
doSomething();
6+
```
7+
Corrected example:
8+
```php
9+
while ($condition) {
10+
doSomething();
11+
}
12+
```
13+
14+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:19:01.413Z -->
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
Formatting: Blank Line Before Return
1+
This rule enforces the presence of a blank line before return statements to improve code readability. Maintaining consistency and clarity in function structures is encouraged.
2+
Example:
3+
```
4+
def example():
5+
if condition:
6+
do_something()
7+
8+
return result
9+
```
10+
11+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:19:05.441Z -->
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
Functions: Closure Declaration
1+
This pattern checks for correct closure declarations in CakePHP, ensuring adherence to PSR-12 standards. Misplaced closures may lead to unpredictable behavior. Example:
2+
```php
3+
$validator->allowEmptyString('somefield', 'This is required', function($context) { return false; });
4+
```
5+
Adjust your declarations for consistency and reliability.
6+
7+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:19:10.083Z -->
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
Naming Conventions: Valid Function Name
1+
This pattern ensures that function names in CakePHP adhere to camelBack convention without double underscores. Correcting function names improves code readability and compatibility.
2+
Example issue:
3+
```php
4+
function send_system_email__to_user() {}
5+
```
6+
Solution:
7+
```php
8+
function sendSystemEmailToUser() {}
9+
```
10+
11+
<!-- Codacy PatPatBot reviewed: 2024-05-23T15:19:14.835Z -->

0 commit comments

Comments
 (0)