Skip to content

Commit

Permalink
Ignore false positives by phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
Art4 committed Oct 19, 2023
1 parent d3e2710 commit ff3773c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
26 changes: 23 additions & 3 deletions .phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,53 @@ parameters:
scanDirectories:
- vendor

treatPhpDocTypesAsCertain: false

ignoreErrors:
-
message: "#^Property Art4\\\\JsonApiClient\\\\V1\\\\ResourceNull\\:\\:\\$data is never read, only written\\.$#"
message: "#^Constructor of class Art4\\\\JsonApiClient\\\\V1\\\\ResourceNull has an unused parameter \\$data\\.$#"
count: 1
path: src/V1/ResourceNull.php
# parameter is required by Art4\JsonApiClient\Element

-
message: "#^Property Art4\\\\JsonApiClient\\\\V1\\\\ResourceNull\\:\\:\\$manager is never read, only written\\.$#"
message: "#^Constructor of class Art4\\\\JsonApiClient\\\\V1\\\\ResourceNull has an unused parameter \\$manager\\.$#"
count: 1
path: src/V1/ResourceNull.php
# parameter is required by Art4\JsonApiClient\Element

-
message: "#^Property Art4\\\\JsonApiClient\\\\V1\\\\ResourceNull\\:\\:\\$parent is never read, only written\\.$#"
message: "#^Constructor of class Art4\\\\JsonApiClient\\\\V1\\\\ResourceNull has an unused parameter \\$parent\\.$#"
count: 1
path: src/V1/ResourceNull.php
# parameter is required by Art4\JsonApiClient\Element

-
message: "#^Constructor of an anonymous class has an unused parameter \\$data\\.$#"
count: 1
path: tests/BC/ElementTest.php
# parameter is required by Art4\JsonApiClient\Element

-
message: "#^Constructor of an anonymous class has an unused parameter \\$manager\\.$#"
count: 1
path: tests/BC/ElementTest.php
# parameter is required by Art4\JsonApiClient\Element

-
message: "#^Constructor of an anonymous class has an unused parameter \\$parent\\.$#"
count: 1
path: tests/BC/ElementTest.php
# parameter is required by Art4\JsonApiClient\Element

-
message: "#^Parameter \\#1 \\$key of method Art4\\\\JsonApiClient\\\\V1\\\\ResourceNull\\:\\:has\\(\\) expects Art4\\\\JsonApiClient\\\\Helper\\\\AccessKey\\|int\\|string, array given\\.$#"
count: 1
path: tests/Unit/V1/ResourceNullTest.php
# We are providing an invalid parameter to test the deprecation message

-
message: "#^Parameter \\#1 \\$key of method Art4\\\\JsonApiClient\\\\V1\\\\ResourceNull\\:\\:has\\(\\) expects Art4\\\\JsonApiClient\\\\Helper\\\\AccessKey\\|int\\|string, stdClass given\\.$#"
count: 1
path: tests/Unit/V1/ResourceNullTest.php
# We are providing an invalid parameter to test the deprecation message
8 changes: 0 additions & 8 deletions src/V1/ResourceNull.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
*/
final class ResourceNull implements Accessable, Element
{
/** @var mixed */
private $data;
private Manager $manager;
private Accessable $parent;

/**
* Constructor
*
Expand All @@ -33,9 +28,6 @@ final class ResourceNull implements Accessable, Element
*/
public function __construct($data, Manager $manager, Accessable $parent)
{
$this->data = $data;
$this->manager = $manager;
$this->parent = $parent;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Helper/AccessableTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
namespace Art4\JsonApiClient\Tests\Unit\Helper;

use Art4\JsonApiClient\Helper\AccessableTrait;
use Art4\JsonApiClient\Accessable;
use PHPUnit\Framework\TestCase;

class AccessableTraitTest extends TestCase
{
public function testHasWithObjectAsKeyTriggersException(): void
{
/** @var Accessable */
$resource = $this->getMockForTrait(AccessableTrait::class);

// PHPUnit 10 compatible way to test trigger_error().
Expand All @@ -36,6 +38,7 @@ function ($errno, $errstr): bool {

public function testHasWithArrayAsKeyTriggersException(): void
{
/** @var Accessable */
$resource = $this->getMockForTrait(AccessableTrait::class);

// PHPUnit 10 compatible way to test trigger_error().
Expand Down

0 comments on commit ff3773c

Please sign in to comment.