@@ -25,10 +25,6 @@ class BinLogSocketConnect
2525 * @var RepositoryInterface
2626 */
2727 private $ repository ;
28- /**
29- * @var Config
30- */
31- private $ config ;
3228 /**
3329 * http://dev.mysql.com/doc/internals/en/auth-phase-fast-path.html 00 FE
3430 * @var array
@@ -45,23 +41,20 @@ class BinLogSocketConnect
4541 private $ binaryDataMaxLength = 16777215 ;
4642
4743 /**
48- * @param Config $config
4944 * @param RepositoryInterface $repository
5045 * @param SocketInterface $socket
5146 * @throws BinLogException
5247 * @throws \MySQLReplication\Gtid\GtidException
5348 * @throws \MySQLReplication\Socket\SocketException
5449 */
5550 public function __construct (
56- Config $ config ,
5751 RepositoryInterface $ repository ,
5852 SocketInterface $ socket
5953 ) {
6054 $ this ->repository = $ repository ;
61- $ this ->config = $ config ;
6255 $ this ->socket = $ socket ;
6356
64- $ this ->socket ->connectToStream ($ this -> config -> getHost (), $ this -> config -> getPort ());
57+ $ this ->socket ->connectToStream (Config:: getHost (), Config:: getPort ());
6558 BinLogServerInfo::parsePackage ($ this ->getResponse (false ), $ this ->repository ->getVersion ());
6659 $ this ->authenticate ();
6760 $ this ->getBinlogStream ();
@@ -129,9 +122,9 @@ private function authenticate()
129122 for ($ i = 0 ; $ i < 23 ; $ i ++) {
130123 $ data .= chr (0 );
131124 }
132- $ result = sha1 ($ this -> config -> getPassword (), true ) ^ sha1 (BinLogServerInfo::getSalt () . sha1 (sha1 ($ this -> config -> getPassword (), true ), true ), true );
125+ $ result = sha1 (Config:: getPassword (), true ) ^ sha1 (BinLogServerInfo::getSalt () . sha1 (sha1 (Config:: getPassword (), true ), true ), true );
133126
134- $ data = $ data . $ this -> config -> getUser () . chr (0 ) . chr (strlen ($ result )) . $ result ;
127+ $ data = $ data . Config:: getUser () . chr (0 ) . chr (strlen ($ result )) . $ result ;
135128 $ str = pack ('L ' , strlen ($ data ));
136129 $ s = $ str [0 ] . $ str [1 ] . $ str [2 ];
137130 $ data = $ s . chr (1 ) . $ data ;
@@ -154,7 +147,7 @@ private function getBinlogStream()
154147
155148 $ this ->registerSlave ();
156149
157- if ('' !== $ this -> config -> getGtid ()) {
150+ if ('' !== Config:: getGtid ()) {
158151 $ this ->setBinLogDumpGtid ();
159152 } else {
160153 $ this ->setBinLogDump ();
@@ -181,19 +174,19 @@ private function registerSlave()
181174 {
182175 $ host = gethostname ();
183176 $ hostLength = strlen ($ host );
184- $ userLength = strlen ($ this -> config -> getUser ());
185- $ passLength = strlen ($ this -> config -> getPassword ());
177+ $ userLength = strlen (Config:: getUser ());
178+ $ passLength = strlen (Config:: getPassword ());
186179
187180 $ data = pack ('l ' , 18 + $ hostLength + $ userLength + $ passLength );
188181 $ data .= chr (ConstCommand::COM_REGISTER_SLAVE );
189- $ data .= pack ('V ' , $ this -> config -> getSlaveId ());
182+ $ data .= pack ('V ' , Config:: getSlaveId ());
190183 $ data .= pack ('C ' , $ hostLength );
191184 $ data .= $ host ;
192185 $ data .= pack ('C ' , $ userLength );
193- $ data .= $ this -> config -> getUser ();
186+ $ data .= Config:: getUser ();
194187 $ data .= pack ('C ' , $ passLength );
195- $ data .= $ this -> config -> getPassword ();
196- $ data .= pack ('v ' , $ this -> config -> getPort ());
188+ $ data .= Config:: getPassword ();
189+ $ data .= pack ('v ' , Config:: getPort ());
197190 $ data .= pack ('V ' , 0 );
198191 $ data .= pack ('V ' , 0 );
199192
@@ -209,11 +202,11 @@ private function registerSlave()
209202 */
210203 private function setBinLogDumpGtid ()
211204 {
212- $ collection = GtidFactory::makeCollectionFromString ($ this -> config -> getGtid ());
205+ $ collection = GtidFactory::makeCollectionFromString (Config:: getGtid ());
213206
214207 $ data = pack ('l ' , 26 + $ collection ->getEncodedLength ()) . chr (ConstCommand::COM_BINLOG_DUMP_GTID );
215208 $ data .= pack ('S ' , 0 );
216- $ data .= pack ('I ' , $ this -> config -> getSlaveId ());
209+ $ data .= pack ('I ' , Config:: getSlaveId ());
217210 $ data .= pack ('I ' , 3 );
218211 $ data .= chr (0 );
219212 $ data .= chr (0 );
@@ -233,15 +226,15 @@ private function setBinLogDumpGtid()
233226 */
234227 private function setBinLogDump ()
235228 {
236- if ('' !== $ this -> config -> getMariaDbGtid ()) {
229+ if ('' !== Config:: getMariaDbGtid ()) {
237230 $ this ->execute ('SET @mariadb_slave_capability = 4 ' );
238- $ this ->execute ('SET @slave_connect_state = \'' . $ this -> config -> getMariaDbGtid () . '\'' );
231+ $ this ->execute ('SET @slave_connect_state = \'' . Config:: getMariaDbGtid () . '\'' );
239232 $ this ->execute ('SET @slave_gtid_strict_mode = 0 ' );
240233 $ this ->execute ('SET @slave_gtid_ignore_duplicates = 0 ' );
241234 }
242235
243- $ binFilePos = $ this -> config -> getBinLogPosition ();
244- $ binFileName = $ this -> config -> getBinLogFileName ();
236+ $ binFilePos = Config:: getBinLogPosition ();
237+ $ binFileName = Config:: getBinLogFileName ();
245238 if (0 === $ binFilePos || '' === $ binFileName ) {
246239 $ master = $ this ->repository ->getMasterStatus ();
247240 $ binFilePos = $ master ['Position ' ];
@@ -251,7 +244,7 @@ private function setBinLogDump()
251244 $ data = pack ('i ' , strlen ($ binFileName ) + 11 ) . chr (ConstCommand::COM_BINLOG_DUMP );
252245 $ data .= pack ('I ' , $ binFilePos );
253246 $ data .= pack ('v ' , 0 );
254- $ data .= pack ('I ' , $ this -> config -> getSlaveId ());
247+ $ data .= pack ('I ' , Config:: getSlaveId ());
255248 $ data .= $ binFileName ;
256249
257250 $ this ->socket ->writeToSocket ($ data );
0 commit comments