Skip to content

Commit

Permalink
increase phpstan level to 8
Browse files Browse the repository at this point in the history
  • Loading branch information
JanTvrdik committed Mar 8, 2023
1 parent 59b92bc commit 5b00f05
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 6
level: 8
checkMissingIterableValueType: false

paths:
Expand Down
2 changes: 1 addition & 1 deletion src/Schema/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ public function toString(): string
return preg_replace_callback('~( ?)%(\w+)%~', function ($m) use ($vars) {
[, $space, $key] = $m;
return $vars[$key] === null ? '' : $space . $vars[$key];
}, $this->message);
}, $this->message) ?? throw new Nette\InvalidStateException(preg_last_error_msg());
}
}
15 changes: 8 additions & 7 deletions src/Schema/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class Processor
use Nette\SmartObject;

public array $onNewContext = [];
private ?Context $context;
private Context $context;
private bool $skipDefaults = false;


Expand All @@ -36,7 +36,7 @@ public function skipDefaults(bool $value = true): void
*/
public function process(Schema $schema, mixed $data): mixed
{
$this->createContext();
$this->context = $this->createContext();
$data = $schema->normalize($data, $this->context);
$this->throwsErrors();
$data = $schema->complete($data, $this->context);
Expand All @@ -51,7 +51,7 @@ public function process(Schema $schema, mixed $data): mixed
*/
public function processMultiple(Schema $schema, array $dataset): mixed
{
$this->createContext();
$this->context = $this->createContext();
$flatten = null;
$first = true;
foreach ($dataset as $data) {
Expand Down Expand Up @@ -89,10 +89,11 @@ private function throwsErrors(): void
}


private function createContext(): void
private function createContext(): Context
{
$this->context = new Context;
$this->context->skipDefaults = $this->skipDefaults;
Nette\Utils\Arrays::invoke($this->onNewContext, $this->context);
$context = new Context;
$context->skipDefaults = $this->skipDefaults;
Nette\Utils\Arrays::invoke($this->onNewContext, $context);
return $context;
}
}

0 comments on commit 5b00f05

Please sign in to comment.