Skip to content

Commit

Permalink
gpt: Automated pattern documentation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklem authored and github-actions[bot] committed May 23, 2024
1 parent 2f07e43 commit 96f5a62
Show file tree
Hide file tree
Showing 12 changed files with 15,099 additions and 12,188 deletions.
8 changes: 7 additions & 1 deletion docs/description/CakePHP_Classes_ReturnTypeHint.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
Classes: Return Type Hint
This pattern identifies methods in classes that lack return type hints. Adding explicit return type hints improves code readability and ensures consistency. For instance:
```php
function getUser(): User { /* ... */ }
```
Use the appropriate return type based on what the method returns.

<!-- Codacy PatPatBot reviewed: 2024-05-23T15:18:30.605Z -->
10 changes: 9 additions & 1 deletion docs/description/CakePHP_Commenting_DocBlockAlignment.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
Commenting: Doc Block Alignment
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:
```php
/**
* This is a correctly aligned DocBlock comment.
*/
function example() {}
```

<!-- Codacy PatPatBot reviewed: 2024-05-23T15:18:35.027Z -->
19 changes: 18 additions & 1 deletion docs/description/CakePHP_Commenting_FunctionComment.md
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
Commenting: Function Comment
This pattern checks for thorough PHPDoc comments on functions. Such comments assist in generating documentation and enhance code readability, especially in IDEs.

**Example Issue:**
```php
/**
* Adds two numbers
*
* @param int $a First number
* @param int $b Second number
* @return int Sum of numbers
*/
function add($a, $b) {
return $a + $b;
}
```
Ensure the comment reflects function purpose, parameters, and return type.

<!-- Codacy PatPatBot reviewed: 2024-05-23T15:18:39.545Z -->
12 changes: 11 additions & 1 deletion docs/description/CakePHP_Commenting_InheritDoc.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
Commenting: Inherit Doc
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.
```php
/**
* {@inheritDoc}
*/
public function exampleMethod() {
// Method implementation
}
```

<!-- Codacy PatPatBot reviewed: 2024-05-23T15:18:47.121Z -->
16 changes: 15 additions & 1 deletion docs/description/CakePHP_ControlStructures_ControlStructures.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
Control Structures: Control Structures
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.

Example Issue:
```php
if($condition){
doSomething();
}

Example Solution:
if ($condition) {
doSomething();
}
```

<!-- Codacy PatPatBot reviewed: 2024-05-23T15:18:51.507Z -->
19 changes: 18 additions & 1 deletion docs/description/CakePHP_ControlStructures_ElseIfDeclaration.md
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
Control Structures: Else If Declaration
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.
```php
// Incorrect
if ($a > $b) {
echo "a is greater";
} else if ($a == $b) {
echo "a is equal";
}

// Correct
if ($a > $b) {
echo "a is greater";
} elseif ($a == $b) {
echo "a is equal";
}
```

<!-- Codacy PatPatBot reviewed: 2024-05-23T15:18:56.366Z -->
15 changes: 14 additions & 1 deletion docs/description/CakePHP_ControlStructures_WhileStructures.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
Control Structures: While Structures
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.
Example that violates the standard:
```php
while($condition)
doSomething();
```
Corrected example:
```php
while ($condition) {
doSomething();
}
```

<!-- Codacy PatPatBot reviewed: 2024-05-23T15:19:01.413Z -->
12 changes: 11 additions & 1 deletion docs/description/CakePHP_Formatting_BlankLineBeforeReturn.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
Formatting: Blank Line Before Return
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.
Example:
```
def example():
if condition:
do_something()
return result
```

<!-- Codacy PatPatBot reviewed: 2024-05-23T15:19:05.441Z -->
8 changes: 7 additions & 1 deletion docs/description/CakePHP_Functions_ClosureDeclaration.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
Functions: Closure Declaration
This pattern checks for correct closure declarations in CakePHP, ensuring adherence to PSR-12 standards. Misplaced closures may lead to unpredictable behavior. Example:
```php
$validator->allowEmptyString('somefield', 'This is required', function($context) { return false; });
```
Adjust your declarations for consistency and reliability.

<!-- Codacy PatPatBot reviewed: 2024-05-23T15:19:10.083Z -->
12 changes: 11 additions & 1 deletion docs/description/CakePHP_NamingConventions_ValidFunctionName.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
Naming Conventions: Valid Function Name
This pattern ensures that function names in CakePHP adhere to camelBack convention without double underscores. Correcting function names improves code readability and compatibility.
Example issue:
```php
function send_system_email__to_user() {}
```
Solution:
```php
function sendSystemEmailToUser() {}
```

<!-- Codacy PatPatBot reviewed: 2024-05-23T15:19:14.835Z -->
Loading

0 comments on commit 96f5a62

Please sign in to comment.