diff --git a/.harness.json b/.harness.json index c8be860..69f5541 100644 --- a/.harness.json +++ b/.harness.json @@ -8,10 +8,10 @@ "illuminate/support" ], "ratchet": { - "type_coverage": 88.8, - "phpstan_level": 5, + "phpstan_level": "max", "phpstan_baseline": 1, "coverage": 100, + "type_coverage": 88.8, "msi": 85 } } diff --git a/phpstan.neon b/phpstan.neon index 78b4d7d..511a565 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,8 @@ includes: - - phpstan-baseline.neon - vendor/pollora/harness/presets/phpstan/base.neon parameters: - level: 5 + level: 10 paths: - src + # PHPStan skips a trait no analysed class uses: this class makes it analyse ArgumentHelper + - tests/Fixtures diff --git a/src/ArgumentHelper.php b/src/ArgumentHelper.php index 3daa3e0..6d6f2c2 100644 --- a/src/ArgumentHelper.php +++ b/src/ArgumentHelper.php @@ -14,14 +14,14 @@ trait ArgumentHelper /** * Raw post type args. * - * @var args + * @var array|null */ private $rawArgs; /** * Set the raw arguments for the method. * - * @param array $rawArgs The raw arguments to be set. + * @param array $rawArgs The raw arguments to be set. * @return self Returns the instance of the object for method chaining. */ public function setRawArgs(array $rawArgs): self @@ -34,7 +34,7 @@ public function setRawArgs(array $rawArgs): self /** * Get the raw arguments * - * @return array|null The raw arguments, or null if not set + * @return array|null The raw arguments, or null if not set */ public function getRawArgs(): ?array { @@ -44,7 +44,7 @@ public function getRawArgs(): ?array /** * Extracts arguments from object properties using getter methods. * - * @return array An associative array containing the extracted arguments. + * @return array An associative array containing the extracted arguments. */ public function extractArgumentFromProperties(): array { @@ -66,7 +66,7 @@ public function extractArgumentFromProperties(): array /** * Build the arguments array * - * @return array The built arguments array + * @return array The built arguments array */ protected function buildArguments(): array { @@ -78,7 +78,7 @@ protected function buildArguments(): array /** * Collects all getter methods of the current object. * - * @return array An array containing all getter method names. + * @return array An array containing all getter method names. */ private function collectGetters(): array { diff --git a/tests/Feature/ArgumentHelperTest.php b/tests/Feature/ArgumentHelperTest.php index 833208a..56d2e2b 100644 --- a/tests/Feature/ArgumentHelperTest.php +++ b/tests/Feature/ArgumentHelperTest.php @@ -2,40 +2,7 @@ declare(strict_types=1); -use Pollora\WordPressArgs\ArgumentHelper; - -class TestClass -{ - use ArgumentHelper; - - private $testProperty; - - private $anotherProperty; - - public function getTestProperty() - { - return $this->testProperty; - } - - public function setTestProperty($value) - { - $this->testProperty = $value; - - return $this; - } - - public function getAnotherProperty() - { - return $this->anotherProperty; - } - - public function setAnotherProperty($value) - { - $this->anotherProperty = $value; - - return $this; - } -} +require_once __DIR__.'/../Fixtures/TestClass.php'; test('extractArgumentFromProperties correctly extracts arguments', function () { $testObject = new TestClass; diff --git a/tests/Fixtures/TestClass.php b/tests/Fixtures/TestClass.php new file mode 100644 index 0000000..795b8ef --- /dev/null +++ b/tests/Fixtures/TestClass.php @@ -0,0 +1,43 @@ +testProperty; + } + + public function setTestProperty(string $value): self + { + $this->testProperty = $value; + + return $this; + } + + public function getAnotherProperty(): ?string + { + return $this->anotherProperty; + } + + public function setAnotherProperty(string $value): self + { + $this->anotherProperty = $value; + + return $this; + } +}