@@ -71,46 +71,55 @@ public function __construct(
71
71
*/
72
72
public function validate (): void
73
73
{
74
- if (!empty ($ this ->host )) {
74
+ if (! empty ($ this ->host )) {
75
75
$ ip = gethostbyname ($ this ->host );
76
76
if (false === filter_var ($ ip , FILTER_VALIDATE_IP )) {
77
77
throw new ConfigException (ConfigException::IP_ERROR_MESSAGE , ConfigException::IP_ERROR_CODE );
78
78
}
79
79
}
80
- if (!empty ($ this ->port ) && false === filter_var (
81
- $ this ->port , FILTER_VALIDATE_INT , ['options ' => ['min_range ' => 0 ]]
82
- )) {
80
+ if (! empty ($ this ->port ) && false === filter_var (
81
+ $ this ->port ,
82
+ FILTER_VALIDATE_INT ,
83
+ ['options ' => ['min_range ' => 0 ]]
84
+ )) {
83
85
throw new ConfigException (ConfigException::PORT_ERROR_MESSAGE , ConfigException::PORT_ERROR_CODE );
84
86
}
85
- if (!empty ($ this ->gtid )) {
87
+ if (! empty ($ this ->gtid )) {
86
88
foreach (explode (', ' , $ this ->gtid ) as $ gtid ) {
87
- if (!(bool )preg_match (
88
- '/^([0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12})((?::[0-9-]+)+)$/ ' , $ gtid , $ matches
89
+ if (! (bool )preg_match (
90
+ '/^([0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12})((?::[0-9-]+)+)$/ ' ,
91
+ $ gtid ,
92
+ $ matches
89
93
)) {
90
94
throw new ConfigException (ConfigException::GTID_ERROR_MESSAGE , ConfigException::GTID_ERROR_CODE );
91
95
}
92
96
}
93
97
}
94
- if (!empty ($ this ->slaveId ) && false === filter_var (
95
- $ this ->slaveId , FILTER_VALIDATE_INT , ['options ' => ['min_range ' => 0 ]]
96
- )) {
98
+ if (! empty ($ this ->slaveId ) && false === filter_var (
99
+ $ this ->slaveId ,
100
+ FILTER_VALIDATE_INT ,
101
+ ['options ' => ['min_range ' => 0 ]]
102
+ )) {
97
103
throw new ConfigException (ConfigException::SLAVE_ID_ERROR_MESSAGE , ConfigException::SLAVE_ID_ERROR_CODE );
98
104
}
99
105
if (false === filter_var ($ this ->binLogPosition , FILTER_VALIDATE_INT , ['options ' => ['min_range ' => 0 ]])) {
100
106
throw new ConfigException (
101
- ConfigException::BIN_LOG_FILE_POSITION_ERROR_MESSAGE , ConfigException::BIN_LOG_FILE_POSITION_ERROR_CODE
107
+ ConfigException::BIN_LOG_FILE_POSITION_ERROR_MESSAGE ,
108
+ ConfigException::BIN_LOG_FILE_POSITION_ERROR_CODE
102
109
);
103
110
}
104
111
if (false === filter_var ($ this ->tableCacheSize , FILTER_VALIDATE_INT , ['options ' => ['min_range ' => 0 ]])) {
105
112
throw new ConfigException (
106
- ConfigException::TABLE_CACHE_SIZE_ERROR_MESSAGE , ConfigException::TABLE_CACHE_SIZE_ERROR_CODE
113
+ ConfigException::TABLE_CACHE_SIZE_ERROR_MESSAGE ,
114
+ ConfigException::TABLE_CACHE_SIZE_ERROR_CODE
107
115
);
108
116
}
109
117
if (0.0 !== $ this ->heartbeatPeriod && false === (
110
118
$ this ->heartbeatPeriod >= 0.001 && $ this ->heartbeatPeriod <= 4294967.0
111
119
)) {
112
120
throw new ConfigException (
113
- ConfigException::HEARTBEAT_PERIOD_ERROR_MESSAGE , ConfigException::HEARTBEAT_PERIOD_ERROR_CODE
121
+ ConfigException::HEARTBEAT_PERIOD_ERROR_MESSAGE ,
122
+ ConfigException::HEARTBEAT_PERIOD_ERROR_CODE
114
123
);
115
124
}
116
125
}
@@ -177,7 +186,7 @@ public function getTableCacheSize(): int
177
186
178
187
public function checkDataBasesOnly (string $ database ): bool
179
188
{
180
- return [] !== $ this ->getDatabasesOnly () && !self ::matchNames ($ database , $ this ->getDatabasesOnly ());
189
+ return [] !== $ this ->getDatabasesOnly () && ! self ::matchNames ($ database , $ this ->getDatabasesOnly ());
181
190
}
182
191
183
192
public function getDatabasesOnly (): array
@@ -187,7 +196,7 @@ public function getDatabasesOnly(): array
187
196
188
197
public function checkTablesOnly (string $ table ): bool
189
198
{
190
- return [] !== $ this ->getTablesOnly () && !self ::matchNames ($ table , $ this ->getTablesOnly ());
199
+ return [] !== $ this ->getTablesOnly () && ! self ::matchNames ($ table , $ this ->getTablesOnly ());
191
200
}
192
201
193
202
private static function matchNames (string $ subject , array $ names ): bool
@@ -208,7 +217,7 @@ public function getTablesOnly(): array
208
217
209
218
public function checkEvent (int $ type ): bool
210
219
{
211
- if ([] !== $ this ->getEventsOnly () && !in_array ($ type , $ this ->getEventsOnly (), true )) {
220
+ if ([] !== $ this ->getEventsOnly () && ! in_array ($ type , $ this ->getEventsOnly (), true )) {
212
221
return false ;
213
222
}
214
223
@@ -239,8 +248,9 @@ public function getRetry(): int
239
248
return $ this ->retry ;
240
249
}
241
250
251
+ #[\ReturnTypeWillChange]
242
252
public function jsonSerialize ()
243
253
{
244
254
return get_object_vars ($ this );
245
255
}
246
- }
256
+ }
0 commit comments