Skip to content

Commit e190184

Browse files
committed
Use ::class keyword when possible
1 parent 3fdeae3 commit e190184

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

Tests/DependencyInjection/RegisterListenersPassTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RegisterListenersPassTest extends TestCase
2828
*/
2929
public function testEventSubscriberWithoutInterface()
3030
{
31-
$this->expectException('InvalidArgumentException');
31+
$this->expectException(\InvalidArgumentException::class);
3232
$builder = new ContainerBuilder();
3333
$builder->register('event_dispatcher');
3434
$builder->register('my_event_subscriber', 'stdClass')
@@ -98,7 +98,7 @@ public function testAliasedEventSubscriber()
9898

9999
public function testAbstractEventListener()
100100
{
101-
$this->expectException('InvalidArgumentException');
101+
$this->expectException(\InvalidArgumentException::class);
102102
$this->expectExceptionMessage('The service "foo" tagged "kernel.event_listener" must not be abstract.');
103103
$container = new ContainerBuilder();
104104
$container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_listener', []);
@@ -110,7 +110,7 @@ public function testAbstractEventListener()
110110

111111
public function testAbstractEventSubscriber()
112112
{
113-
$this->expectException('InvalidArgumentException');
113+
$this->expectException(\InvalidArgumentException::class);
114114
$this->expectExceptionMessage('The service "foo" tagged "kernel.event_subscriber" must not be abstract.');
115115
$container = new ContainerBuilder();
116116
$container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_subscriber', []);
@@ -159,7 +159,7 @@ public function testHotPathEvents()
159159

160160
public function testEventSubscriberUnresolvableClassName()
161161
{
162-
$this->expectException('InvalidArgumentException');
162+
$this->expectException(\InvalidArgumentException::class);
163163
$this->expectExceptionMessage('You have requested a non-existent parameter "subscriber.class"');
164164
$container = new ContainerBuilder();
165165
$container->register('foo', '%subscriber.class%')->addTag('kernel.event_subscriber', []);

Tests/EventDispatcherTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ public function testDispatch()
134134
$this->dispatcher->dispatch(new Event(), self::preFoo);
135135
$this->assertTrue($this->listener->preFooInvoked);
136136
$this->assertFalse($this->listener->postFooInvoked);
137-
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), 'noevent'));
138-
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), self::preFoo));
137+
$this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), 'noevent'));
138+
$this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), self::preFoo));
139139
$event = new Event();
140140
$return = $this->dispatcher->dispatch($event, self::preFoo);
141141
$this->assertSame($event, $return);
@@ -148,8 +148,8 @@ public function testDispatchContractsEvent()
148148
$this->dispatcher->dispatch(new ContractsEvent(), self::preFoo);
149149
$this->assertTrue($this->listener->preFooInvoked);
150150
$this->assertFalse($this->listener->postFooInvoked);
151-
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), 'noevent'));
152-
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(new Event(), self::preFoo));
151+
$this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), 'noevent'));
152+
$this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), self::preFoo));
153153
$event = new Event();
154154
$return = $this->dispatcher->dispatch($event, self::preFoo);
155155
$this->assertSame($event, $return);
@@ -228,7 +228,7 @@ public function testAddSubscriberWithPriorities()
228228
$listeners = $this->dispatcher->getListeners('pre.foo');
229229
$this->assertTrue($this->dispatcher->hasListeners(self::preFoo));
230230
$this->assertCount(2, $listeners);
231-
$this->assertInstanceOf('Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities', $listeners[0][0]);
231+
$this->assertInstanceOf(\Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities::class, $listeners[0][0]);
232232
}
233233

234234
public function testAddSubscriberWithMultipleListeners()

Tests/ImmutableEventDispatcherTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ImmutableEventDispatcherTest extends TestCase
3333

3434
protected function setUp(): void
3535
{
36-
$this->innerDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
36+
$this->innerDispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
3737
$this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher);
3838
}
3939

@@ -79,7 +79,7 @@ public function testAddListenerDisallowed()
7979
public function testAddSubscriberDisallowed()
8080
{
8181
$this->expectException(\BadMethodCallException::class);
82-
$subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
82+
$subscriber = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventSubscriberInterface::class)->getMock();
8383

8484
$this->dispatcher->addSubscriber($subscriber);
8585
}
@@ -93,7 +93,7 @@ public function testRemoveListenerDisallowed()
9393
public function testRemoveSubscriberDisallowed()
9494
{
9595
$this->expectException(\BadMethodCallException::class);
96-
$subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
96+
$subscriber = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventSubscriberInterface::class)->getMock();
9797

9898
$this->dispatcher->removeSubscriber($subscriber);
9999
}

0 commit comments

Comments
 (0)