Skip to content

Commit

Permalink
Strengthen static analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
xHeaven committed Jul 10, 2024
1 parent dfea426 commit 57ff004
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ includes:
- phpstan-baseline.neon

parameters:
level: 5
level: 9
paths:
- src
tmpDir: build/phpstan
checkOctaneCompatibility: true
checkModelProperties: true
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
5 changes: 5 additions & 0 deletions src/JSONL.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ protected function encodeLines(array|Collection|LazyCollection $objects, bool $d
return $objects
->map(static function ($object) use ($dto) {
if ($dto) {
if (!is_object($object)) {
throw new FailedToEncodeException('DTO must be an object');
}

$object = get_object_vars($object);
}

Expand All @@ -110,6 +114,7 @@ protected function parseLines(LazyCollection $lines, ?string $dtoClass = null):
return $lines
->reject(static fn ($line) => $line->isEmpty())
->map(static function ($line) use ($dtoClass) {
/** @var string $line */
$object = json_decode($line, true);

if (json_last_error() !== JSON_ERROR_NONE) {
Expand Down

0 comments on commit 57ff004

Please sign in to comment.