Skip to content

Commit 753547e

Browse files
committed
apply strict type declaration rector set
1 parent 609ee69 commit 753547e

24 files changed

+159
-170
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"phpstan/phpstan": "^0.12.90",
7373
"phpstan/phpstan-webmozart-assert": "^0.12.7",
7474
"pimple/pimple": "^3.2",
75-
"rector/rector": "^0.11.36",
75+
"rector/rector-src": "dev-main",
7676
"symfony/dependency-injection": "^5.0"
7777
},
7878
"suggest": {

rector.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
use Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector;
77
use Rector\Core\Configuration\Option;
88
use Rector\Core\ValueObject\PhpVersion;
9-
use Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector;
10-
use Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector;
119
use Rector\Set\ValueObject\SetList;
12-
use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector;
1310
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
1411

1512
return static function (ContainerConfigurator $containerConfigurator): void {
@@ -27,6 +24,7 @@
2724
$containerConfigurator->import(SetList::PHP_80);
2825
$containerConfigurator->import(SetList::PSR_4);
2926
$containerConfigurator->import(SetList::TYPE_DECLARATION);
27+
$containerConfigurator->import(SetList::TYPE_DECLARATION_STRICT);
3028

3129
$parameters = $containerConfigurator->parameters();
3230
$parameters->set(Option::PATHS, [__DIR__ . '/config', __DIR__ . '/src', __DIR__ . '/spec']);
@@ -35,18 +33,9 @@
3533
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80);
3634

3735
$parameters->set(Option::SKIP, [
36+
__DIR__ . '/src/Controller',
37+
__DIR__ . '/src/Middleware/Routed/Preview',
3838
CallableThisArrayToAnonymousFunctionRector::class,
3939
UnSpreadOperatorRector::class,
40-
RemoveUnusedVariableAssignRector::class => [
41-
__DIR__ . '/src/Controller',
42-
__DIR__ . '/src/Middleware/Routed/Preview',
43-
],
44-
RemoveDeadStmtRector::class => [
45-
__DIR__ . '/src/Controller',
46-
__DIR__ . '/src/Middleware/Routed/Preview',
47-
],
48-
ReturnTypeDeclarationRector::class => [
49-
__DIR__ . '/src/Controller',
50-
],
5140
]);
5241
};

spec/Handler/Formatter/JsonSpec.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
use DateTime;
66
use ErrorHeroModule\Handler\Formatter\Json;
77

8-
describe('Json', function () {
8+
describe('Json', function (): void {
99

10-
describe('->format()', function () {
10+
describe('->format()', function (): void {
1111

12-
it('format json', function () {
12+
it('format json', function (): void {
1313

1414
$event = [
1515
'timestamp' => DateTime::__set_state([

spec/Handler/LoggingFactorySpec.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use Psr\Container\ContainerInterface;
1414
use RuntimeException;
1515

16-
describe('LoggingFactorySpec', function () {
16+
describe('LoggingFactorySpec', function (): void {
1717

1818
given('factory', fn() => new LoggingFactory());
1919

@@ -98,9 +98,9 @@
9898
],
9999
]);
100100

101-
describe('__invoke()', function () {
101+
describe('__invoke()', function (): void {
102102

103-
it('instance of Logging on non-console with container does not has "Request" service', function () {
103+
it('instance of Logging on non-console with container does not has "Request" service', function (): void {
104104

105105
Console::overrideIsConsole(false);
106106
$config = $this->config;
@@ -120,7 +120,7 @@
120120

121121
});
122122

123-
it('instance of Logging without bring Laminas\Mail\Message and Laminas\Mail\Transport if email-notification-settings is disabled', function () {
123+
it('instance of Logging without bring Laminas\Mail\Message and Laminas\Mail\Transport if email-notification-settings is disabled', function (): void {
124124

125125
$config = $this->config;
126126

@@ -137,7 +137,7 @@
137137

138138
});
139139

140-
it('throw RuntimeException if Logging try bring non-existence Laminas\Mail\Message service while email-notification-settings is enabled', function () {
140+
it('throw RuntimeException if Logging try bring non-existence Laminas\Mail\Message service while email-notification-settings is enabled', function (): void {
141141

142142
$config = $this->config;
143143
$config['error-hero-module']['email-notification-settings']['enable'] = true;
@@ -150,15 +150,15 @@
150150
allow($container)->toReceive('get')->with('ErrorHeroModuleLogger')
151151
->andReturn($logger);
152152

153-
$closure = function () use ($container) {
153+
$closure = function () use ($container): void {
154154
$this->factory($container);
155155
};
156156

157157
expect($closure)->toThrow(new RuntimeException());
158158

159159
});
160160

161-
it('throw RuntimeException if Logging try bring non-existence Laminas\Mail\Transport\TransportInterface service while email-notification-settings is enabled', function () {
161+
it('throw RuntimeException if Logging try bring non-existence Laminas\Mail\Transport\TransportInterface service while email-notification-settings is enabled', function (): void {
162162

163163
$config = $this->config;
164164
$config['error-hero-module']['email-notification-settings']['enable'] = true;
@@ -174,15 +174,15 @@
174174
allow($container)->toReceive('get')->with('MailMessageService')
175175
->andReturn(new Message());
176176

177-
$closure = function () use ($container) {
177+
$closure = function () use ($container): void {
178178
$this->factory($container);
179179
};
180180

181181
expect($closure)->toThrow(new RuntimeException());
182182

183183
});
184184

185-
it('instance of Logging with bring Laminas\Mail\Message and Laminas\Mail\Transport if email-notification-settings is enabled and both services exist', function () {
185+
it('instance of Logging with bring Laminas\Mail\Message and Laminas\Mail\Transport if email-notification-settings is enabled and both services exist', function (): void {
186186

187187
$config = $this->config;
188188
$config['error-hero-module']['email-notification-settings']['enable'] = true;

spec/Handler/LoggingSpec.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
use Laminas\Mail\Message;
1818
use ReflectionProperty;
1919

20-
describe('LoggingSpec', function () {
20+
describe('LoggingSpec', function (): void {
2121

22-
beforeAll(function () {
22+
beforeAll(function (): void {
2323
$this->logger = Double::instance(['extends' => Logger::class]);
2424
$this->request = new Request();
2525
$this->request->setUri('http://www.example.com');
@@ -114,9 +114,9 @@
114114
null
115115
));
116116

117-
describe('->handleErrorException()', function () {
117+
describe('->handleErrorException()', function (): void {
118118

119-
it('not log if exists', function () {
119+
it('not log if exists', function (): void {
120120

121121
$sql = Double::instance(['extends' => Sql::class, 'methods' => '__construct']);
122122
allow(TableGateway::class)->toReceive('getSql')->andReturn($sql);
@@ -144,7 +144,7 @@
144144

145145
});
146146

147-
it('not log if exists and exception instanceof ErrorException', function () {
147+
it('not log if exists and exception instanceof ErrorException', function (): void {
148148

149149
$sql = Double::instance(['extends' => Sql::class, 'methods' => '__construct']);
150150
allow(TableGateway::class)->toReceive('getSql')->andReturn($sql);

spec/Handler/Writer/Checker/DbSpec.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
use Laminas\Log\Writer\Db as DbWriter;
1313
use ReflectionProperty;
1414

15-
describe('Db', function () {
15+
describe('Db', function (): void {
1616

17-
beforeAll(function () {
17+
beforeAll(function (): void {
1818

1919
$this->dbWriter = Double::instance(['extends' => DbWriter::class, 'methods' => '__construct']);
2020
$reflectionProperty = new ReflectionProperty($this->dbWriter, 'db');
@@ -56,9 +56,9 @@
5656
$this->logWritersConfig
5757
));
5858

59-
describe('__construct', function () {
59+
describe('__construct', function (): void {
6060

61-
it('instanceof '. Db::class, function () {
61+
it('instanceof '. Db::class, function (): void {
6262

6363
$actual = $this->writerHandler;
6464
expect($actual)->toBeAnInstanceOf(Db::class);
@@ -67,9 +67,9 @@
6767

6868
});
6969

70-
describe('->isExists()', function () {
70+
describe('->isExists()', function (): void {
7171

72-
it('return false if no current data', function () {
72+
it('return false if no current data', function (): void {
7373

7474
$sql = Double::instance(['extends' => Sql::class, 'methods' => '__construct']);
7575
allow(TableGateway::class)->toReceive('getSql')->andReturn($sql);
@@ -90,7 +90,7 @@
9090

9191
});
9292

93-
it('return false if has current data but timestamp is expired', function () {
93+
it('return false if has current data but timestamp is expired', function (): void {
9494

9595
$sql = Double::instance(['extends' => Sql::class, 'methods' => '__construct']);
9696
allow(TableGateway::class)->toReceive('getSql')->andReturn($sql);
@@ -121,7 +121,7 @@
121121

122122
});
123123

124-
it('return true if has current data but timestamp === current time', function () {
124+
it('return true if has current data but timestamp === current time', function (): void {
125125

126126
$sql = Double::instance(['extends' => Sql::class, 'methods' => '__construct']);
127127
allow(TableGateway::class)->toReceive('getSql')->andReturn($sql);

spec/Handler/Writer/MailSpec.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
describe('Mail', function () {
1414

15-
beforeAll(function () {
15+
beforeAll(function (): void {
1616
$this->mailMessage = Double::instance(['extends' => Message::class]);
1717
$this->transport = Double::instance(['implements' => TransportInterface::class]);
1818

@@ -33,7 +33,7 @@
3333

3434
describe('->shutdown', function () {
3535

36-
it('bring multiple collection upload, then transport->send()', function () {
36+
it('bring multiple collection upload, then transport->send()', function (): void {
3737

3838
$writer = new Mail(
3939
$this->mailMessage,
@@ -74,7 +74,7 @@
7474

7575
});
7676

77-
it('bring deeper multiple collection upload, then transport->send()', function () {
77+
it('bring deeper multiple collection upload, then transport->send()', function (): void {
7878

7979
$writer = new Mail(
8080
$this->mailMessage,

spec/Integration/IntegrationViaErrorPreviewConsoleControllerSpec.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242

4343
});
4444

45-
describe('error-preview', function() {
45+
describe('error-preview', function(): void {
4646

47-
it('show error page', function() {
47+
it('show error page', function(): void {
4848

4949
Quit::disable();
5050

@@ -56,7 +56,7 @@
5656
];
5757

5858
\ob_start();
59-
$closure = function () {
59+
$closure = function (): void {
6060
$this->application->run();
6161
};
6262
expect($closure)->toThrow(new QuitException('Exit statement occurred', -1));
@@ -68,9 +68,9 @@
6868

6969
});
7070

71-
describe('error-preview error', function() {
71+
describe('error-preview error', function(): void {
7272

73-
it('show error page', function() {
73+
it('show error page', function(): void {
7474

7575
Quit::disable();
7676

@@ -82,7 +82,7 @@
8282
];
8383

8484
\ob_start();
85-
$closure = function () {
85+
$closure = function (): void {
8686
$this->application->run();
8787
};
8888
expect($closure)->toThrow(new QuitException('Exit statement occurred', -1));

spec/Integration/IntegrationViaErrorPreviewConsoleControllerWithDoctrineORMModuleSpec.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141

4242
});
4343

44-
describe('error-preview', function() {
44+
describe('error-preview', function(): void {
4545

46-
it('show error page', function() {
46+
it('show error page', function(): void {
4747

4848
Quit::disable();
4949

@@ -55,7 +55,7 @@
5555
];
5656

5757
\ob_start();
58-
$closure = function () {
58+
$closure = function (): void {
5959
$this->application->run();
6060
};
6161
expect($closure)->toThrow(new QuitException('Exit statement occurred', -1));
@@ -67,9 +67,9 @@
6767

6868
});
6969

70-
describe('error-preview error', function() {
70+
describe('error-preview error', function(): void {
7171

72-
it('show error page', function() {
72+
it('show error page', function(): void {
7373

7474
Quit::disable();
7575

@@ -81,7 +81,7 @@
8181
];
8282

8383
\ob_start();
84-
$closure = function () {
84+
$closure = function (): void {
8585
$this->application->run();
8686
};
8787
expect($closure)->toThrow(new QuitException('Exit statement occurred', -1));

spec/Integration/IntegrationViaErrorPreviewControllerForCannotConnecttoDBSpec.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
describe('Integration via ErrorPreviewController for Cannot connect to DB', function () {
99

10-
given('application', function () {
10+
given('application', function (): Application {
1111

1212
Console::overrideIsConsole(false);
1313

@@ -27,9 +27,9 @@
2727

2828
});
2929

30-
describe('/error-preview', function() {
30+
describe('/error-preview', function(): void {
3131

32-
it('show error page', function() {
32+
it('show error page', function(): void {
3333

3434
$request = $this->application->getRequest();
3535
$request->setMethod('GET');
@@ -48,9 +48,9 @@
4848

4949
});
5050

51-
describe('/error-preview/error', function() {
51+
describe('/error-preview/error', function(): void {
5252

53-
it('show error page', function() {
53+
it('show error page', function(): void {
5454

5555
$request = $this->application->getRequest();
5656
$request->setMethod('GET');

0 commit comments

Comments
 (0)