Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .harness.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
5 changes: 3 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions src/ArgumentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ trait ArgumentHelper
/**
* Raw post type args.
*
* @var args
* @var array<array-key, mixed>|null
*/
private $rawArgs;

/**
* Set the raw arguments for the method.
*
* @param array $rawArgs The raw arguments to be set.
* @param array<array-key, mixed> $rawArgs The raw arguments to be set.
* @return self Returns the instance of the object for method chaining.
*/
public function setRawArgs(array $rawArgs): self
Expand All @@ -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<array-key, mixed>|null The raw arguments, or null if not set
*/
public function getRawArgs(): ?array
{
Expand All @@ -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<string, mixed> An associative array containing the extracted arguments.
*/
public function extractArgumentFromProperties(): array
{
Expand All @@ -66,7 +66,7 @@ public function extractArgumentFromProperties(): array
/**
* Build the arguments array
*
* @return array The built arguments array
* @return array<array-key, mixed> The built arguments array
*/
protected function buildArguments(): array
{
Expand All @@ -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<int, string> An array containing all getter method names.
*/
private function collectGetters(): array
{
Expand Down
35 changes: 1 addition & 34 deletions tests/Feature/ArgumentHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
43 changes: 43 additions & 0 deletions tests/Fixtures/TestClass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

use Pollora\WordPressArgs\ArgumentHelper;

/*
* The class the tests exercise the trait through. PHPStan analyses a trait only
* through a class that uses it, so this directory is part of the analysed paths.
*/

class TestClass
{
use ArgumentHelper;

private ?string $testProperty = null;

private ?string $anotherProperty = null;

public function getTestProperty(): ?string
{
return $this->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;
}
}
Loading