Repository: knuckleswtf/scribe (php)

Issue:
required array marked as optional
**What happened?**
I have a custom FormRequest object containing the following:
```
public function rules()
{
    return [
        'events' => 'required|array',
        'events.*.name' => ['required', 'string', 'max:200', new UniqueEventName]
    ];
}
```

after running php artisan scribe:generate
the endpoint using the request shows
`events   object[]  optional`

**My environment:**
 - PHP version (from `php -v`): 8.1.14
 - Framework (Laravel/Lumen): Laravel
 - Laravel/Lumen version (from `composer show laravel/framework` or `composer show laravel/lumen-framework`): v8.83.27
 - Scribe version (from `composer show knuckleswtf/scribe`): 4.13.0

**My Scribe config (from `php artisan scribe:config:diff`):**
try_it_out.enabled => false
auth.enabled => true
auth.default => true
postman.enabled => false
openapi.enabled => false
strategies.metadata => removed Knuckles\Scribe\Extracting\Strategies\Metadata\GetFromMetadataAttributes
strategies.urlParameters => removed Knuckles\Scribe\Extracting\Strategies\UrlParameters\GetFromUrlParamAttribute
strategies.queryParameters => removed Knuckles\Scribe\Extracting\Strategies\QueryParameters\GetFromQueryParamAttribute
strategies.headers => removed Knuckles\Scribe\Extracting\Strategies\Headers\GetFromHeaderAttribute
strategies.bodyParameters => removed Knuckles\Scribe\Extracting\Strategies\BodyParameters\GetFromBodyParamAttribute
strategies.responses => removed Knuckles\Scribe\Extracting\Strategies\Responses\UseResponseAttributes
strategies.responseFields => removed Knuckles\Scribe\Extracting\Strategies\ResponseFields\GetFromResponseFieldAttribute

**Additional info:**
I think the issue is within Extracting/ParsesValidationRules:addMissingParentFields()
on the first run through the loop `$results['events']` is set as type array, required true
on the second run through there is the test
`if (empty($results[$normalisedParentPath]))` where `$normalisedParentPath = 'events.*'`
but then this variable has the last two characters trimmed from it and it overwrites `$results['events']` setting required = false


Pull request description:
Required array overwritten
addMissingParentFields was checking for the existence of 'name.*' but then renaming to 'name' before saving.
Add a check to see if 'name' already exists to avoid overwriting a parent that is not missing.

fix #608

Patch:
diff --git a/src/Extracting/ParsesValidationRules.php b/src/Extracting/ParsesValidationRules.php
index 862f4815..9c3c0b08 100644
--- a/src/Extracting/ParsesValidationRules.php
+++ b/src/Extracting/ParsesValidationRules.php
@@ -658,6 +658,10 @@ trait ParsesValidationRules
                         $parentPath = substr($parentPath, 0, -2);
                         $normalisedParentPath = str_replace('.*.', '[].', $parentPath);
 
+                        if (!empty($results[$normalisedParentPath])) {
+                            break;
+                        }
+
                         $type = 'object[]';
                         $example = [[]];
                     } else {


Test patch:
diff --git a/tests/Unit/ValidationRuleParsingTest.php b/tests/Unit/ValidationRuleParsingTest.php
index 371b66dc..e9a904bd 100644
--- a/tests/Unit/ValidationRuleParsingTest.php
+++ b/tests/Unit/ValidationRuleParsingTest.php
@@ -438,6 +438,19 @@ class ValidationRuleParsingTest extends BaseLaravelTest
             ];
         }
     }
+
+    /** @test */
+    public function child_does_not_overwrite_parent_status()
+    {
+        $ruleset = [
+            'array_param' => 'array|required',
+            'array_param.*' => 'array|required',
+            'array_param.*.an_item' => 'string|required',
+        ];
+        $results = $this->strategy->parse($ruleset);
+        $this->assertCount(2, $results);
+        $this->assertEquals(true, $results['array_param']['required']);
+    }
 }
 
 class DummyValidationRule implements \Illuminate\Contracts\Validation\Rule