diff --git a/modules/notifications/tests/Module/Notifications/Service/NotificationServiceTest.php b/modules/notifications/tests/Module/Notifications/Service/NotificationServiceTest.php index 0e15baa..2d8f74b 100644 --- a/modules/notifications/tests/Module/Notifications/Service/NotificationServiceTest.php +++ b/modules/notifications/tests/Module/Notifications/Service/NotificationServiceTest.php @@ -275,7 +275,7 @@ class NotificationServiceTest extends TestCase $this->notifRepo->expects($this->once()) ->method('create') ->with($this->callback(function (array $data): bool { - return !isset($data['dedupe_fingerprint']) || $data['dedupe_fingerprint'] === null; + return !isset($data['dedupe_fingerprint']); })) ->willReturn(56); diff --git a/phpstan.neon b/phpstan.neon index b55ce8f..ab1a06d 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,6 +3,15 @@ parameters: phpVersion: 80499 scanFiles: - web/index.php + - bin/cli-bootstrap.php + - bin/module-cli-bootstrap.php + - bin/module-migrate.php + - bin/module-deactivate.php + - bin/module-build.php + - bin/module-assets-sync.php + - bin/module-permissions-sync.php + - bin/module-runtime-sync.php + - bin/doctor.php paths: - config - lib diff --git a/tests/Architecture/ModuleI18nContractTest.php b/tests/Architecture/ModuleI18nContractTest.php index 374dfe9..ce0d0a7 100644 --- a/tests/Architecture/ModuleI18nContractTest.php +++ b/tests/Architecture/ModuleI18nContractTest.php @@ -42,7 +42,7 @@ class ModuleI18nContractTest extends TestCase $modules[$moduleId] = [$moduleId, $resolvedPath]; } - return $modules; + return array_values($modules); } #[DataProvider('moduleProvider')] diff --git a/tests/Service/Settings/SettingsDefaultsGatewayTest.php b/tests/Service/Settings/SettingsDefaultsGatewayTest.php index b0b8ed1..e09563d 100644 --- a/tests/Service/Settings/SettingsDefaultsGatewayTest.php +++ b/tests/Service/Settings/SettingsDefaultsGatewayTest.php @@ -28,6 +28,7 @@ class SettingsDefaultsGatewayTest extends TestCase 'setDefaultTenantId' => $tenantRepository->expects($this->once())->method('find')->with($id)->willReturn(null), 'setDefaultRoleId' => $roleRepository->expects($this->once())->method('find')->with($id)->willReturn(null), 'setDefaultDepartmentId' => $departmentRepository->expects($this->once())->method('find')->with($id)->willReturn(null), + default => throw new \LogicException("Unknown setter: {$setter}"), }; $this->assertFalse($gateway->$setter($id)); diff --git a/tests/Service/Settings/SettingsSessionPolicyGatewayTest.php b/tests/Service/Settings/SettingsSessionPolicyGatewayTest.php index 9894d8e..d84ca4a 100644 --- a/tests/Service/Settings/SettingsSessionPolicyGatewayTest.php +++ b/tests/Service/Settings/SettingsSessionPolicyGatewayTest.php @@ -59,7 +59,7 @@ final class SettingsSessionPolicyGatewayTest extends TestCase self::assertFalse($gateway->isMicrosoftAutoRememberDefault()); $metadataTrue = $this->createMock(SettingsMetadataGateway::class); - $metadataTrue->method('getValue')->with('microsoft_auto_remember_default')->willReturn('1'); + $metadataTrue->expects($this->any())->method('getValue')->with('microsoft_auto_remember_default')->willReturn('1'); $gatewayTrue = new SettingsLoginPersistenceGateway($metadataTrue); self::assertTrue($gatewayTrue->isMicrosoftAutoRememberDefault()); } @@ -82,13 +82,13 @@ final class SettingsSessionPolicyGatewayTest extends TestCase public function testRememberTokenLifetimeUsesFallbackWhenMissingOrInvalid(): void { $metadataMissing = $this->createMock(SettingsMetadataGateway::class); - $metadataMissing->method('getInt')->with('remember_token_lifetime_days')->willReturn(null); + $metadataMissing->expects($this->any())->method('getInt')->with('remember_token_lifetime_days')->willReturn(null); $gatewayMissing = new SettingsLoginPersistenceGateway($metadataMissing); self::assertSame(30, $gatewayMissing->getRememberTokenLifetimeDays()); self::assertSame(30 * 86400, $gatewayMissing->getRememberTokenLifetimeSeconds()); $metadataInvalid = $this->createMock(SettingsMetadataGateway::class); - $metadataInvalid->method('getInt')->with('remember_token_lifetime_days')->willReturn(500); + $metadataInvalid->expects($this->any())->method('getInt')->with('remember_token_lifetime_days')->willReturn(500); $gatewayInvalid = new SettingsLoginPersistenceGateway($metadataInvalid); self::assertSame(30, $gatewayInvalid->getRememberTokenLifetimeDays()); } @@ -96,7 +96,7 @@ final class SettingsSessionPolicyGatewayTest extends TestCase public function testRememberTokenLifetimeAcceptsValidRangeAndComputesSeconds(): void { $metadata = $this->createMock(SettingsMetadataGateway::class); - $metadata->method('getInt')->with('remember_token_lifetime_days')->willReturn(7); + $metadata->expects($this->any())->method('getInt')->with('remember_token_lifetime_days')->willReturn(7); $metadata->expects($this->once()) ->method('set') ->with('remember_token_lifetime_days', '14', $this->anything()) diff --git a/tests/Unit/Module/ModuleEventDispatcherTest.php b/tests/Unit/Module/ModuleEventDispatcherTest.php index e6d32c9..d8f102c 100644 --- a/tests/Unit/Module/ModuleEventDispatcherTest.php +++ b/tests/Unit/Module/ModuleEventDispatcherTest.php @@ -17,8 +17,11 @@ final class ModuleEventDispatcherTest extends TestCase $listener = new class ($called, $capturedEvent, $capturedPayload) implements EventListener { public function __construct( + /** @phpstan-ignore property.onlyWritten */ private bool &$called, + /** @phpstan-ignore property.onlyWritten */ private string &$capturedEvent, + /** @phpstan-ignore property.onlyWritten */ private array &$capturedPayload ) { } @@ -69,7 +72,7 @@ final class ModuleEventDispatcherTest extends TestCase }; $successListener = new class ($secondCalled) implements EventListener { - public function __construct(private bool &$called) + public function __construct(/** @phpstan-ignore property.onlyWritten */ private bool &$called) { }