Skip to content

Commit bb7f887

Browse files
Merge branch '6.4' into 7.0
* 6.4: Use typed properties in tests as much as possible
2 parents ec83642 + 8a9a52c commit bb7f887

File tree

3 files changed

+12
-45
lines changed

3 files changed

+12
-45
lines changed

Tests/EventDispatcherTest.php

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,15 @@ class EventDispatcherTest extends TestCase
2323
private const postFoo = 'post.foo';
2424
private const preBar = 'pre.bar';
2525

26-
/**
27-
* @var EventDispatcher
28-
*/
29-
private $dispatcher;
30-
31-
private $listener;
26+
private EventDispatcher $dispatcher;
27+
private TestEventListener $listener;
3228

3329
protected function setUp(): void
3430
{
3531
$this->dispatcher = $this->createEventDispatcher();
3632
$this->listener = new TestEventListener();
3733
}
3834

39-
protected function tearDown(): void
40-
{
41-
$this->dispatcher = null;
42-
$this->listener = null;
43-
}
44-
4535
protected function createEventDispatcher()
4636
{
4737
return new EventDispatcher();
@@ -446,9 +436,9 @@ public function __invoke()
446436

447437
class TestEventListener
448438
{
449-
public $name;
450-
public $preFooInvoked = false;
451-
public $postFooInvoked = false;
439+
public string $name;
440+
public bool $preFooInvoked = false;
441+
public bool $postFooInvoked = false;
452442

453443
/* Listener methods */
454444

@@ -473,9 +463,9 @@ public function __invoke()
473463

474464
class TestWithDispatcher
475465
{
476-
public $name;
477-
public $dispatcher;
478-
public $invoked = false;
466+
public ?string $name = null;
467+
public ?EventDispatcher $dispatcher = null;
468+
public bool $invoked = false;
479469

480470
public function foo($e, $name, $dispatcher)
481471
{

Tests/GenericEventTest.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,15 @@
1919
*/
2020
class GenericEventTest extends TestCase
2121
{
22-
/**
23-
* @var GenericEvent
24-
*/
25-
private $event;
26-
27-
private $subject;
22+
private GenericEvent $event;
23+
private \stdClass $subject;
2824

29-
/**
30-
* Prepares the environment before running a test.
31-
*/
3225
protected function setUp(): void
3326
{
3427
$this->subject = new \stdClass();
3528
$this->event = new GenericEvent($this->subject, ['name' => 'Event']);
3629
}
3730

38-
/**
39-
* Cleans up the environment after running a test.
40-
*/
41-
protected function tearDown(): void
42-
{
43-
$this->subject = null;
44-
$this->event = null;
45-
}
46-
4731
public function testConstruct()
4832
{
4933
$this->assertEquals($this->event, new GenericEvent($this->subject, ['name' => 'Event']));

Tests/ImmutableEventDispatcherTest.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,8 @@
2323
*/
2424
class ImmutableEventDispatcherTest extends TestCase
2525
{
26-
/**
27-
* @var MockObject&EventDispatcherInterface
28-
*/
29-
private $innerDispatcher;
30-
31-
/**
32-
* @var ImmutableEventDispatcher
33-
*/
34-
private $dispatcher;
26+
private MockObject&EventDispatcherInterface $innerDispatcher;
27+
private ImmutableEventDispatcher $dispatcher;
3528

3629
protected function setUp(): void
3730
{

0 commit comments

Comments
 (0)