Completed
Push — master ( 527733...42d287 )
by zyt
11s
created
src/Validator.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
             return false;
230 230
         }
231 231
 
232
-        $test     = 'catch-all-test-' . time();
233
-        $accepted = $this->rcpt($test . '@' . $domain);
232
+        $test     = 'catch-all-test-'.time();
233
+        $accepted = $this->rcpt($test.'@'.$domain);
234 234
         if ($accepted) {
235 235
             // Success on a non-existing address is a "catch-all"
236 236
             $this->domains_info[$domain]['catchall'] = true;
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         // Log when we get disconnected while trying catchall detection
241 241
         $this->noop();
242 242
         if (!$this->connected()) {
243
-            $this->debug('Disconnected after trying a non-existing recipient on ' . $domain);
243
+            $this->debug('Disconnected after trying a non-existing recipient on '.$domain);
244 244
         }
245 245
 
246 246
         /**
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
                 }
293 293
             } catch (NoConnectionException $e) {
294 294
                 // Unable to connect to host, so these addresses are invalid?
295
-                $this->debug('Unable to connect. Exception caught: ' . $e->getMessage());
295
+                $this->debug('Unable to connect. Exception caught: '.$e->getMessage());
296 296
                 //$this->setDomainResults($users, $domain, $this->no_conn_is_valid);
297 297
             }
298 298
         }
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
         foreach ($this->domains as $domain => $users) {
335 335
             $mxs = $this->buildMxs($domain);
336 336
 
337
-            $this->debug('MX records (' . $domain . '): ' . print_r($mxs, true));
337
+            $this->debug('MX records ('.$domain.'): '.print_r($mxs, true));
338 338
             $this->domains_info[$domain]          = [];
339 339
             $this->domains_info[$domain]['users'] = $users;
340 340
             $this->domains_info[$domain]['mxs']   = $mxs;
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
                 // Say helo, and continue if we can talk
355 355
                 if ($this->helo()) {
356 356
                     // try issuing MAIL FROM
357
-                    if (!$this->mail($this->from_user . '@' . $this->from_domain)) {
357
+                    if (!$this->mail($this->from_user.'@'.$this->from_domain)) {
358 358
                         // MAIL FROM not accepted, we can't talk
359 359
                         $this->setDomainResults($users, $domain, $this->no_comm_is_valid);
360 360
                     }
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
                             $this->noop();
386 386
                             // RCPT for each user
387 387
                             foreach ($users as $user) {
388
-                                $address                 = $user . '@' . $domain;
388
+                                $address                 = $user.'@'.$domain;
389 389
                                 $this->results[$address] = $this->rcpt($address);
390 390
                                 $this->noop();
391 391
                             }
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
     private function setDomainResults(array $users, $domain, $val)
445 445
     {
446 446
         foreach ($users as $user) {
447
-            $this->results[$user . '@' . $domain] = $val;
447
+            $this->results[$user.'@'.$domain] = $val;
448 448
         }
449 449
     }
450 450
 
@@ -470,13 +470,13 @@  discard block
 block discarded – undo
470 470
      */
471 471
     protected function connect($host)
472 472
     {
473
-        $remote_socket = $host . ':' . $this->connect_port;
473
+        $remote_socket = $host.':'.$this->connect_port;
474 474
         $errnum        = 0;
475 475
         $errstr        = '';
476 476
         $this->host    = $remote_socket;
477 477
 
478 478
         // Open connection
479
-        $this->debug('Connecting to ' . $this->host);
479
+        $this->debug('Connecting to '.$this->host);
480 480
         // @codingStandardsIgnoreLine
481 481
         $this->socket = /** @scrutinizer ignore-unhandled */ @stream_socket_client(
482 482
             $this->host,
@@ -489,8 +489,8 @@  discard block
 block discarded – undo
489 489
 
490 490
         // Check and throw if not connected
491 491
         if (!$this->connected()) {
492
-            $this->debug('Connect failed: ' . $errstr . ', error number: ' . $errnum . ', host: ' . $this->host);
493
-            throw new NoConnectionException('Cannot open a connection to remote host (' . $this->host . ')');
492
+            $this->debug('Connect failed: '.$errstr.', error number: '.$errnum.', host: '.$this->host);
493
+            throw new NoConnectionException('Cannot open a connection to remote host ('.$this->host.')');
494 494
         }
495 495
 
496 496
         $result = stream_set_timeout($this->socket, $this->connect_timeout);
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
             throw new NoTimeoutException('Cannot set timeout');
499 499
         }
500 500
 
501
-        $this->debug('Connected to ' . $this->host . ' successfully');
501
+        $this->debug('Connected to '.$this->host.' successfully');
502 502
     }
503 503
 
504 504
     /**
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
         }
516 516
 
517 517
         if ($this->connected()) {
518
-            $this->debug('Closing socket to ' . $this->host);
518
+            $this->debug('Closing socket to '.$this->host);
519 519
             fclose($this->socket);
520 520
         }
521 521
 
@@ -575,7 +575,7 @@  discard block
 block discarded – undo
575 575
         } catch (UnexpectedResponseException $e) {
576 576
             // Connected, but got an unexpected response, so disconnect
577 577
             $result = false;
578
-            $this->debug('Unexpected response after connecting: ' . $e->getMessage());
578
+            $this->debug('Unexpected response after connecting: '.$e->getMessage());
579 579
             $this->disconnect(false);
580 580
         }
581 581
 
@@ -591,11 +591,11 @@  discard block
 block discarded – undo
591 591
     {
592 592
         try {
593 593
             // Modern
594
-            $this->send('EHLO ' . $this->from_domain);
594
+            $this->send('EHLO '.$this->from_domain);
595 595
             $this->expect(self::SMTP_GENERIC_SUCCESS, $this->command_timeouts['ehlo']);
596 596
         } catch (UnexpectedResponseException $e) {
597 597
             // Legacy
598
-            $this->send('HELO ' . $this->from_domain);
598
+            $this->send('HELO '.$this->from_domain);
599 599
             $this->expect(self::SMTP_GENERIC_SUCCESS, $this->command_timeouts['helo']);
600 600
         }
601 601
     }
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
         }
617 617
 
618 618
         // Issue MAIL FROM, 5 minute timeout
619
-        $this->send('MAIL FROM:<' . $from . '>');
619
+        $this->send('MAIL FROM:<'.$from.'>');
620 620
 
621 621
         try {
622 622
             $this->expect(self::SMTP_GENERIC_SUCCESS, $this->command_timeouts['mail']);
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
             $result = false;
631 631
 
632 632
             // Got something unexpected in response to MAIL FROM
633
-            $this->debug("Unexpected response to MAIL FROM\n:" . $e->getMessage());
633
+            $this->debug("Unexpected response to MAIL FROM\n:".$e->getMessage());
634 634
 
635 635
             // Hotmail has been known to do this + was closing the connection
636 636
             // forcibly on their end, so we're killing the socket here too
@@ -667,17 +667,17 @@  discard block
 block discarded – undo
667 667
 
668 668
         // Issue RCPT TO, 5 minute timeout
669 669
         try {
670
-            $this->send('RCPT TO:<' . $to . '>');
670
+            $this->send('RCPT TO:<'.$to.'>');
671 671
             // Handle response
672 672
             try {
673 673
                 $this->expect($expected_codes, $this->command_timeouts['rcpt']);
674 674
                 $this->state['rcpt'] = true;
675 675
                 $valid               = true;
676 676
             } catch (UnexpectedResponseException $e) {
677
-                $this->debug('Unexpected response to RCPT TO: ' . $e->getMessage());
677
+                $this->debug('Unexpected response to RCPT TO: '.$e->getMessage());
678 678
             }
679 679
         } catch (Exception $e) {
680
-            $this->debug('Sending RCPT TO failed: ' . $e->getMessage());
680
+            $this->debug('Sending RCPT TO failed: '.$e->getMessage());
681 681
         }
682 682
 
683 683
         return $valid;
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
         if ($this->state['helo']) {
717 717
             $this->send('QUIT');
718 718
             $this->expect(
719
-                [self::SMTP_GENERIC_SUCCESS,self::SMTP_QUIT_SUCCESS],
719
+                [self::SMTP_GENERIC_SUCCESS, self::SMTP_QUIT_SUCCESS],
720 720
                 $this->command_timeouts['quit'],
721 721
                 true
722 722
             );
@@ -761,13 +761,13 @@  discard block
 block discarded – undo
761 761
         // Must be connected
762 762
         $this->throwIfNotConnected();
763 763
 
764
-        $this->debug('send>>>: ' . $cmd);
764
+        $this->debug('send>>>: '.$cmd);
765 765
         // Write the cmd to the connection stream
766
-        $result = fwrite($this->socket, $cmd . self::CRLF);
766
+        $result = fwrite($this->socket, $cmd.self::CRLF);
767 767
 
768 768
         // Did it work?
769 769
         if (false === $result) {
770
-            throw new SendFailedException('Send failed on: ' . $this->host);
770
+            throw new SendFailedException('Send failed on: '.$this->host);
771 771
         }
772 772
 
773 773
         return $result;
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 
797 797
         // Retrieve response
798 798
         $line = fgets($this->socket, 1024);
799
-        $this->debug('<<<recv: ' . $line);
799
+        $this->debug('<<<recv: '.$line);
800 800
 
801 801
         // Have we timed out?
802 802
         $info = stream_get_meta_data($this->socket);
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
              * No response in expect() probably means that the remote server
851 851
              * forcibly closed the connection so lets clean up on our end as well?
852 852
              */
853
-            $this->debug('No response in expect(): ' . $e->getMessage());
853
+            $this->debug('No response in expect(): '.$e->getMessage());
854 854
             $this->disconnect(false);
855 855
         }
856 856
 
@@ -954,9 +954,9 @@  discard block
 block discarded – undo
954 954
         $this->log($str);
955 955
         if ($this->debug) {
956 956
             if ('cli' !== PHP_SAPI) {
957
-                $str = '<br/><pre>' . htmlspecialchars($str) . '</pre>';
957
+                $str = '<br/><pre>'.htmlspecialchars($str).'</pre>';
958 958
             }
959
-            echo "\n" . $str;
959
+            echo "\n".$str;
960 960
         }
961 961
     }
962 962
 
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
     private function stamp($msg)
983 983
     {
984 984
         $date = \DateTime::createFromFormat('U.u', sprintf('%.f', microtime(true)))->format('Y-m-d\TH:i:s.uO');
985
-        $line = '[' . $date . '] ' . $msg;
985
+        $line = '['.$date.'] '.$msg;
986 986
 
987 987
         return $line;
988 988
     }
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
         if (\method_exists($this, $camelized)) {
1022 1022
             return \call_user_func_array([$this, $camelized], $args);
1023 1023
         } else {
1024
-            trigger_error('Fatal error: Call to undefined method ' . self::class . '::' . $name . '()', E_USER_ERROR);
1024
+            trigger_error('Fatal error: Call to undefined method '.self::class.'::'.$name.'()', E_USER_ERROR);
1025 1025
         }
1026 1026
     }
1027 1027
 
Please login to merge, or discard this patch.