Skip to content

Commit

Permalink
PHPStan level 9
Browse files Browse the repository at this point in the history
  • Loading branch information
nkl-kst committed Jul 16, 2024
1 parent bf4f2c9 commit 6e0944a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
'import_constants' => true,
'import_functions' => true,
],
'phpdoc_to_comment' => ['ignored_tags' => ['var']],
'yoda_style' => false,
])
->setFinder($finder);
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build](https://github.com/nkl-kst/the-sports-db/workflows/Build/badge.svg)](https://github.com/nkl-kst/the-sports-db/actions)
[![Packagist Version](https://img.shields.io/packagist/v/nkl-kst/the-sports-db)](https://packagist.org/packages/nkl-kst/the-sports-db)
[![Coverage Status](https://coveralls.io/repos/github/nkl-kst/the-sports-db/badge.svg?branch=master)](https://coveralls.io/github/nkl-kst/the-sports-db?branch=master)
[![PHPStan Level](https://img.shields.io/badge/PHPStan-level%208-brightgreen.svg?style=flat)](https://github.com/nkl-kst/the-sports-db/actions)
[![PHPStan Level](https://img.shields.io/badge/PHPStan-level%209-brightgreen.svg?style=flat)](https://github.com/nkl-kst/the-sports-db/actions)
[![GitHub](https://img.shields.io/github/license/nkl-kst/the-sports-db)](https://github.com/nkl-kst/the-sports-db/blob/master/LICENSE.md)

An easy-to-use PHP library to get data from https://www.thesportsdb.com.
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 8
level: 9
paths:
- src
- test
7 changes: 7 additions & 0 deletions src/Serializer/AbstractSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,25 @@ private function validate(?object $json): ?string
public function serialize(string $content): array
{
$json = json_decode($content);
if (!is_object($json)) {
$json = null;
}

if ($message = $this->validate($json)) {
throw new Exception($message);
}

// Tested in self::validate()
assert($json !== null);

$innerJson = $json->{$this->getJsonRootName($json)};

// Don't serialize if the API endpoint returned null instead of an empty array
if (null === $innerJson) {
return [];
}

/** @var TObject[] */
return $this->mapper->mapArray($innerJson, [], $this->getEntityClass());
}
}
5 changes: 4 additions & 1 deletion test/unit/Dependency/DependencyContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ protected function setUp(): void
*/
private function getBuilder(): ContainerBuilder
{
return TestUtils::getHiddenStaticProperty(DependencyContainer::class, 'builder');
$containerBuilder = TestUtils::getHiddenStaticProperty(DependencyContainer::class, 'builder');
assert($containerBuilder instanceof ContainerBuilder);

return $containerBuilder;
}

private function getMethod(string $method): Closure
Expand Down

0 comments on commit 6e0944a

Please sign in to comment.