From bd3ed2b7a3cd89eda177eabffefdaf613035acd9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Aug 2026 02:04:49 +0000 Subject: [PATCH 1/6] composer (master)(deps-dev): bump the development-dependencies group with 5 updates Updates the requirements on [infection/infection](https://github.com/infection/infection), [phpstan/phpstan](https://github.com/phpstan/phpstan-phar-composer-source), [phpstan/phpstan-deprecation-rules](https://github.com/phpstan/phpstan-deprecation-rules), [rector/rector](https://github.com/rectorphp/rector) and [rector/type-perfect](https://github.com/rectorphp/type-perfect) to permit the latest version. Updates `infection/infection` to 0.34.2 - [Release notes](https://github.com/infection/infection/releases) - [Changelog](https://github.com/infection/infection/blob/master/CHANGELOG.md) - [Commits](https://github.com/infection/infection/compare/0.34.0...0.34.2) Updates `phpstan/phpstan` to 2.2.8 - [Commits](https://github.com/phpstan/phpstan-phar-composer-source/commits) Updates `phpstan/phpstan-deprecation-rules` to 2.0.5 - [Release notes](https://github.com/phpstan/phpstan-deprecation-rules/releases) - [Commits](https://github.com/phpstan/phpstan-deprecation-rules/compare/2.0.4...2.0.5) Updates `rector/rector` to 2.6.2 - [Release notes](https://github.com/rectorphp/rector/releases) - [Commits](https://github.com/rectorphp/rector/compare/2.5.6...2.6.2) Updates `rector/type-perfect` to 2.2.0 - [Release notes](https://github.com/rectorphp/type-perfect/releases) - [Commits](https://github.com/rectorphp/type-perfect/compare/2.1.4...2.2.0) --- updated-dependencies: - dependency-name: infection/infection dependency-version: 0.34.2 dependency-type: direct:development dependency-group: development-dependencies - dependency-name: phpstan/phpstan dependency-version: 2.2.8 dependency-type: direct:development dependency-group: development-dependencies - dependency-name: phpstan/phpstan-deprecation-rules dependency-version: 2.0.5 dependency-type: direct:development dependency-group: development-dependencies - dependency-name: rector/rector dependency-version: 2.6.2 dependency-type: direct:development dependency-group: development-dependencies - dependency-name: rector/type-perfect dependency-version: 2.2.0 dependency-type: direct:development dependency-group: development-dependencies ... Signed-off-by: dependabot[bot] --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index bf11a7a..3977481 100644 --- a/composer.json +++ b/composer.json @@ -33,17 +33,17 @@ "ext-xml": "*", "ext-xmlwriter": "*", "ergebnis/composer-normalize": "^2.52.0", - "infection/infection": "^0.34.0", + "infection/infection": "^0.34.2", "jbelien/phpstan-sarif-formatter": "^1.2.0", "mimmi20/coding-standard": "^6.2.5", "nikic/php-parser": "^5.8.0", "phpstan/extension-installer": "^1.4.3", - "phpstan/phpstan": "^2.2.5", - "phpstan/phpstan-deprecation-rules": "^2.0.4", + "phpstan/phpstan": "^2.2.8", + "phpstan/phpstan-deprecation-rules": "^2.0.5", "phpunit/phpunit": "^12.5.3", "psr/log": "^3.0.2", - "rector/rector": "^2.5.6", - "rector/type-perfect": "^2.1.4", + "rector/rector": "^2.6.2", + "rector/type-perfect": "^2.2.0", "shipmonk/composer-dependency-analyser": "^1.8.4", "symfony/process": "^7.3.4", "symplify/phpstan-rules": "^14.9.11", From 7adf1a761604e368493c277abd219a4f6ab31cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 21 Aug 2026 07:11:00 +0200 Subject: [PATCH 2/6] update rector config --- rector.php | 54 ++--- tests/CallbackFilterHandlerTest.php | 295 +++++++++++++--------------- 2 files changed, 170 insertions(+), 179 deletions(-) diff --git a/rector.php b/rector.php index 808b7b5..0118b8d 100644 --- a/rector.php +++ b/rector.php @@ -13,32 +13,34 @@ declare(strict_types = 1); use Rector\Config\RectorConfig; -use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector; -use Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector; -use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector; -use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; -use Rector\PHPUnit\Set\PHPUnitSetList; -use Rector\Set\ValueObject\LevelSetList; -use Rector\Set\ValueObject\SetList; +use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector; +use Rector\ValueObject\PhpVersion; -return static function (RectorConfig $rectorConfig): void { - $rectorConfig->paths([ +return RectorConfig::configure() + ->withPaths([ __DIR__ . '/src', __DIR__ . '/tests', - ]); - - $rectorConfig->sets([ - SetList::DEAD_CODE, - LevelSetList::UP_TO_PHP_83, - PHPUnitSetList::PHPUNIT_100, - ]); - - $rectorConfig->skip( - [ - NullToStrictStringFuncCallArgRector::class, - RemoveDeadInstanceOfRector::class, - RemoveAlwaysTrueIfConditionRector::class, - RemoveParentCallWithoutParentRector::class, - ], - ); -}; + ]) + ->withPhpVersion(PhpVersion::PHP_83) + ->withPreparedSets( + deadCode: true, + codeQuality: false, + typeDeclarations: true, + typeDeclarationDocblocks: true, + naming: true, + namedArgs: true, + instanceOf: false, + if: true, + earlyReturn: true, + phpunitCodeQuality: true, + phpunitNarrowAsserts: true, + phpunitMockToStub: true, + ) + ->withPhpSets(php83: true) + ->withAttributesSets(phpunit: true) + ->withComposerBased(phpunit: true) + ->withSkip([ + PreferPHPUnitThisCallRector::class, + ]) + ->withoutParallel() + ->withMemoryLimit('2048M'); diff --git a/tests/CallbackFilterHandlerTest.php b/tests/CallbackFilterHandlerTest.php index c1e927a..9b36205 100644 --- a/tests/CallbackFilterHandlerTest.php +++ b/tests/CallbackFilterHandlerTest.php @@ -43,14 +43,12 @@ final class CallbackFilterHandlerTest extends AbstractTestCase * @throws Exception * @throws RuntimeException */ - #[DataProvider('provideSuiteRecords')] - public function testIsHandling(LogRecord $record): void + #[DataProvider(methodName: 'provideSuiteRecords')] + public function testIsHandling(LogRecord $logRecord): void { $filters = []; - $test = $this->getMockBuilder(HandlerInterface::class) - ->disableOriginalConstructor() - ->getMock(); + $test = $this->createMock(HandlerInterface::class); $test->expects(self::never()) ->method('isHandling'); $test->expects(self::never()) @@ -60,11 +58,11 @@ public function testIsHandling(LogRecord $record): void $test->expects(self::never()) ->method('close'); - $handler = new CallbackFilterHandler($test, $filters); + $callbackFilterHandler = new CallbackFilterHandler($test, $filters); - self::assertTrue($handler->isHandling($record)); - self::assertTrue($handler->getBubble()); - self::assertSame(Level::Debug, $handler->getLevel()); + self::assertTrue($callbackFilterHandler->isHandling($logRecord)); + self::assertTrue($callbackFilterHandler->getBubble()); + self::assertSame(Level::Debug, $callbackFilterHandler->getLevel()); } /** @@ -73,15 +71,13 @@ public function testIsHandling(LogRecord $record): void * @throws Exception * @throws RuntimeException */ - #[DataProvider('provideSuiteRecords')] - public function testIsHandlingLevel(LogRecord $record): void + #[DataProvider(methodName: 'provideSuiteRecords')] + public function testIsHandlingLevel(LogRecord $logRecord): void { $filters = []; $testlvl = Level::Warning; - $test = $this->getMockBuilder(HandlerInterface::class) - ->disableOriginalConstructor() - ->getMock(); + $test = $this->createMock(HandlerInterface::class); $test->expects(self::never()) ->method('isHandling'); $test->expects(self::never()) @@ -91,16 +87,16 @@ public function testIsHandlingLevel(LogRecord $record): void $test->expects(self::never()) ->method('close'); - $handler = new CallbackFilterHandler($test, $filters, $testlvl, false); + $callbackFilterHandler = new CallbackFilterHandler($test, $filters, $testlvl, bubble: false); - if ($record->level->value >= $testlvl->value) { - self::assertTrue($handler->isHandling($record)); + if ($logRecord->level->value >= $testlvl->value) { + self::assertTrue($callbackFilterHandler->isHandling($logRecord)); } else { - self::assertFalse($handler->isHandling($record)); + self::assertFalse($callbackFilterHandler->isHandling($logRecord)); } - self::assertSame($testlvl, $handler->getLevel()); - self::assertFalse($handler->getBubble()); + self::assertSame($testlvl, $callbackFilterHandler->getLevel()); + self::assertFalse($callbackFilterHandler->getBubble()); } /** @@ -110,15 +106,13 @@ public function testIsHandlingLevel(LogRecord $record): void * @throws RuntimeException * @throws InvalidArgumentException */ - #[DataProvider('provideSuiteRecords')] - public function testIsHandlingLevelWithLoglevel(LogRecord $record): void + #[DataProvider(methodName: 'provideSuiteRecords')] + public function testIsHandlingLevelWithLoglevel(LogRecord $logRecord): void { $filters = []; $testlvl = LogLevel::WARNING; - $test = $this->getMockBuilder(HandlerInterface::class) - ->disableOriginalConstructor() - ->getMock(); + $test = $this->createMock(HandlerInterface::class); $test->expects(self::never()) ->method('isHandling'); $test->expects(self::never()) @@ -128,14 +122,14 @@ public function testIsHandlingLevelWithLoglevel(LogRecord $record): void $test->expects(self::never()) ->method('close'); - $handler = new CallbackFilterHandler($test, $filters, $testlvl); + $callbackFilterHandler = new CallbackFilterHandler($test, $filters, $testlvl); $levelToCompare = Logger::toMonologLevel($testlvl); - if ($record->level->value >= $levelToCompare->value) { - self::assertTrue($handler->isHandling($record)); + if ($logRecord->level->value >= $levelToCompare->value) { + self::assertTrue($callbackFilterHandler->isHandling($logRecord)); } else { - self::assertFalse($handler->isHandling($record)); + self::assertFalse($callbackFilterHandler->isHandling($logRecord)); } } @@ -145,21 +139,19 @@ public function testIsHandlingLevelWithLoglevel(LogRecord $record): void * @throws Exception * @throws RuntimeException */ - #[DataProvider('provideSuiteRecords')] - public function testIsHandlingLevelAndCallback(LogRecord $record): void + #[DataProvider(methodName: 'provideSuiteRecords')] + public function testIsHandlingLevelAndCallback(LogRecord $logRecord): void { $filters = [ - static fn (LogRecord $record) => in_array( - $record->level->value, + static fn (LogRecord $logRecord): bool => in_array( + $logRecord->level->value, [Level::Info->value, Level::Notice->value], - true, + strict: true, ), ]; $testlvl = Level::Info; - $test = $this->getMockBuilder(HandlerInterface::class) - ->disableOriginalConstructor() - ->getMock(); + $test = $this->createMock(HandlerInterface::class); $test->expects(self::never()) ->method('isHandling'); $test->expects(self::never()) @@ -169,12 +161,12 @@ public function testIsHandlingLevelAndCallback(LogRecord $record): void $test->expects(self::never()) ->method('close'); - $handler = new CallbackFilterHandler($test, $filters, $testlvl); + $callbackFilterHandler = new CallbackFilterHandler($test, $filters, $testlvl); - if (in_array($record->level->value, [Level::Info->value, Level::Notice->value], true)) { - self::assertTrue($handler->isHandling($record)); + if (in_array($record->level->value, [Level::Info->value, Level::Notice->value], strict: true)) { + self::assertTrue($callbackFilterHandler->isHandling($record)); } else { - self::assertFalse($handler->isHandling($record)); + self::assertFalse($callbackFilterHandler->isHandling($record)); } } @@ -184,21 +176,19 @@ public function testIsHandlingLevelAndCallback(LogRecord $record): void * @throws Exception * @throws RuntimeException */ - #[DataProvider('provideSuiteRecords')] - public function testIsHandlingLevelAndCallbackWithLoglevel(LogRecord $record): void + #[DataProvider(methodName: 'provideSuiteRecords')] + public function testIsHandlingLevelAndCallbackWithLoglevel(LogRecord $logRecord): void { $filters = [ - static fn (LogRecord $record) => in_array( - $record->level->value, + static fn (LogRecord $logRecord): bool => in_array( + $logRecord->level->value, [Level::Info->value, Level::Notice->value], - true, + strict: true, ), ]; $testlvl = LogLevel::INFO; - $test = $this->getMockBuilder(HandlerInterface::class) - ->disableOriginalConstructor() - ->getMock(); + $test = $this->createMock(HandlerInterface::class); $test->expects(self::never()) ->method('isHandling'); $test->expects(self::never()) @@ -208,12 +198,12 @@ public function testIsHandlingLevelAndCallbackWithLoglevel(LogRecord $record): v $test->expects(self::never()) ->method('close'); - $handler = new CallbackFilterHandler($test, $filters, $testlvl); + $callbackFilterHandler = new CallbackFilterHandler($test, $filters, $testlvl); - if (in_array($record->level->value, [Level::Info->value, Level::Notice->value], true)) { - self::assertTrue($handler->isHandling($record)); + if (in_array($record->level->value, [Level::Info->value, Level::Notice->value], strict: true)) { + self::assertTrue($callbackFilterHandler->isHandling($record)); } else { - self::assertFalse($handler->isHandling($record)); + self::assertFalse($callbackFilterHandler->isHandling($record)); } } @@ -223,26 +213,26 @@ public function testIsHandlingLevelAndCallbackWithLoglevel(LogRecord $record): v * @throws Exception * @throws RuntimeException */ - #[DataProvider('provideSuiteRecords')] - public function testHandleProcessOnlyNeededLevels(LogRecord $record): void + #[DataProvider(methodName: 'provideSuiteRecords')] + public function testHandleProcessOnlyNeededLevels(LogRecord $logRecord): void { $filters = [ - static fn (LogRecord $record) => in_array( - $record->level->value, + static fn (LogRecord $logRecord): bool => in_array( + $logRecord->level->value, [Level::Info->value, Level::Notice->value], - true, + strict: true, ), ]; - $test = new TestHandler(); - $handler = new CallbackFilterHandler($test, $filters); - $handler->handle($record); + $testHandler = new TestHandler(); + $callbackFilterHandler = new CallbackFilterHandler($testHandler, $filters); + $callbackFilterHandler->handle($record); $levelName = Level::fromValue($record->level->value)->getName(); $hasMethod = 'has' . ucfirst(mb_strtolower($levelName)); - $result = $test->{$hasMethod}(sprintf('sample of %s message', $levelName)); + $result = $testHandler->{$hasMethod}(sprintf('sample of %s message', $levelName)); - if (in_array($record->level->value, [Level::Info->value, Level::Notice->value], true)) { + if (in_array($record->level->value, [Level::Info->value, Level::Notice->value], strict: true)) { self::assertTrue($result); } else { self::assertFalse($result); @@ -255,23 +245,26 @@ public function testHandleProcessOnlyNeededLevels(LogRecord $record): void * @throws Exception * @throws RuntimeException */ - #[DataProvider('provideSuiteRecords')] - public function testHandleProcessAllMatchingRules(LogRecord $record): void + #[DataProvider(methodName: 'provideSuiteRecords')] + public function testHandleProcessAllMatchingRules(LogRecord $logRecord): void { $filters = [ - static fn (LogRecord $record) => $record->level->value === Level::Notice->value, - static fn (LogRecord $record) => preg_match('/^sample of/', $record->message) === 1, + static fn (LogRecord $logRecord): bool => $logRecord->level->value === Level::Notice->value, + static fn (LogRecord $logRecord): bool => preg_match( + '/^sample of/', + $logRecord->message, + ) === 1, ]; - $test = new TestHandler(); + $testHandler = new TestHandler(); - $handler = new CallbackFilterHandler($test, $filters); - $handler->handle($record); + $callbackFilterHandler = new CallbackFilterHandler($testHandler, $filters); + $callbackFilterHandler->handle($record); if ($record->level->value === Level::Notice->value) { - self::assertTrue($test->hasNoticeThatContains($record->message)); + self::assertTrue($testHandler->hasNoticeThatContains($record->message)); } else { - self::assertFalse($test->hasNoticeThatContains($record->message)); + self::assertFalse($testHandler->hasNoticeThatContains($record->message)); } } @@ -285,18 +278,21 @@ public function testHandleProcessAllMatchingRules(LogRecord $record): void public function testHandleBatch(): void { $filters = [ - static fn (LogRecord $record) => $record->level->value === Level::Info->value, - static fn (LogRecord $record) => preg_match('/information/', $record->message) === 1, + static fn (LogRecord $logRecord): bool => $logRecord->level->value === Level::Info->value, + static fn (LogRecord $logRecord): bool => preg_match( + '/information/', + $logRecord->message, + ) === 1, ]; - $records = $this->getMultipleRecords(); - $test = new TestHandler(); + $records = $this->getMultipleRecords(); + $testHandler = new TestHandler(); - $handler = new CallbackFilterHandler($test, $filters); - $handler->handleBatch($records); + $callbackFilterHandler = new CallbackFilterHandler($testHandler, $filters); + $callbackFilterHandler->handleBatch($records); self::assertTrue( - $test->hasOnlyRecordsThatContains('information', Level::Info), + $testHandler->hasOnlyRecordsThatContains('information', Level::Info), ); } @@ -310,17 +306,20 @@ public function testHandleBatch(): void public function testHandleBatch2(): void { $filters = [ - static fn (LogRecord $record) => $record->level->value === Level::Info->value, - static fn (LogRecord $record) => preg_match('/information/', $record->message) === false, + static fn (LogRecord $logRecord): bool => $logRecord->level->value === Level::Info->value, + static fn (LogRecord $logRecord): bool => preg_match( + '/information/', + $logRecord->message, + ) === false, ]; - $records = $this->getMultipleRecords(); - $test = new TestHandler(); + $records = $this->getMultipleRecords(); + $testHandler = new TestHandler(); - $handler = new CallbackFilterHandler($test, $filters); - $handler->handleBatch($records); + $callbackFilterHandler = new CallbackFilterHandler($testHandler, $filters); + $callbackFilterHandler->handleBatch($records); - self::assertSame([], $test->getRecords()); + self::assertSame([], $testHandler->getRecords()); } /** @@ -331,40 +330,38 @@ public function testHandleBatch2(): void public function testHandleUsesProcessors(): void { $filters = [ - static fn (LogRecord $record) => in_array( - $record->level->value, + static fn (LogRecord $logRecord): bool => in_array( + $logRecord->level->value, [Level::Debug->value, Level::Warning->value], - true, + strict: true, ), ]; - $test = new TestHandler(); + $testHandler = new TestHandler(); - $record1 = $this->getRecord(); - $record2 = $this->getRecord(Level::Error); + $logRecord = $this->getRecord(); + $record2 = $this->getRecord(Level::Error); - $callback = static function (LogRecord $record): LogRecord { - $record->extra['foo'] = true; + $callback = static function (LogRecord $logRecord): LogRecord { + $logRecord->extra['foo'] = true; - return $record; + return $logRecord; }; - $processor = $this->getMockBuilder(ProcessorInterface::class) - ->disableOriginalConstructor() - ->getMock(); + $processor = $this->createMock(ProcessorInterface::class); $processor->expects(self::once()) ->method('__invoke') - ->with($record1) + ->with($logRecord) ->willReturnCallback($callback); - $handler = new CallbackFilterHandler($test, $filters); - $handler->pushProcessor($processor); + $callbackFilterHandler = new CallbackFilterHandler($testHandler, $filters); + $callbackFilterHandler->pushProcessor($processor); - $handler->handle($record1); - $handler->handle($record2); + $callbackFilterHandler->handle($logRecord); + $callbackFilterHandler->handle($record2); self::assertTrue( - $test->hasOnlyRecordsMatching( + $testHandler->hasOnlyRecordsMatching( [ 'extra' => ['foo' => true], 'level' => Level::Warning, @@ -381,22 +378,22 @@ public function testHandleUsesProcessors(): void * @throws Exception * @throws RuntimeException */ - #[DataProvider('provideSuiteBubbleRecords')] - public function testHandleRespectsBubble(LogRecord $record): void + #[DataProvider(methodName: 'provideSuiteBubbleRecords')] + public function testHandleRespectsBubble(LogRecord $logRecord): void { $filters = [ - static fn (LogRecord $record) => in_array( - $record->level->value, + static fn (LogRecord $logRecord): bool => in_array( + $logRecord->level->value, [Level::Info->value, Level::Notice->value], - true, + strict: true, ), ]; $testlvl = Level::Info; - $test = new TestHandler(); + $testHandler = new TestHandler(); foreach ([false, true] as $bubble) { - $handler = new CallbackFilterHandler($test, $filters, $testlvl, $bubble); + $handler = new CallbackFilterHandler($testHandler, $filters, $testlvl, $bubble); if ($record->level->value === Level::Notice->value && $bubble === false) { self::assertTrue($handler->handle($record)); @@ -414,21 +411,21 @@ public function testHandleRespectsBubble(LogRecord $record): void * @throws Exception * @throws RuntimeException */ - #[DataProvider('provideSuiteBubbleRecords')] - public function testHandleRespectsBubbleWithLoglevel(LogRecord $record): void + #[DataProvider(methodName: 'provideSuiteBubbleRecords')] + public function testHandleRespectsBubbleWithLoglevel(LogRecord $logRecord): void { - $filters = [ - static fn (LogRecord $record) => in_array( - $record->level->value, + $filters = [ + static fn (LogRecord $logRecord): bool => in_array( + $logRecord->level->value, [Level::Info->value, Level::Notice->value], - true, + strict: true, ), ]; - $testlvl = LogLevel::INFO; - $test = new TestHandler(); + $testlvl = LogLevel::INFO; + $testHandler = new TestHandler(); foreach ([false, true] as $bubble) { - $handler = new CallbackFilterHandler($test, $filters, $testlvl, $bubble); + $handler = new CallbackFilterHandler($testHandler, $filters, $testlvl, $bubble); if ($record->level->value === Level::Notice->value && $bubble === false) { self::assertTrue($handler->handle($record)); @@ -551,9 +548,9 @@ public function close(): void } }; - $handler = new CallbackFilterHandler($test, $filters); + $callbackFilterHandler = new CallbackFilterHandler($test, $filters); - self::assertSame($test, $handler->getHandler()); + self::assertSame($test, $callbackFilterHandler->getHandler()); } /** @@ -566,9 +563,9 @@ public function testGetHandlerWithClosureFailure(): void { $filters = []; - $logRecord = $this->createMock(LogRecord::class); + $logRecord = $this->createStub(LogRecord::class); - $handler = new CallbackFilterHandler( + $callbackFilterHandler = new CallbackFilterHandler( /** * @throws void * @@ -586,7 +583,7 @@ static function (LogRecord $innerRecord, HandlerInterface $innerHandler) use ($l $this->expectExceptionMessage('The factory Closure should return a HandlerInterface'); $this->expectExceptionCode(0); - $handler->getHandler($logRecord); + $callbackFilterHandler->getHandler($logRecord); } /** @@ -599,10 +596,10 @@ public function testGetHandlerWithClosure(): void { $filters = []; - $logRecord = $this->createMock(LogRecord::class); - $testHandler = $this->createMock(HandlerInterface::class); + $logRecord = $this->createStub(LogRecord::class); + $testHandler = $this->createStub(HandlerInterface::class); - $handler = new CallbackFilterHandler( + $callbackFilterHandler = new CallbackFilterHandler( /** * @throws void * @@ -616,7 +613,7 @@ static function (LogRecord $innerRecord, HandlerInterface $innerHandler) use ($l $filters, ); - self::assertSame($testHandler, $handler->getHandler($logRecord)); + self::assertSame($testHandler, $callbackFilterHandler->getHandler($logRecord)); } /** @@ -626,29 +623,25 @@ static function (LogRecord $innerRecord, HandlerInterface $innerHandler) use ($l public function testReset(): void { $filters = [ - static fn (LogRecord $record) => in_array( - $record->level->value, + static fn (LogRecord $logRecord): bool => in_array( + $logRecord->level->value, [Level::Debug->value, Level::Warning->value], - true, + strict: true, ), ]; - $test = $this->getMockBuilder(GroupHandler::class) - ->disableOriginalConstructor() - ->getMock(); + $test = $this->createMock(GroupHandler::class); $test->expects(self::once()) ->method('reset'); - $processor = $this->getMockBuilder(UidProcessor::class) - ->disableOriginalConstructor() - ->getMock(); + $processor = $this->createMock(UidProcessor::class); $processor->expects(self::once()) ->method('reset'); - $handler = new CallbackFilterHandler($test, $filters); - $handler->pushProcessor($processor); + $callbackFilterHandler = new CallbackFilterHandler($test, $filters); + $callbackFilterHandler->pushProcessor($processor); - $handler->reset(); + $callbackFilterHandler->reset(); } /** @@ -658,28 +651,24 @@ public function testReset(): void public function testReset2(): void { $filters = [ - static fn (LogRecord $record) => in_array( - $record->level->value, + static fn (LogRecord $logRecord): bool => in_array( + $logRecord->level->value, [Level::Debug->value, Level::Warning->value], - true, + strict: true, ), ]; - $test = $this->getMockBuilder(AbstractTestHandler::class) - ->disableOriginalConstructor() - ->getMock(); + $test = $this->createMock(AbstractTestHandler::class); $test->expects(self::never()) ->method('reset'); - $processor = $this->getMockBuilder(UidProcessor::class) - ->disableOriginalConstructor() - ->getMock(); + $processor = $this->createMock(UidProcessor::class); $processor->expects(self::once()) ->method('reset'); - $handler = new CallbackFilterHandler($test, $filters); - $handler->pushProcessor($processor); + $callbackFilterHandler = new CallbackFilterHandler($test, $filters); + $callbackFilterHandler->pushProcessor($processor); - $handler->reset(); + $callbackFilterHandler->reset(); } } From a60073ab7c6586af0dad48ed0f90b4e4f3861d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 21 Aug 2026 07:16:40 +0200 Subject: [PATCH 3/6] fix issue --- tests/CallbackFilterHandlerTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/CallbackFilterHandlerTest.php b/tests/CallbackFilterHandlerTest.php index 9b36205..ca3b4f3 100644 --- a/tests/CallbackFilterHandlerTest.php +++ b/tests/CallbackFilterHandlerTest.php @@ -563,7 +563,7 @@ public function testGetHandlerWithClosureFailure(): void { $filters = []; - $logRecord = $this->createStub(LogRecord::class); + $logRecord = self::createStub(LogRecord::class); $callbackFilterHandler = new CallbackFilterHandler( /** @@ -596,8 +596,8 @@ public function testGetHandlerWithClosure(): void { $filters = []; - $logRecord = $this->createStub(LogRecord::class); - $testHandler = $this->createStub(HandlerInterface::class); + $logRecord = self::createStub(LogRecord::class); + $testHandler = self::createStub(HandlerInterface::class); $callbackFilterHandler = new CallbackFilterHandler( /** From 1d9156560af9878e08961ec68011271b85465107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 21 Aug 2026 07:24:19 +0200 Subject: [PATCH 4/6] fix issue --- tests/CallbackFilterHandlerTest.php | 56 +++++++++++++++++++---------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/tests/CallbackFilterHandlerTest.php b/tests/CallbackFilterHandlerTest.php index ca3b4f3..f8fc68e 100644 --- a/tests/CallbackFilterHandlerTest.php +++ b/tests/CallbackFilterHandlerTest.php @@ -163,10 +163,16 @@ public function testIsHandlingLevelAndCallback(LogRecord $logRecord): void $callbackFilterHandler = new CallbackFilterHandler($test, $filters, $testlvl); - if (in_array($record->level->value, [Level::Info->value, Level::Notice->value], strict: true)) { - self::assertTrue($callbackFilterHandler->isHandling($record)); + if ( + in_array( + $logRecord->level->value, + [Level::Info->value, Level::Notice->value], + strict: true, + ) + ) { + self::assertTrue($callbackFilterHandler->isHandling($logRecord)); } else { - self::assertFalse($callbackFilterHandler->isHandling($record)); + self::assertFalse($callbackFilterHandler->isHandling($logRecord)); } } @@ -200,10 +206,16 @@ public function testIsHandlingLevelAndCallbackWithLoglevel(LogRecord $logRecord) $callbackFilterHandler = new CallbackFilterHandler($test, $filters, $testlvl); - if (in_array($record->level->value, [Level::Info->value, Level::Notice->value], strict: true)) { - self::assertTrue($callbackFilterHandler->isHandling($record)); + if ( + in_array( + $logRecord->level->value, + [Level::Info->value, Level::Notice->value], + strict: true, + ) + ) { + self::assertTrue($callbackFilterHandler->isHandling($logRecord)); } else { - self::assertFalse($callbackFilterHandler->isHandling($record)); + self::assertFalse($callbackFilterHandler->isHandling($logRecord)); } } @@ -226,13 +238,19 @@ public function testHandleProcessOnlyNeededLevels(LogRecord $logRecord): void $testHandler = new TestHandler(); $callbackFilterHandler = new CallbackFilterHandler($testHandler, $filters); - $callbackFilterHandler->handle($record); + $callbackFilterHandler->handle($logRecord); - $levelName = Level::fromValue($record->level->value)->getName(); + $levelName = Level::fromValue($logRecord->level->value)->getName(); $hasMethod = 'has' . ucfirst(mb_strtolower($levelName)); $result = $testHandler->{$hasMethod}(sprintf('sample of %s message', $levelName)); - if (in_array($record->level->value, [Level::Info->value, Level::Notice->value], strict: true)) { + if ( + in_array( + $logRecord->level->value, + [Level::Info->value, Level::Notice->value], + strict: true, + ) + ) { self::assertTrue($result); } else { self::assertFalse($result); @@ -259,12 +277,12 @@ public function testHandleProcessAllMatchingRules(LogRecord $logRecord): void $testHandler = new TestHandler(); $callbackFilterHandler = new CallbackFilterHandler($testHandler, $filters); - $callbackFilterHandler->handle($record); + $callbackFilterHandler->handle($logRecord); - if ($record->level->value === Level::Notice->value) { - self::assertTrue($testHandler->hasNoticeThatContains($record->message)); + if ($logRecord->level->value === Level::Notice->value) { + self::assertTrue($testHandler->hasNoticeThatContains($logRecord->message)); } else { - self::assertFalse($testHandler->hasNoticeThatContains($record->message)); + self::assertFalse($testHandler->hasNoticeThatContains($logRecord->message)); } } @@ -395,10 +413,10 @@ public function testHandleRespectsBubble(LogRecord $logRecord): void foreach ([false, true] as $bubble) { $handler = new CallbackFilterHandler($testHandler, $filters, $testlvl, $bubble); - if ($record->level->value === Level::Notice->value && $bubble === false) { - self::assertTrue($handler->handle($record)); + if ($logRecord->level->value === Level::Notice->value && $bubble === false) { + self::assertTrue($handler->handle($logRecord)); } else { - self::assertFalse($handler->handle($record)); + self::assertFalse($handler->handle($logRecord)); } } } @@ -427,10 +445,10 @@ public function testHandleRespectsBubbleWithLoglevel(LogRecord $logRecord): void foreach ([false, true] as $bubble) { $handler = new CallbackFilterHandler($testHandler, $filters, $testlvl, $bubble); - if ($record->level->value === Level::Notice->value && $bubble === false) { - self::assertTrue($handler->handle($record)); + if ($logRecord->level->value === Level::Notice->value && $bubble === false) { + self::assertTrue($handler->handle($logRecord)); } else { - self::assertFalse($handler->handle($record)); + self::assertFalse($handler->handle($logRecord)); } } } From 7ee901bd15f17cc41938c969613e8e28af14f3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 21 Aug 2026 07:37:43 +0200 Subject: [PATCH 5/6] fix issue --- phpstan.neon | 2 ++ src/CallbackFilterHandler.php | 2 +- tests/CallbackFilterHandlerTest.php | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index 9e9e0ff..f3b92d6 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -108,6 +108,8 @@ parameters: narrow_param: true ignoreErrors: + - + identifier: argument.named # - '~Method Mimmi20\\Monolog\\Handler\\CallbackFilterHandler::getHandler\(\) has RuntimeException in PHPDoc @throws tag but it.s not thrown~' - '~Parameter #2 \$filters of class Mimmi20\\Monolog\\Handler\\CallbackFilterHandler constructor expects array, array{false} given~' - '~Parameter #1 \$handler of class Mimmi20\\Monolog\\Handler\\CallbackFilterHandler constructor expects \(Closure\(Monolog\\LogRecord\|null, Monolog\\Handler\\HandlerInterface\):.*Monolog\\Handler\\HandlerInterface\)\|Monolog\\Handler\\HandlerInterface, Closure\(Monolog\\LogRecord, Monolog\\Handler\\HandlerInterface\):~' diff --git a/src/CallbackFilterHandler.php b/src/CallbackFilterHandler.php index 3865a72..018f1eb 100644 --- a/src/CallbackFilterHandler.php +++ b/src/CallbackFilterHandler.php @@ -99,7 +99,7 @@ public function isHandling(LogRecord $record): bool return false; } - if (isset($record->message)) { + if ($record->message) { // when record is fulfilled, try each filter foreach ($this->filters as $filter) { if (!$filter($record, $this->level)) { diff --git a/tests/CallbackFilterHandlerTest.php b/tests/CallbackFilterHandlerTest.php index f8fc68e..0bf9302 100644 --- a/tests/CallbackFilterHandlerTest.php +++ b/tests/CallbackFilterHandlerTest.php @@ -42,6 +42,7 @@ final class CallbackFilterHandlerTest extends AbstractTestCase * * @throws Exception * @throws RuntimeException + * @throws \PHPUnit\Framework\MockObject\Exception */ #[DataProvider(methodName: 'provideSuiteRecords')] public function testIsHandling(LogRecord $logRecord): void @@ -70,6 +71,7 @@ public function testIsHandling(LogRecord $logRecord): void * * @throws Exception * @throws RuntimeException + * @throws \PHPUnit\Framework\MockObject\Exception */ #[DataProvider(methodName: 'provideSuiteRecords')] public function testIsHandlingLevel(LogRecord $logRecord): void @@ -105,6 +107,7 @@ public function testIsHandlingLevel(LogRecord $logRecord): void * @throws Exception * @throws RuntimeException * @throws InvalidArgumentException + * @throws \PHPUnit\Framework\MockObject\Exception */ #[DataProvider(methodName: 'provideSuiteRecords')] public function testIsHandlingLevelWithLoglevel(LogRecord $logRecord): void @@ -138,6 +141,7 @@ public function testIsHandlingLevelWithLoglevel(LogRecord $logRecord): void * * @throws Exception * @throws RuntimeException + * @throws \PHPUnit\Framework\MockObject\Exception */ #[DataProvider(methodName: 'provideSuiteRecords')] public function testIsHandlingLevelAndCallback(LogRecord $logRecord): void @@ -181,6 +185,7 @@ public function testIsHandlingLevelAndCallback(LogRecord $logRecord): void * * @throws Exception * @throws RuntimeException + * @throws \PHPUnit\Framework\MockObject\Exception */ #[DataProvider(methodName: 'provideSuiteRecords')] public function testIsHandlingLevelAndCallbackWithLoglevel(LogRecord $logRecord): void @@ -320,6 +325,7 @@ public function testHandleBatch(): void * @throws Exception * @throws RuntimeException * @throws InvalidArgumentException + * @throws \PHPUnit\Framework\MockObject\Exception */ public function testHandleBatch2(): void { @@ -344,6 +350,7 @@ public function testHandleBatch2(): void * @throws Exception * @throws RuntimeException * @throws InvalidArgumentException + * @throws \PHPUnit\Framework\MockObject\Exception */ public function testHandleUsesProcessors(): void { @@ -637,6 +644,7 @@ static function (LogRecord $innerRecord, HandlerInterface $innerHandler) use ($l /** * @throws Exception * @throws RuntimeException + * @throws \PHPUnit\Framework\MockObject\Exception */ public function testReset(): void { @@ -665,6 +673,7 @@ public function testReset(): void /** * @throws Exception * @throws RuntimeException + * @throws \PHPUnit\Framework\MockObject\Exception */ public function testReset2(): void { From 2e8520002ffbb2d1cd5026d6825a602614c1a856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 21 Aug 2026 07:41:46 +0200 Subject: [PATCH 6/6] update rector config --- rector.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rector.php b/rector.php index 0118b8d..006345b 100644 --- a/rector.php +++ b/rector.php @@ -12,6 +12,7 @@ declare(strict_types = 1); +use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector; use Rector\Config\RectorConfig; use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector; use Rector\ValueObject\PhpVersion; @@ -41,6 +42,7 @@ ->withComposerBased(phpunit: true) ->withSkip([ PreferPHPUnitThisCallRector::class, + ExplicitBoolCompareRector::class, ]) ->withoutParallel() ->withMemoryLimit('2048M');