Skip to content

Commit e908d68

Browse files
committed
apply php 7.4 rector set list
1 parent 85454fb commit e908d68

File tree

14 files changed

+339
-386
lines changed

14 files changed

+339
-386
lines changed

rector.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
use Rector\Core\Configuration\Option;
44
use Rector\Core\ValueObject\PhpVersion;
5+
use Rector\Php74\Rector\Property\TypedPropertyRector;
56
use Rector\Set\ValueObject\SetList;
67
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
78

89
return static function (ContainerConfigurator $containerConfigurator): void {
10+
$containerConfigurator->import(SetList::PHP_74);
911
$containerConfigurator->import(SetList::PHP_80);
1012

1113
$parameters = $containerConfigurator->parameters();
@@ -14,4 +16,11 @@
1416
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
1517
$parameters->set(Option::ENABLE_CACHE, true);
1618
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80);
19+
20+
$parameters->set(Option::SKIP, [
21+
TypedPropertyRector::class => [
22+
__DIR__ . '/src/Listener/Mvc.php',
23+
__DIR__ . '/src/Middleware/Mezzio.php',
24+
],
25+
]);
1726
};

spec/Handler/LoggingFactorySpec.php

Lines changed: 63 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -15,92 +15,88 @@
1515

1616
describe('LoggingFactorySpec', function () {
1717

18-
given('factory', function () {
19-
return new LoggingFactory();
20-
});
21-
22-
given('config', function () {
23-
return [
24-
'log' => [
25-
'ErrorHeroModuleLogger' => [
26-
'writers' => [
27-
28-
[
29-
'name' => 'db',
30-
'options' => [
31-
'db' => AdapterInterface::class,
32-
'table' => 'log',
33-
'column' => [
34-
'timestamp' => 'date',
35-
'priority' => 'type',
36-
'message' => 'event',
37-
'extra' => [
38-
'url' => 'url',
39-
'file' => 'file',
40-
'line' => 'line',
41-
'error_type' => 'error_type',
42-
'trace' => 'trace',
43-
'request_data' => 'request_data',
44-
],
18+
given('factory', fn() => new LoggingFactory());
19+
20+
given('config', fn() => [
21+
'log' => [
22+
'ErrorHeroModuleLogger' => [
23+
'writers' => [
24+
25+
[
26+
'name' => 'db',
27+
'options' => [
28+
'db' => AdapterInterface::class,
29+
'table' => 'log',
30+
'column' => [
31+
'timestamp' => 'date',
32+
'priority' => 'type',
33+
'message' => 'event',
34+
'extra' => [
35+
'url' => 'url',
36+
'file' => 'file',
37+
'line' => 'line',
38+
'error_type' => 'error_type',
39+
'trace' => 'trace',
40+
'request_data' => 'request_data',
4541
],
4642
],
4743
],
48-
4944
],
45+
5046
],
5147
],
48+
],
5249

53-
'error-hero-module' => [
54-
'enable' => true,
55-
'display-settings' => [
50+
'error-hero-module' => [
51+
'enable' => true,
52+
'display-settings' => [
5653

57-
// excluded php errors
58-
'exclude-php-errors' => [
59-
\E_USER_DEPRECATED
60-
],
61-
62-
// show or not error
63-
'display_errors' => 0,
64-
65-
// if enable and display_errors = 0, the page will bring layout and view
66-
'template' => [
67-
'layout' => 'layout/layout',
68-
'view' => 'error-hero-module/error-default'
69-
],
54+
// excluded php errors
55+
'exclude-php-errors' => [
56+
\E_USER_DEPRECATED
57+
],
7058

71-
// if enable and display_errors = 0, the console will bring message
72-
'console' => [
73-
'message' => 'We have encountered a problem and we can not fulfill your request. An error report has been generated and sent to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience.',
74-
],
59+
// show or not error
60+
'display_errors' => 0,
7561

62+
// if enable and display_errors = 0, the page will bring layout and view
63+
'template' => [
64+
'layout' => 'layout/layout',
65+
'view' => 'error-hero-module/error-default'
7666
],
77-
'logging-settings' => [
78-
'same-error-log-time-range' => 86400,
67+
68+
// if enable and display_errors = 0, the console will bring message
69+
'console' => [
70+
'message' => 'We have encountered a problem and we can not fulfill your request. An error report has been generated and sent to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience.',
7971
],
80-
'email-notification-settings' => [
81-
// set to true to activate email notification on log error
82-
'enable' => false,
8372

84-
// Laminas\Mail\Message instance registered at service manager
85-
'mail-message' => 'MailMessageService',
73+
],
74+
'logging-settings' => [
75+
'same-error-log-time-range' => 86400,
76+
],
77+
'email-notification-settings' => [
78+
// set to true to activate email notification on log error
79+
'enable' => false,
80+
81+
// Laminas\Mail\Message instance registered at service manager
82+
'mail-message' => 'MailMessageService',
8683

87-
// Laminas\Mail\Transport\TransportInterface instance registered at service manager
88-
'mail-transport' => 'MailTransportService',
84+
// Laminas\Mail\Transport\TransportInterface instance registered at service manager
85+
'mail-transport' => 'MailTransportService',
8986

90-
// email sender
91-
'email-from' => 'Sender Name <[email protected]>',
87+
// email sender
88+
'email-from' => 'Sender Name <[email protected]>',
9289

93-
// to include or not $_FILES on send mail
94-
'include-files-to-attachments' => true,
90+
// to include or not $_FILES on send mail
91+
'include-files-to-attachments' => true,
9592

96-
'email-to-send' => [
97-
98-
99-
],
93+
'email-to-send' => [
94+
95+
10096
],
10197
],
102-
];
103-
});
98+
],
99+
]);
104100

105101
describe('__invoke()', function () {
106102

spec/Handler/LoggingSpec.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,13 @@
105105
$this->logger->addWriter($this->dbWriter);
106106
});
107107

108-
given('logging', function () {
109-
return new Logging(
110-
$this->logger,
111-
$this->errorHeroModuleLocalConfig,
112-
$this->logWritersConfig,
113-
null,
114-
null
115-
);
116-
});
108+
given('logging', fn() => new Logging(
109+
$this->logger,
110+
$this->errorHeroModuleLocalConfig,
111+
$this->logWritersConfig,
112+
null,
113+
null
114+
));
117115

118116
describe('->handleErrorException()', function () {
119117

spec/Handler/Writer/Checker/DbSpec.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@
5050
];
5151
});
5252

53-
given('writerHandler', function () {
54-
return new Db(
55-
$this->dbWriter,
56-
$this->configLoggingSettings,
57-
$this->logWritersConfig
58-
);
59-
});
53+
given('writerHandler', fn() => new Db(
54+
$this->dbWriter,
55+
$this->configLoggingSettings,
56+
$this->logWritersConfig
57+
));
6058

6159
describe('__construct', function () {
6260

spec/Listener/MvcFactorySpec.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
describe('MvcFactory', function () {
1313

14-
given('factory', function () {
15-
return new MvcFactory();
16-
});
14+
given('factory', fn() => new MvcFactory());
1715

1816
describe('__invoke()', function () {
1917

spec/Listener/MvcSpec.php

Lines changed: 47 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -25,73 +25,65 @@
2525

2626
describe('Mvc', function () {
2727

28-
given('logging', function () {
29-
return Double::instance([
30-
'extends' => Logging::class,
31-
'methods' => '__construct'
32-
]);
33-
});
34-
35-
given('renderer', function () {
36-
return Double::instance(['extends' => PhpRenderer::class, 'methods' => '__construct']);
37-
});
28+
given('logging', fn() => Double::instance([
29+
'extends' => Logging::class,
30+
'methods' => '__construct'
31+
]));
3832

39-
given('config', function () {
40-
return [
41-
'enable' => true,
42-
'display-settings' => [
33+
given('renderer', fn() => Double::instance(['extends' => PhpRenderer::class, 'methods' => '__construct']));
4334

44-
// excluded php errors
45-
'exclude-php-errors' => [
46-
\E_USER_DEPRECATED
47-
],
35+
given('config', fn() => [
36+
'enable' => true,
37+
'display-settings' => [
4838

49-
// show or not error
50-
'display_errors' => 0,
39+
// excluded php errors
40+
'exclude-php-errors' => [
41+
\E_USER_DEPRECATED
42+
],
5143

52-
// if enable and display_errors = 0, the page will bring layout and view
53-
'template' => [
54-
'layout' => 'layout/layout',
55-
'view' => 'error-hero-module/error-default'
56-
],
57-
58-
// if enable and display_errors = 0, the console will bring message
59-
'console' => [
60-
'message' => 'We have encountered a problem and we can not fulfill your request. An error report has been generated and sent to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience.',
61-
],
44+
// show or not error
45+
'display_errors' => 0,
6246

47+
// if enable and display_errors = 0, the page will bring layout and view
48+
'template' => [
49+
'layout' => 'layout/layout',
50+
'view' => 'error-hero-module/error-default'
6351
],
64-
'logging-settings' => [
65-
'same-error-log-time-range' => 86400,
52+
53+
// if enable and display_errors = 0, the console will bring message
54+
'console' => [
55+
'message' => 'We have encountered a problem and we can not fulfill your request. An error report has been generated and sent to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience.',
6656
],
67-
'email-notification-settings' => [
68-
// set to true to activate email notification on log error
69-
'enable' => false,
7057

71-
// Laminas\Mail\Message instance registered at service manager
72-
'mail-message' => 'YourMailMessageService',
58+
],
59+
'logging-settings' => [
60+
'same-error-log-time-range' => 86400,
61+
],
62+
'email-notification-settings' => [
63+
// set to true to activate email notification on log error
64+
'enable' => false,
7365

74-
// Laminas\Mail\Transport\TransportInterface instance registered at service manager
75-
'mail-transport' => 'YourMailTransportService',
66+
// Laminas\Mail\Message instance registered at service manager
67+
'mail-message' => 'YourMailMessageService',
7668

77-
// email sender
78-
'email-from' => 'Sender Name <[email protected]>',
69+
// Laminas\Mail\Transport\TransportInterface instance registered at service manager
70+
'mail-transport' => 'YourMailTransportService',
7971

80-
'email-to-send' => [
81-
82-
83-
],
72+
// email sender
73+
'email-from' => 'Sender Name <[email protected]>',
74+
75+
'email-to-send' => [
76+
77+
8478
],
85-
];
86-
});
79+
],
80+
]);
8781

88-
given('listener', function () {
89-
return new Mvc(
90-
$this->config,
91-
$this->logging,
92-
$this->renderer
93-
);
94-
});
82+
given('listener', fn() => new Mvc(
83+
$this->config,
84+
$this->logging,
85+
$this->renderer
86+
));
9587

9688
describe('->attach()', function () {
9789

@@ -417,9 +409,7 @@
417409
allow('property_exists')->toBeCalled()->with($listener, 'request')->andReturn(false);
418410
allow('property_exists')->toBeCalled()->with($listener, 'mvcEvent')->andReturn(true);
419411

420-
$mvcEvent = & Closure::bind(function & ($listener) {
421-
return $listener->mvcEvent;
422-
}, null, $listener)($listener);
412+
$mvcEvent = & Closure::bind(fn&($listener) => $listener->mvcEvent, null, $listener)($listener);
423413
$mvcEvent = Double::instance(['extends' => MvcEvent::class, 'methods' => '__construct']);
424414

425415
$request = new Request();

0 commit comments

Comments
 (0)