diff --git a/composer.json b/composer.json index 1167cdd..5886ca7 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ }, "require-dev": { "phpunit/phpunit": "^9.6", - "sigwin/infra": "~1.5.0" + "sigwin/infra": "~1.6.0" }, "conflict": { "nikic/php-parser": "< 4.14", diff --git a/psalm.xml.dist b/psalm.xml.dist index b1db58c..5f892b9 100644 --- a/psalm.xml.dist +++ b/psalm.xml.dist @@ -11,7 +11,7 @@ findUnusedPsalmSuppress="true" findUnusedVariablesAndParams="true" limitMethodComplexity="true" - restrictReturnTypes="true" + restrictReturnTypes="false" strictBinaryOperands="true"> diff --git a/src/Bridge/Symfony/HttpKernel/Fragment/RelativeUrlInlineFragmentRenderer.php b/src/Bridge/Symfony/HttpKernel/Fragment/RelativeUrlInlineFragmentRenderer.php index 9a49cce..b038ac3 100644 --- a/src/Bridge/Symfony/HttpKernel/Fragment/RelativeUrlInlineFragmentRenderer.php +++ b/src/Bridge/Symfony/HttpKernel/Fragment/RelativeUrlInlineFragmentRenderer.php @@ -32,8 +32,6 @@ public function __construct(InlineFragmentRenderer $fragmentRenderer, UrlGenerat /** * @psalm-param string|\Symfony\Component\HttpKernel\Controller\ControllerReference $uri - * - * @param mixed $uri */ public function render($uri, Request $request, array $options = []): \Symfony\Component\HttpFoundation\Response { diff --git a/src/Bridge/Symfony/Serializer/Normalizer/CollectionNormalizer.php b/src/Bridge/Symfony/Serializer/Normalizer/CollectionNormalizer.php index 1149158..33f704d 100644 --- a/src/Bridge/Symfony/Serializer/Normalizer/CollectionNormalizer.php +++ b/src/Bridge/Symfony/Serializer/Normalizer/CollectionNormalizer.php @@ -36,7 +36,7 @@ public function __construct(ExpressionLanguage $expressionLanguage, ClassMetadat $this->classMetadataFactory = $classMetadataFactory; } - public function denormalize(mixed $data, string $type, string $format = null, array $context = []): Collection + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): Collection { $type = mb_substr($type, 0, -2); if ($data === null) { @@ -55,7 +55,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar return new ReadOnlyCollection($this->expressionLanguage, $this->getProperties($type), $denormalized); } - public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = null): bool + public function supportsDenormalization(mixed $data, string $type, ?string $format = null, ?array $context = null): bool { return str_ends_with($type, '[]'); } diff --git a/src/Bridge/Symfony/Serializer/Normalizer/ExpressionNormalizer.php b/src/Bridge/Symfony/Serializer/Normalizer/ExpressionNormalizer.php index 0b44d03..e05c624 100644 --- a/src/Bridge/Symfony/Serializer/Normalizer/ExpressionNormalizer.php +++ b/src/Bridge/Symfony/Serializer/Normalizer/ExpressionNormalizer.php @@ -28,7 +28,7 @@ public function __construct(ExpressionLanguage $expressionLanguage, DatabaseProv $this->databaseProvider = $databaseProvider; } - public function denormalize(mixed $data, string $type, string $format = null, array $context = []) + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []) { /** @var string $data */ $value = $this->expressionLanguage->evaluate(mb_substr($data, 2), [ @@ -47,7 +47,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar return $value; } - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + public function supportsDenormalization(mixed $data, string $type, ?string $format = null): bool { return \is_string($data) && str_starts_with($data, '@='); } diff --git a/src/Bridge/Symfony/Serializer/Normalizer/LocalizingNormalizer.php b/src/Bridge/Symfony/Serializer/Normalizer/LocalizingNormalizer.php index 2ed793d..11ff452 100644 --- a/src/Bridge/Symfony/Serializer/Normalizer/LocalizingNormalizer.php +++ b/src/Bridge/Symfony/Serializer/Normalizer/LocalizingNormalizer.php @@ -31,7 +31,7 @@ public function __construct(array $classes) $this->classes = $classes; } - public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed { if (isset($this->classes[$type])) { $locale = $context[LocaleContext::LOCALE]; @@ -55,7 +55,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar return $this->denormalizer->denormalize($data, $type, $format, $context); } - public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = null): bool + public function supportsDenormalization(mixed $data, string $type, ?string $format = null, ?array $context = null): bool { return isset($this->classes[$type]) && ($context[self::LOCALIZING_NORMALIZER_LAST_TYPE] ?? null) !== $type; } diff --git a/src/Bridge/Symfony/Serializer/Normalizer/ResourceLocatorNormalizer.php b/src/Bridge/Symfony/Serializer/Normalizer/ResourceLocatorNormalizer.php index f022ab1..e46828b 100644 --- a/src/Bridge/Symfony/Serializer/Normalizer/ResourceLocatorNormalizer.php +++ b/src/Bridge/Symfony/Serializer/Normalizer/ResourceLocatorNormalizer.php @@ -26,7 +26,7 @@ public function __construct(FileLocatorInterface $locator) $this->locator = $locator; } - public function denormalize(mixed $data, string $type, string $format = null, array $context = []) + public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []) { if (\is_string($data) === false) { throw new \LogicException('String expected'); @@ -35,7 +35,7 @@ public function denormalize(mixed $data, string $type, string $format = null, ar return $this->locator->locate($data); } - public function supportsDenormalization(mixed $data, string $type, string $format = null): bool + public function supportsDenormalization(mixed $data, string $type, ?string $format = null): bool { return $type === Resource::class && \is_string($data) && str_starts_with($data, '@'); } diff --git a/src/Storage/FilesystemStorage.php b/src/Storage/FilesystemStorage.php index f9a8327..ae3c15e 100644 --- a/src/Storage/FilesystemStorage.php +++ b/src/Storage/FilesystemStorage.php @@ -100,7 +100,6 @@ public static function resolveOptions(array $options): array $resolver->setRequired(['root']); $resolver->setAllowedTypes('root', ['array', 'string']); $resolver->setAllowedTypes('names', ['array', 'string']); - /** @psalm-suppress UnusedClosureParam */ $resolver->setNormalizer('root', static function (OptionsResolver $resolver, array|string $value): array { if (\is_string($value)) { $value = [$value]; diff --git a/tests/unit/GeneratorTest.php b/tests/unit/GeneratorTest.php index 6eaac7b..42172ca 100644 --- a/tests/unit/GeneratorTest.php +++ b/tests/unit/GeneratorTest.php @@ -104,7 +104,7 @@ private function generate(Generator $generator): void $called = true; }); if (! $called) { - static::fail('Callback not called'); + self::fail('Callback not called'); } } @@ -121,12 +121,12 @@ private function mockUrlGenerator(string $baseUrl, array $routes, mixed $indexFi { $requestContext = $this->getMockBuilder(RequestContext::class)->getMock(); $requestContext - ->expects(static::once()) + ->expects(self::once()) ->method('getBaseUrl') ->willReturn($baseUrl) ; $requestContext - ->expects(static::once()) + ->expects(self::once()) ->method('getParameter') ->with('index-file') ->willReturn($indexFile) @@ -134,7 +134,7 @@ private function mockUrlGenerator(string $baseUrl, array $routes, mixed $indexFi $urlGenerator = $this->getMockBuilder(UrlGeneratorInterface::class)->getMock(); $urlGenerator - ->expects(static::once()) + ->expects(self::once()) ->method('getContext') ->willReturn($requestContext) ; @@ -145,7 +145,7 @@ private function mockUrlGenerator(string $baseUrl, array $routes, mixed $indexFi } $urlGenerator - ->expects(static::exactly(\count($routes))) + ->expects(self::exactly(\count($routes))) ->method('generate') ->withConsecutive(...$remapped) ->willReturn('/////') @@ -158,21 +158,21 @@ private function mockKernel(string $baseUrl, string|false $body, int $status = 2 { $response = $this->getMockBuilder(Response::class)->getMock(); $response - ->expects(static::once()) + ->expects(self::once()) ->method('getStatusCode') ->willReturn($status) ; $response - ->expects(static::once()) + ->expects(self::once()) ->method('getContent') ->willReturn($body) ; $kernel = $this->getMockBuilder(KernelInterface::class)->getMock(); $kernel - ->expects(static::once()) + ->expects(self::once()) ->method('handle') - ->with(static::callback(static function (\Symfony\Component\HttpFoundation\Request $request) use ($baseUrl): bool { + ->with(self::callback(static function (\Symfony\Component\HttpFoundation\Request $request) use ($baseUrl): bool { return $request->getUri() === 'http://localhost/'.$baseUrl; })) ->willReturn($response) @@ -185,7 +185,7 @@ private function mockFilesystem(?string $path, string $content): Filesystem { $filesystem = $this->getMockBuilder(Filesystem::class)->getMock(); $filesystem - ->expects(static::once()) + ->expects(self::once()) ->method('dumpFile') ->with($path, $content) ;