Skip to content

Commit 33b0e9d

Browse files
committed
Tests: add types
1 parent 2c1c867 commit 33b0e9d

18 files changed

Lines changed: 52 additions & 79 deletions

src/DI/EventBridgesExtension.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
class EventBridgesExtension extends CompilerExtension
1414
{
1515

16+
/** @var array<string, class-string<CompilerExtension>> */
17+
private array $map = [
18+
'application' => EventApplicationBridgeExtension::class,
19+
'latte' => EventLatteBridgeExtension::class,
20+
'security' => EventSecurityBridgeExtension::class,
21+
];
22+
23+
/** @var array<string, CompilerExtension> */
24+
private array $passes = [];
25+
1626
public function getConfigSchema(): Schema
1727
{
1828
return Expect::structure([
@@ -22,16 +32,6 @@ public function getConfigSchema(): Schema
2232
])->castTo('array');
2333
}
2434

25-
/** @var array<string, class-string<CompilerExtension>> */
26-
private $map = [
27-
'application' => EventApplicationBridgeExtension::class,
28-
'latte' => EventLatteBridgeExtension::class,
29-
'security' => EventSecurityBridgeExtension::class,
30-
];
31-
32-
/** @var array<string, CompilerExtension> */
33-
private $passes = [];
34-
3535
/**
3636
* Register services
3737
*/
@@ -74,7 +74,7 @@ public function beforeCompile(): void
7474
/**
7575
* Decorate initialize method
7676
*/
77-
public function afterCompile(ClassType $class)
77+
public function afterCompile(ClassType $class): void
7878
{
7979
foreach ($this->passes as $pass) {
8080
$pass->afterCompile($class);

src/DI/EventLatteBridgeExtension.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use Contributte\Events\Extra\Event\Latte\LatteCompileEvent;
66
use Contributte\Events\Extra\Event\Latte\TemplateCreateEvent;
77
use LogicException;
8-
use Nette\Application\UI\TemplateFactory;
98
use Nette\Bridges\ApplicationLatte\LatteFactory;
9+
use Nette\Bridges\ApplicationLatte\TemplateFactory;
1010
use Nette\DI\CompilerExtension;
1111
use Nette\DI\Definitions\FactoryDefinition;
1212
use Nette\DI\Definitions\ServiceDefinition;
@@ -44,9 +44,6 @@ public function beforeCompile(): void
4444
$templateFactories = $builder->findByType(TemplateFactory::class);
4545
foreach ($templateFactories as $templateFactory) {
4646
assert($templateFactory instanceof ServiceDefinition);
47-
if ($templateFactory->factory === null || $templateFactory->factory->entity !== TemplateFactory::class) {
48-
continue;
49-
}
5047

5148
$templateFactory->addSetup('?->onCreate[] = function() {?->dispatch(new ?(...func_get_args()));}', [
5249
'@self',

src/Event/Application/ErrorEvent.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
class ErrorEvent extends Event
1010
{
1111

12-
/** @var Application */
13-
private $application;
12+
private Application $application;
1413

15-
/** @var Throwable */
16-
private $throwable;
14+
private Throwable $throwable;
1715

1816
public function __construct(Application $application, Throwable $throwable)
1917
{

src/Event/Application/PresenterEvent.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
class PresenterEvent extends Event
1010
{
1111

12-
/** @var Application */
13-
private $application;
12+
private Application $application;
1413

15-
/** @var IPresenter */
16-
private $presenter;
14+
private IPresenter $presenter;
1715

1816
public function __construct(Application $application, IPresenter $presenter)
1917
{

src/Event/Application/PresenterShutdownEvent.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
class PresenterShutdownEvent extends Event
1010
{
1111

12-
/** @var Presenter */
13-
private $presenter;
12+
private Presenter $presenter;
1413

15-
/** @var Response */
16-
private $response;
14+
private Response $response;
1715

1816
public function __construct(Presenter $presenter, Response $response)
1917
{

src/Event/Application/PresenterStartupEvent.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
class PresenterStartupEvent extends Event
99
{
1010

11-
/** @var Presenter */
12-
private $presenter;
11+
private Presenter $presenter;
1312

1413
public function __construct(Presenter $presenter)
1514
{

src/Event/Application/RequestEvent.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
class RequestEvent extends Event
1010
{
1111

12-
/** @var Application */
13-
private $application;
12+
private Application $application;
1413

15-
/** @var Request */
16-
private $request;
14+
private Request $request;
1715

1816
public function __construct(Application $application, Request $request)
1917
{

src/Event/Application/ResponseEvent.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
class ResponseEvent extends Event
1010
{
1111

12-
/** @var Application */
13-
private $application;
12+
private Application $application;
1413

15-
/** @var Response */
16-
private $response;
14+
private Response $response;
1715

1816
public function __construct(Application $application, Response $response)
1917
{

src/Event/Application/ShutdownEvent.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
class ShutdownEvent extends Event
1010
{
1111

12-
/** @var Application */
13-
private $application;
12+
private Application $application;
1413

15-
/** @var Throwable|null */
16-
private $throwable;
14+
private ?Throwable $throwable = null;
1715

1816
public function __construct(Application $application, ?Throwable $throwable = null)
1917
{

src/Event/Application/StartupEvent.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
class StartupEvent extends Event
99
{
1010

11-
/** @var Application */
12-
private $application;
11+
private Application $application;
1312

1413
public function __construct(Application $application)
1514
{

0 commit comments

Comments
 (0)