metaregistrar / php-epp-client

Object-oriented PHP EPP Client

Home Page:https://www.metaregistrar.com/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convert four variable assignments to the usage of combined operators

elfring opened this issue Β· comments

πŸ‘€ Some source code analysis tools can help to find opportunities for improving software components.
πŸ’­ I propose to increase the usage of combined operators accordingly.

diff --git a/Protocols/EPP/eppConnection.php b/Protocols/EPP/eppConnection.php
index 1c5fdf2..3076bac 100755
--- a/Protocols/EPP/eppConnection.php
+++ b/Protocols/EPP/eppConnection.php
@@ -555,7 +555,7 @@ class eppConnection {
                 while ($readLength > 0) {
 //                    $loops++;
                     if ($readbuffer = fread($this->connection, $readLength)) {
-                        $readLength = $readLength - strlen($readbuffer);
+                        $readLength -= strlen($readbuffer);
                         $read .= $readbuffer;
                         $time = time() + $this->timeout;
                     } elseif ($useSleep) {
@@ -588,7 +588,7 @@ class eppConnection {
                 $time = time() + $this->timeout;
                 if ($read = fread($this->connection, $length)) {
                     //$this->writeLog(print_R(socket_get_status($this->connection), true));
-                    $length = $length - strlen($read);
+                    $length -= strlen($read);
                     $content .= $read;
                     $time = time() + $this->timeout;
                 }
diff --git a/Tests/lvEppContactExtTest.php b/Tests/lvEppContactExtTest.php
index f1c3021..14c3839 100644
--- a/Tests/lvEppContactExtTest.php
+++ b/Tests/lvEppContactExtTest.php
@@ -198,7 +198,7 @@ class lvEppContactExtTest extends eppTestCase {
         }
 
         // success
-        $startpos = $startpos + strlen($start);
+        $startpos += strlen($start);
         $length = $endpos - $startpos;
         $text = substr($text, $startpos, $length);
 
diff --git a/Tests/lvEppDomainExtTest.php b/Tests/lvEppDomainExtTest.php
index f3516eb..436f11b 100644
--- a/Tests/lvEppDomainExtTest.php
+++ b/Tests/lvEppDomainExtTest.php
@@ -196,7 +196,7 @@ class lvEppDomainExtTest extends eppTestCase {
         }
 
         // success
-        $startpos = $startpos + strlen($start);
+        $startpos += strlen($start);
         $length = $endpos - $startpos;
         $text = substr($text, $startpos, $length);
 

πŸ’­ I would appreciate a more constructive feedback for the shown change possibility.

Well, from a programming perspective there is no difference between $c = $c +1 and $c += 1;
The resulting execution code and performance will be exactly the same.
It is just a matter of taste. Some will like the first, some will like the second. Everyone has their reasons.

The resulting execution code and performance will be exactly the same.

πŸ’­ I suggest to reconsider this development view.
πŸ‘€ I got the impression that the usage of combined operators for in-place modifications can influence the software run time characteristics in desirable directions.