Browse Source

Merge remote-tracking branch 'origin/master'

shalvah 2 years ago
parent
commit
8968e0b561
3 changed files with 109 additions and 92 deletions
  1. 92 92
      composer.json
  2. 4 0
      src/Extracting/ParsesValidationRules.php
  3. 13 0
      tests/Unit/ValidationRuleParsingTest.php

+ 92 - 92
composer.json

@@ -1,94 +1,94 @@
 {
-  "name": "knuckleswtf/scribe",
-  "license": "MIT",
-  "description": "Generate API documentation for humans from your Laravel codebase.✍",
-  "keywords": [
-    "API",
-    "documentation",
-    "laravel",
-    "dingo"
-  ],
-  "homepage": "http://github.com/knuckleswtf/scribe",
-  "authors": [
-    {
-      "name": "Shalvah"
-    }
-  ],
-  "require": {
-    "php": ">=8.0",
-    "ext-fileinfo": "*",
-    "ext-json": "*",
-    "ext-pdo": "*",
-    "erusev/parsedown": "1.7.4",
-    "fakerphp/faker": "^1.9.1",
-    "illuminate/console": "^8.0|^9.0",
-    "illuminate/routing": "^8.0|^9.0",
-    "illuminate/support": "^8.0|^9.0",
-    "league/flysystem": "^1.1.4|^2.1.1|^3.0",
-    "mpociot/reflection-docblock": "^1.0.1",
-    "nikic/php-parser": "^4.10",
-    "nunomaduro/collision": "^5.10|^6.0",
-    "ramsey/uuid": "^4.2.2",
-    "shalvah/clara": "^3.1.0",
-    "shalvah/upgrader": "^0.3.0",
-    "spatie/data-transfer-object": "^2.6|^3.0",
-    "symfony/var-exporter": "^5.4|^6.0",
-    "symfony/yaml": "^5.4|^6.0"
-  },
-  "require-dev": {
-    "brianium/paratest": "^6.0",
-    "dms/phpunit-arraysubset-asserts": "^0.2.0",
-    "laravel/legacy-factories": "^1.3.0",
-    "laravel/lumen-framework": "^8.0|^9.0",
-    "league/fractal": "^0.19.0",
-    "nikic/fast-route": "^1.3",
-    "orchestra/testbench": "^6.0|^7.0",
-    "pestphp/pest": "^1.21",
-    "phpstan/phpstan": "^1.0",
-    "phpunit/phpunit": "^9.0|^10.0",
-    "symfony/css-selector": "^5.4|^6.0",
-    "symfony/dom-crawler": "^5.4|^6.0"
-  },
-  "autoload": {
-    "psr-4": {
-      "Knuckles\\Scribe\\": "src/",
-      "Knuckles\\Camel\\": "camel/"
-    }
-  },
-  "autoload-dev": {
-    "psr-4": {
-      "Knuckles\\Scribe\\Tests\\": "tests/"
-    }
-  },
-  "scripts": {
-    "lint": "phpstan analyse -c ./phpstan.neon src camel --memory-limit 1G",
-    "test": "pest --stop-on-failure --exclude-group dingo --coverage --colors",
-    "test-ci": "pest --exclude-group dingo --coverage --min=80",
-    "test-parallel": "paratest -p16 --stop-on-failure --exclude-group dingo",
-    "test-parallel-ci": "paratest -p16 --exclude-group dingo"
-  },
-  "extra": {
-    "laravel": {
-      "providers": [
-        "Knuckles\\Scribe\\ScribeServiceProvider"
-      ]
-    }
-  },
-  "config": {
-    "preferred-install": "dist",
-    "sort-packages": true,
-    "process-timeout": 600,
-    "allow-plugins": {
-      "pestphp/pest-plugin": true
-    }
-  },
-  "replace": {
-    "mpociot/laravel-apidoc-generator": "*"
-  },
-  "funding": [
-    {
-      "type": "patreon",
-      "url": "https://patreon.com/shalvah"
-    }
-  ]
+    "name": "knuckleswtf/scribe",
+    "license": "MIT",
+    "description": "Generate API documentation for humans from your Laravel codebase.✍",
+    "keywords": [
+        "API",
+        "documentation",
+        "laravel",
+        "dingo"
+    ],
+    "homepage": "http://github.com/knuckleswtf/scribe",
+    "authors": [
+        {
+            "name": "Shalvah"
+        }
+    ],
+    "require": {
+        "php": ">=8.0",
+        "ext-fileinfo": "*",
+        "ext-json": "*",
+        "ext-pdo": "*",
+        "erusev/parsedown": "1.7.4",
+        "fakerphp/faker": "^1.9.1",
+        "illuminate/console": "^8.0|^9.0|^10.0",
+        "illuminate/routing": "^8.0|^9.0|^10.0",
+        "illuminate/support": "^8.0|^9.0|^10.0",
+        "league/flysystem": "^1.1.4|^2.1.1|^3.0",
+        "mpociot/reflection-docblock": "^1.0.1",
+        "nikic/php-parser": "^4.10",
+        "nunomaduro/collision": "^5.10|^6.0",
+        "ramsey/uuid": "^4.2.2",
+        "shalvah/clara": "^3.1.0",
+        "shalvah/upgrader": "^0.3.0",
+        "spatie/data-transfer-object": "^2.6|^3.0",
+        "symfony/var-exporter": "^5.4|^6.0",
+        "symfony/yaml": "^5.4|^6.0"
+    },
+    "require-dev": {
+        "brianium/paratest": "^6.0",
+        "dms/phpunit-arraysubset-asserts": "^0.4",
+        "laravel/legacy-factories": "^1.3.0",
+        "laravel/lumen-framework": "^8.0|^9.0",
+        "league/fractal": "^0.20",
+        "nikic/fast-route": "^1.3",
+        "orchestra/testbench": "^6.0|^7.0|^8.0",
+        "pestphp/pest": "^1.21",
+        "phpstan/phpstan": "^1.0",
+        "phpunit/phpunit": "^9.0|^10.0",
+        "symfony/css-selector": "^5.4|^6.0",
+        "symfony/dom-crawler": "^5.4|^6.0"
+    },
+    "autoload": {
+        "psr-4": {
+            "Knuckles\\Scribe\\": "src/",
+            "Knuckles\\Camel\\": "camel/"
+        }
+    },
+    "autoload-dev": {
+        "psr-4": {
+            "Knuckles\\Scribe\\Tests\\": "tests/"
+        }
+    },
+    "scripts": {
+        "lint": "phpstan analyse -c ./phpstan.neon src camel --memory-limit 1G",
+        "test": "pest --stop-on-failure --exclude-group dingo --coverage --colors",
+        "test-ci": "pest --exclude-group dingo --coverage --min=80",
+        "test-parallel": "paratest -p16 --stop-on-failure --exclude-group dingo",
+        "test-parallel-ci": "paratest -p16 --exclude-group dingo"
+    },
+    "extra": {
+        "laravel": {
+            "providers": [
+                "Knuckles\\Scribe\\ScribeServiceProvider"
+            ]
+        }
+    },
+    "config": {
+        "preferred-install": "dist",
+        "sort-packages": true,
+        "process-timeout": 600,
+        "allow-plugins": {
+            "pestphp/pest-plugin": true
+        }
+    },
+    "replace": {
+        "mpociot/laravel-apidoc-generator": "*"
+    },
+    "funding": [
+        {
+            "type": "patreon",
+            "url": "https://patreon.com/shalvah"
+        }
+    ]
 }

+ 4 - 0
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 {

+ 13 - 0
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