Repository: knuckleswtf/scribe (php)

Issue:
Rule::enum overrides description
### Scribe version

4.19.0

### PHP version

8.2.5

### Framework

Laravel

### Framework version

10.8.0

### Scribe config

```ruby
type => "laravel"
```


### What happened?

Validation rule `Rule::enum(...)` overrides description defined in `public static function queryParameters() {...}`, I think it should be appended instead. In the following example it only generates an entry saying `Must be one of red, green, or blue.`.

```php
<?php

namespace App\Http\Requests;

use App\Enums\Colors;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class TestRequest extends FormRequest
{
    public function rules(): array
    {
        return [
            'types.*' => [Rule::enum(Colors::class)],
        ];
    }

    public static function queryParameters(): array
    {
        return [
            'types.*' => [
                'description' => 'This text is overridden with text from enum and never shown.',
            ],
        ];
    }
}
```

```php
<?php

namespace App\Enums;

enum Colors: string
{
    case Red = 'red';
    case Green = 'green';
    case Blue = 'blue';
}
```

### Docs

- [X] I've checked [the docs](https://scribe.knuckles.wtf/laravel), the [troubleshooting guide](https://scribe.knuckles.wtf/laravel/troubleshooting), and [existing issues](https://github.com/knuckleswtf/scribe/issues?q=is%3Aissue+), but I didn't find a solution

Pull request:
fix: enum rule no longer overrides description
Add a missing string concatenation when dealing with enum rules and a test for it.

closes #665

Patch:
diff --git a/src/Extracting/ParsesValidationRules.php b/src/Extracting/ParsesValidationRules.php
index 6fe9dd6b..c39dce40 100644
--- a/src/Extracting/ParsesValidationRules.php
+++ b/src/Extracting/ParsesValidationRules.php
@@ -203,7 +203,7 @@ trait ParsesValidationRules
             if (enum_exists($type) && method_exists($type, 'tryFrom')) {
                 $cases = array_map(fn ($case) => $case->value, $type::cases());
                 $parameterData['type'] = gettype($cases[0]);
-                $parameterData['description'] = ' Must be one of ' . w::getListOfValuesAsFriendlyHtmlString($cases) . ' ';
+                $parameterData['description'] .= ' Must be one of ' . w::getListOfValuesAsFriendlyHtmlString($cases) . ' ';
                 $parameterData['setter'] = fn () => Arr::random($cases);
             }
 


Test patch:
diff --git a/tests/Unit/ValidationRuleParsingTest.php b/tests/Unit/ValidationRuleParsingTest.php
index 90960279..2380162f 100644
--- a/tests/Unit/ValidationRuleParsingTest.php
+++ b/tests/Unit/ValidationRuleParsingTest.php
@@ -554,6 +554,21 @@ class ValidationRuleParsingTest extends BaseLaravelTest
             $results['enum']['example'],
             array_map(fn ($case) => $case->value, Fixtures\TestIntegerBackedEnum::cases())
         ));
+
+        $results = $this->strategy->parse([
+            'enum' => ['required', Rule::enum(Fixtures\TestStringBackedEnum::class)],
+        ], [
+            'enum' => ['description' => 'A description'],
+        ]);
+        $this->assertEquals('string', $results['enum']['type']);
+        $this->assertEquals(
+            'A description. Must be one of <code>red</code>, <code>green</code>, or <code>blue</code>.',
+            $results['enum']['description']
+        );
+        $this->assertTrue(in_array(
+            $results['enum']['example'],
+            array_map(fn ($case) => $case->value, Fixtures\TestStringBackedEnum::cases())
+        ));
     }
 }