Skip to content

Commit 376709c

Browse files
committed
refactor: resolve phpstan found issues
1 parent a319158 commit 376709c

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

src/JsonSchema/Constraints/Drafts/Draft06/AdditionalItemsConstraint.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66

77
use JsonSchema\ConstraintError;
88
use JsonSchema\Constraints\ConstraintInterface;
9-
use JsonSchema\Constraints\Factory;
109
use JsonSchema\Entity\ErrorBagProxy;
1110
use JsonSchema\Entity\JsonPointer;
1211

1312
class AdditionalItemsConstraint implements ConstraintInterface
1413
{
1514
use ErrorBagProxy;
1615

17-
/** @var \JsonSchema\Constraints\Drafts\Draft06\Factory */
16+
/** @var Factory */
1817
private $factory;
1918

2019
public function __construct(?Factory $factory = null)

src/JsonSchema/Constraints/Drafts/Draft06/Draft06Constraint.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
5858
$this->checkForKeyword('format', $value, $schema, $path, $i);
5959
}
6060

61+
/**
62+
* @param mixed $value
63+
* @param mixed $schema
64+
* @param mixed $i
65+
*/
6166
protected function checkForKeyword(string $keyword, $value, $schema = null, ?JsonPointer $path = null, $i = null): void
6267
{
6368
$validator = $this->factory->createInstanceFor($keyword);

src/JsonSchema/Constraints/Drafts/Draft06/FormatConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private function validateStyle(string $style): bool
156156
return empty($invalidEntries);
157157
}
158158

159-
private function validatePhone($phone): bool
159+
private function validatePhone(string $phone): bool
160160
{
161161
return preg_match('/^\+?(\(\d{3}\)|\d{3}) \d{3} \d{4}$/', $phone) !== false;
162162
}

src/JsonSchema/Constraints/Drafts/Draft06/ItemsConstraint.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
namespace JsonSchema\Constraints\Drafts\Draft06;
66

77
use JsonSchema\Constraints\ConstraintInterface;
8-
use JsonSchema\Constraints\Factory;
98
use JsonSchema\Entity\ErrorBagProxy;
109
use JsonSchema\Entity\JsonPointer;
1110

1211
class ItemsConstraint implements ConstraintInterface
1312
{
1413
use ErrorBagProxy;
1514

16-
/** @var \JsonSchema\Constraints\Drafts\Draft06\Factory */
15+
/** @var Factory */
1716
private $factory;
1817

1918
public function __construct(?Factory $factory = null)

src/JsonSchema/Constraints/Drafts/Draft06/NotConstraint.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66

77
use JsonSchema\ConstraintError;
88
use JsonSchema\Constraints\ConstraintInterface;
9-
use JsonSchema\Constraints\Factory;
109
use JsonSchema\Entity\ErrorBagProxy;
1110
use JsonSchema\Entity\JsonPointer;
1211

1312
class NotConstraint implements ConstraintInterface
1413
{
1514
use ErrorBagProxy;
1615

17-
/** @var \JsonSchema\Constraints\Drafts\Draft06\Factory */
16+
/** @var Factory */
1817
private $factory;
1918

2019
public function __construct(?Factory $factory = null)

src/JsonSchema/Constraints/Drafts/Draft06/PropertiesConstraint.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
namespace JsonSchema\Constraints\Drafts\Draft06;
66

77
use JsonSchema\Constraints\ConstraintInterface;
8-
use JsonSchema\Constraints\Factory;
98
use JsonSchema\Entity\ErrorBagProxy;
109
use JsonSchema\Entity\JsonPointer;
1110

1211
class PropertiesConstraint implements ConstraintInterface
1312
{
1413
use ErrorBagProxy;
1514

16-
/** @var \JsonSchema\Constraints\Drafts\Draft06\Factory */
15+
/** @var Factory */
1716
private $factory;
1817

1918
public function __construct(?Factory $factory = null)

src/JsonSchema/Entity/ErrorBagProxy.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*/
1414
trait ErrorBagProxy
1515
{
16-
/** @var ErrorBag */
17-
protected $errorBag;
16+
/** @var ?ErrorBag */
17+
protected $errorBag = null;
1818

1919
/** @return ErrorList */
2020
public function getErrors(): array
@@ -29,7 +29,7 @@ public function addErrors(array $errors): void
2929
}
3030

3131
/**
32-
* @param array $more more array elements to add to the error
32+
* @param array<string, mixed> $more more array elements to add to the error
3333
*/
3434
public function addError(ConstraintError $constraint, ?JsonPointer $path = null, array $more = []): void
3535
{
@@ -43,7 +43,7 @@ public function isValid(): bool
4343

4444
protected function initialiseErrorBag(Factory $factory): ErrorBag
4545
{
46-
if (!isset($this->errorBag)) {
46+
if (is_null($this->errorBag)) {
4747
$this->errorBag = new ErrorBag($factory);
4848
}
4949

@@ -52,7 +52,7 @@ protected function initialiseErrorBag(Factory $factory): ErrorBag
5252

5353
protected function errorBag(): ErrorBag
5454
{
55-
if (!isset($this->errorBag)) {
55+
if (is_null($this->errorBag)) {
5656
throw new \RuntimeException('ErrorBag not initialized');
5757
}
5858

@@ -61,6 +61,6 @@ protected function errorBag(): ErrorBag
6161

6262
public function __clone()
6363
{
64-
$this->errorBag->reset();
64+
$this->errorBag()->reset();
6565
}
6666
}

0 commit comments

Comments
 (0)