diff --git a/.php_cs.dist b/.php_cs.dist index 338811d8..bc32a66b 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -43,6 +43,7 @@ $rules = [ '@PHP71Migration:risky' => true, 'compact_nullable_typehint' => true, 'void_return' => null, + 'static_lambda' => true, 'strict_comparison' => true, 'strict_param' => true, 'php_unit_strict' => true, diff --git a/src/DependencyInjection/SonataNotificationExtension.php b/src/DependencyInjection/SonataNotificationExtension.php index 977ac937..23232164 100644 --- a/src/DependencyInjection/SonataNotificationExtension.php +++ b/src/DependencyInjection/SonataNotificationExtension.php @@ -468,7 +468,7 @@ protected function createAMQPBackend(ContainerBuilder $container, $exchange, $na */ private function getQueuesParameters($name, array $queues) { - $params = array_unique(array_map(function ($q) use ($name) { + $params = array_unique(array_map(static function ($q) use ($name) { return $q[$name]; }, $queues)); diff --git a/tests/Backend/PostponeRuntimeBackendTest.php b/tests/Backend/PostponeRuntimeBackendTest.php index dcf2efff..cd5091c7 100644 --- a/tests/Backend/PostponeRuntimeBackendTest.php +++ b/tests/Backend/PostponeRuntimeBackendTest.php @@ -84,7 +84,7 @@ public function testLiveEnvironment(): void $phpunit = $this; $phpunit->passed = false; - $dispatcher->addListener('notification.demo', function (ConsumerEventInterface $event) use ($phpunit, $message): void { + $dispatcher->addListener('notification.demo', static function (ConsumerEventInterface $event) use ($phpunit, $message): void { $phpunit->assertSame($message, $event->getMessage()); $phpunit->passed = true; @@ -111,7 +111,7 @@ public function testRecursiveMessage(): void $phpunit->passed1 = false; $phpunit->passed2 = false; - $dispatcher->addListener('notification.demo1', function (ConsumerEventInterface $event) use ($phpunit, $message1, $message2, $backend, $dispatcher): void { + $dispatcher->addListener('notification.demo1', static function (ConsumerEventInterface $event) use ($phpunit, $message1, $message2, $backend, $dispatcher): void { $phpunit->assertSame($message1, $event->getMessage()); $phpunit->passed1 = true; @@ -119,7 +119,7 @@ public function testRecursiveMessage(): void $backend->publish($message2); }); - $dispatcher->addListener('notification.demo2', function (ConsumerEventInterface $event) use ($phpunit, $message2): void { + $dispatcher->addListener('notification.demo2', static function (ConsumerEventInterface $event) use ($phpunit, $message2): void { $phpunit->assertSame($message2, $event->getMessage()); $phpunit->passed2 = true; diff --git a/tests/Entity/MessageManagerTest.php b/tests/Entity/MessageManagerTest.php index 03f0ddb4..bc86ac56 100644 --- a/tests/Entity/MessageManagerTest.php +++ b/tests/Entity/MessageManagerTest.php @@ -59,7 +59,7 @@ public function testGetPager(): void { $self = $this; $this - ->getMessageManager(function ($qb) use ($self): void { + ->getMessageManager(static function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['m'])); $qb->expects($self->never())->method('andWhere'); $qb->expects($self->once())->method('setParameters')->with([]); @@ -78,7 +78,7 @@ public function testGetPagerWithInvalidSort(): void $self = $this; $this - ->getMessageManager(function ($qb) use ($self): void { + ->getMessageManager(static function ($qb) use ($self): void { }) ->getPager([], 1, 10, ['invalid' => 'ASC']); } @@ -87,7 +87,7 @@ public function testGetPagerWithMultipleSort(): void { $self = $this; $this - ->getMessageManager(function ($qb) use ($self): void { + ->getMessageManager(static function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['m'])); $qb->expects($self->never())->method('andWhere'); $qb->expects($self->once())->method('setParameters')->with([]); @@ -113,7 +113,7 @@ public function testGetPagerWithOpenedMessages(): void { $self = $this; $this - ->getMessageManager(function ($qb) use ($self): void { + ->getMessageManager(static function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['m'])); $qb->expects($self->once())->method('andWhere')->with($self->equalTo('m.state = :state')); $qb->expects($self->once())->method('setParameters')->with($self->equalTo([ @@ -127,7 +127,7 @@ public function testGetPagerWithCanceledMessages(): void { $self = $this; $this - ->getMessageManager(function ($qb) use ($self): void { + ->getMessageManager(static function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['m'])); $qb->expects($self->once())->method('andWhere')->with($self->equalTo('m.state = :state')); $qb->expects($self->once())->method('setParameters')->with($self->equalTo([ @@ -141,7 +141,7 @@ public function testGetPagerWithInProgressMessages(): void { $self = $this; $this - ->getMessageManager(function ($qb) use ($self): void { + ->getMessageManager(static function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['m'])); $qb->expects($self->once())->method('andWhere')->with($self->equalTo('m.state = :state')); $qb->expects($self->once())->method('setParameters')->with($self->equalTo([