From cbdf0a93929b483ccdde5695fff7fcc709b7c357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 18 Jun 2023 16:01:28 +0200 Subject: [PATCH] Fixed some errors introduced by earlier typings --- src/Entity/Attachments/AttachmentContainingDBElement.php | 2 -- src/Entity/LogSystem/AbstractLogEntry.php | 6 +++--- src/Serializer/StructuralElementFromNameDenormalizer.php | 2 +- src/Services/LabelSystem/LabelGenerator.php | 4 +--- src/Twig/TwigCoreExtension.php | 2 +- tests/Twig/TwigCoreExtensionTest.php | 8 -------- 6 files changed, 6 insertions(+), 18 deletions(-) diff --git a/src/Entity/Attachments/AttachmentContainingDBElement.php b/src/Entity/Attachments/AttachmentContainingDBElement.php index b3b71a85..34f5797e 100644 --- a/src/Entity/Attachments/AttachmentContainingDBElement.php +++ b/src/Entity/Attachments/AttachmentContainingDBElement.php @@ -79,8 +79,6 @@ abstract class AttachmentContainingDBElement extends AbstractNamedDBElement impl /** * Gets all attachments associated with this element. - * - * @phpstan-return Collection */ public function getAttachments(): Collection { diff --git a/src/Entity/LogSystem/AbstractLogEntry.php b/src/Entity/LogSystem/AbstractLogEntry.php index 9329a33d..20626385 100644 --- a/src/Entity/LogSystem/AbstractLogEntry.php +++ b/src/Entity/LogSystem/AbstractLogEntry.php @@ -141,10 +141,10 @@ abstract class AbstractLogEntry extends AbstractDBElement #[ORM\Column(type: Types::STRING)] protected string $username = ''; - /** @var \DateTimeInterface|null The datetime the event associated with this log entry has occured + /** @var \DateTimeInterface The datetime the event associated with this log entry has occured */ #[ORM\Column(name: 'datetime', type: Types::DATETIME_MUTABLE)] - protected ?\DateTimeInterface $timestamp = null; + protected \DateTimeInterface $timestamp; /** @var int The priority level of the associated level. 0 is highest, 7 lowest */ @@ -249,7 +249,7 @@ abstract class AbstractLogEntry extends AbstractDBElement /** * Returns the timestamp when the event that caused this log entry happened. */ - public function getTimestamp(): \DateTimeInterface|null + public function getTimestamp(): \DateTimeInterface { return $this->timestamp; } diff --git a/src/Serializer/StructuralElementFromNameDenormalizer.php b/src/Serializer/StructuralElementFromNameDenormalizer.php index 63fba0a6..4277fed4 100644 --- a/src/Serializer/StructuralElementFromNameDenormalizer.php +++ b/src/Serializer/StructuralElementFromNameDenormalizer.php @@ -43,7 +43,7 @@ class StructuralElementFromNameDenormalizer implements DenormalizerInterface } /** - * @template T + * @template T of AbstractStructuralDBElement * @phpstan-param class-string $type * @phpstan-return T|null */ diff --git a/src/Services/LabelSystem/LabelGenerator.php b/src/Services/LabelSystem/LabelGenerator.php index 333461f3..943a4245 100644 --- a/src/Services/LabelSystem/LabelGenerator.php +++ b/src/Services/LabelSystem/LabelGenerator.php @@ -60,9 +60,7 @@ final class LabelGenerator } /** - * @param object|object[] $elements An element or an array of elements for which labels should be generated - * - * @return null|string + * @param object|object[] $elements An element or an array of elements for which labels should be generated */ public function generateLabel(LabelOptions $options, object|array $elements): string { diff --git a/src/Twig/TwigCoreExtension.php b/src/Twig/TwigCoreExtension.php index fb7da6d7..1cb7f1dc 100644 --- a/src/Twig/TwigCoreExtension.php +++ b/src/Twig/TwigCoreExtension.php @@ -38,7 +38,7 @@ final class TwigCoreExtension extends AbstractExtension { } - public function getFunctions() + public function getFunctions(): array { return [ /* Returns the enum cases as values */ diff --git a/tests/Twig/TwigCoreExtensionTest.php b/tests/Twig/TwigCoreExtensionTest.php index 47283520..1aa1f7ca 100644 --- a/tests/Twig/TwigCoreExtensionTest.php +++ b/tests/Twig/TwigCoreExtensionTest.php @@ -65,12 +65,4 @@ class TwigCoreExtensionTest extends WebTestCase $this->assertEqualsCanonicalizing(['test' => 1, 'test4' => 7], $this->service->toArray($obj)); } - - public function testToArrayException(): void - { - //When passing a simple scalar value a exception should be thrown. - $this->expectException(\InvalidArgumentException::class); - - $this->service->toArray(1); - } }