Passed
Branch master (c73d10)
by Stefan
02:51 queued 55s
created
SKien/PNServer/PNDataProviderSQLite.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             if (!file_exists($strDBName)) {
67 67
                 $strDir = pathinfo($strDBName, PATHINFO_DIRNAME) == '' ?  __DIR__ : pathinfo($strDBName, PATHINFO_DIRNAME);
68 68
                 if (!is_writable($strDir)) {
69
-                   $this->strLastError .= ' (no rights to write on directory ' . $strDir . ')';
69
+                    $this->strLastError .= ' (no rights to write on directory ' . $strDir . ')';
70 70
                 }
71 71
             }
72 72
         }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
             // - can only occur during development using invalid SQL-statement for creation!
88 88
             // @codeCoverageIgnoreStart
89 89
             if (strlen($this->strLastError) == 0) {
90
-               $this->strLastError = 'database table ' . $this->strTableName . ' not exist!';
90
+                $this->strLastError = 'database table ' . $this->strTableName . ' not exist!';
91 91
             }
92 92
             // @codeCoverageIgnoreEnd
93 93
         }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 namespace SKien\PNServer;
5 5
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     /** @var string name of the DB file          */
28 28
     protected   string $strDBName; 
29 29
     /** @var \SQLite3 internal SqLite DB         */
30
-    protected   ?\SQLite3 $db = null;
30
+    protected ?\SQLite3 $db = null;
31 31
     /** @var \SQLite3Result|bool result of DB queries (no type hint - \SQLite3::query() returns \SQLite3Result|bool) */
32 32
     protected   $dbres = false;
33 33
     /** @var array|bool last fetched row or false (no type hint - \SQLite3Result::fetchArray() returns array|bool)    */
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
     /** @var string last error                   */
36 36
     protected   string $strLastError;
37 37
     /** @var bool does table exist               */
38
-    protected   ?bool $bTableExist = null;
38
+    protected ?bool $bTableExist = null;
39 39
     
40 40
     /**
41 41
      * @param string $strDir        directory -  if null, current working directory assumed
42 42
      * @param string $strDBName     name of DB file - if null, file 'pnsub.sqlite' is used and created if not exist
43 43
      * @param string $strTableName  tablename for the subscriptions - if null, self::TABLE_NAME is used and created if not exist
44 44
      */
45
-    public function __construct(?string $strDir=null, ?string $strDBName=null, ?string $strTableName=null) 
45
+    public function __construct(?string $strDir = null, ?string $strDBName = null, ?string $strTableName = null) 
46 46
     {
47 47
         $this->strTableName = isset($strTableName) ? $strTableName : self::TABLE_NAME;
48 48
         $this->strDBName = isset($strDBName) ? $strDBName : 'pnsub.sqlite';
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             $this->db = null;
65 65
             $this->strLastError = $e->getMessage();
66 66
             if (!file_exists($strDBName)) {
67
-                $strDir = pathinfo($strDBName, PATHINFO_DIRNAME) == '' ?  __DIR__ : pathinfo($strDBName, PATHINFO_DIRNAME);
67
+                $strDir = pathinfo($strDBName, PATHINFO_DIRNAME) == '' ? __DIR__ : pathinfo($strDBName, PATHINFO_DIRNAME);
68 68
                 if (!is_writable($strDir)) {
69 69
                    $this->strLastError .= ' (no rights to write on directory ' . $strDir . ')';
70 70
                 }
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
         if ($this->isConnected()) {
105 105
             $oSubscription = json_decode($strJSON, true);
106 106
             if ($oSubscription) {
107
-                $iExpires = isset($oSubscription['expirationTime']) ? bcdiv((string)$oSubscription['expirationTime'], '1000') : 0;
107
+                $iExpires = isset($oSubscription['expirationTime']) ? bcdiv((string) $oSubscription['expirationTime'], '1000') : 0;
108 108
                 $strUserAgent = isset($oSubscription['userAgent']) ? $oSubscription['userAgent'] : 'unknown UserAgent';
109 109
                 
110 110
                 // insert or update - relevant is the endpoint as unique index 
111 111
                 $strSQL  = "REPLACE INTO " . $this->strTableName . " (";
112
-                $strSQL .=       self::COL_ENDPOINT;
112
+                $strSQL .= self::COL_ENDPOINT;
113 113
                 $strSQL .= "," . self::COL_EXPIRES;
114 114
                 $strSQL .= "," . self::COL_SUBSCRIPTION;
115 115
                 $strSQL .= "," . self::COL_USERAGENT;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
      * {@inheritDoc}
154 154
      * @see PNDataProvider::init()
155 155
      */
156
-    public function init(bool $bAutoRemove=true) : bool 
156
+    public function init(bool $bAutoRemove = true) : bool 
157 157
     {
158 158
         $bSucceeded = false;
159 159
         $this->dbres = false;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
                 $this->setSQLiteError($bSucceeded);
182 182
             }
183 183
         }
184
-        return (bool)$bSucceeded;
184
+        return (bool) $bSucceeded;
185 185
     }
186 186
 
187 187
     /**
Please login to merge, or discard this patch.
SKien/PNServer/PNDataProviderMySQL.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 namespace SKien\PNServer;
5 5
 
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
     /** @var \mysqli_result|bool result of DB queries  (No type hint, as \mysqli_result or bool is possible type) */
38 38
     protected   $dbres = false;
39 39
     /** @var array last fetched row or null      */
40
-    protected   ?array $row = null;
40
+    protected ?array $row = null;
41 41
     /** @var string last error                   */
42 42
     protected   string $strLastError = '';
43 43
     /** @var bool does table exist               */
44
-    protected   ?bool $bTableExist = null;
44
+    protected ?bool $bTableExist = null;
45 45
     
46 46
     /**
47 47
      * @param string $strDBHost     DB Host
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      * @param string $strDBName     DB Name
51 51
      * @param string $strTableName  tablename for the subscriptions - if null, self::TABLE_NAME is used and created if not exist
52 52
      */
53
-    public function __construct(string $strDBHost, string $strDBUser, string $strDBPwd, string $strDBName, ?string $strTableName=null) 
53
+    public function __construct(string $strDBHost, string $strDBUser, string $strDBPwd, string $strDBName, ?string $strTableName = null) 
54 54
     {
55 55
         $this->strDBHost = $strDBHost; 
56 56
         $this->strDBUser = $strDBUser; 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                 $strUserAgent = isset($oSubscription['userAgent']) ? $oSubscription['userAgent'] : 'unknown UserAgent';
106 106
                                 
107 107
                 $strSQL  = "INSERT INTO " . $this->strTableName . " (";
108
-                $strSQL .=       self::COL_ENDPOINT;
108
+                $strSQL .= self::COL_ENDPOINT;
109 109
                 $strSQL .= "," . self::COL_EXPIRES;
110 110
                 $strSQL .= "," . self::COL_SUBSCRIPTION;
111 111
                 $strSQL .= "," . self::COL_USERAGENT;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
                 $strSQL .= ",'" . $strJSON . "'";
116 116
                 $strSQL .= ",'" . $strUserAgent . "'";
117 117
                 $strSQL .= ") ";
118
-                $strSQL .= "ON DUPLICATE KEY UPDATE ";  // in case of UPDATE UA couldn't have been changed and endpoint is the UNIQUE key!
118
+                $strSQL .= "ON DUPLICATE KEY UPDATE "; // in case of UPDATE UA couldn't have been changed and endpoint is the UNIQUE key!
119 119
                 $strSQL .= " expires = " . $tsExpires;
120 120
                 $strSQL .= ",subscription = '" . $strJSON . "'";
121 121
                 $strSQL .= ";";
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
      * {@inheritDoc}
156 156
      * @see PNDataProvider::init()
157 157
      */
158
-    public function init(bool $bAutoRemove=true) : bool 
158
+    public function init(bool $bAutoRemove = true) : bool 
159 159
     {
160 160
         $bSucceeded = false;
161 161
         $this->dbres = false;
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             }
182 182
             if ($bSucceeded) {
183 183
                 $strSQL  = "SELECT ";
184
-                $strSQL .=       self::COL_ID;
184
+                $strSQL .= self::COL_ID;
185 185
                 $strSQL .= "," . self::COL_ENDPOINT;
186 186
                 $strSQL .= ",UNIX_TIMESTAMP(" . self::COL_EXPIRES . ") AS " . self::COL_EXPIRES;
187 187
                 $strSQL .= "," . self::COL_SUBSCRIPTION;
Please login to merge, or discard this patch.
SKien/Test/PNServer/PNEncryptionTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 namespace SKien\Test\PNServer;
5 5
 
Please login to merge, or discard this patch.
SKien/Test/PNServer/PNDataProviderMySQLTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 namespace SKien\Test\PNServer;
5 5
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     public static function setUpBeforeClass() : void
21 21
     {
22 22
         $db = mysqli_connect($GLOBALS['MYSQL_HOST'], $GLOBALS['MYSQL_USER'], $GLOBALS['MYSQL_PASSWD'], $GLOBALS['MYSQL_DBNAME']);
23
-        if(!$db) {
23
+        if (!$db) {
24 24
             fwrite(STDOUT, 'MySQL: Connect Error ' . mysqli_connect_errno() . PHP_EOL);
25 25
         }
26 26
         $db->query("DROP TABLE IF EXISTS " . PNDataProviderMySQL::TABLE_NAME);
Please login to merge, or discard this patch.
SKien/Test/PNServer/PNServerTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 namespace SKien\Test\PNServer;
5 5
 
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
         $log = $srv->getLog();
148 148
         $this->assertIsArray($log);
149 149
         $this->assertEquals(5, count($log));
150
-        $aResponse = [-1, 201, 404, 410, 0];    // Encryption error, OK, Not Found, Gone. inv. Endpoint
150
+        $aResponse = [-1, 201, 404, 410, 0]; // Encryption error, OK, Not Found, Gone. inv. Endpoint
151 151
         $i = 0;
152
-        foreach ($log as $strEndpoint => $aMsg ) {
152
+        foreach ($log as $strEndpoint => $aMsg) {
153 153
             $this->assertNotEmpty($strEndpoint);
154 154
             $this->assertEquals($aResponse[$i++], $aMsg['curl_response_code']);
155 155
             // fwrite(STDOUT, "\n" . $aMsg['msg'] . "\n");
Please login to merge, or discard this patch.
SKien/Test/PNServer/TestHelperTrait.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 namespace SKien\Test\PNServer;
5 5
 
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
         
17 17
     protected function loadSubscription(string $strFilename) : string
18 18
     {
19
-        return file_get_contents( __DIR__ . DIRECTORY_SEPARATOR . 'testdata' . DIRECTORY_SEPARATOR . $strFilename);
19
+        return file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'testdata' . DIRECTORY_SEPARATOR . $strFilename);
20 20
     }
21 21
     
22 22
     protected static function getTempDataDir() : string
Please login to merge, or discard this patch.
SKien/Test/PNServer/UtilsMathTest.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 namespace SKien\Test\PNServer;
5 5
 
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
     
55 55
     public function test_mod() : void
56 56
     {
57
-        $this->assertEquals((int)Math::mod(gmp_init(7), gmp_init(2)), 1);
57
+        $this->assertEquals((int) Math::mod(gmp_init(7), gmp_init(2)), 1);
58 58
     }
59 59
     
60 60
     public function test_add() : void
61 61
     {
62
-        $this->assertEquals((int)Math::add(gmp_init(2), gmp_init(3)), 5);
62
+        $this->assertEquals((int) Math::add(gmp_init(2), gmp_init(3)), 5);
63 63
     }
64 64
     
65 65
     public function test_sub() : void
66 66
     {
67
-        $this->assertEquals((int)Math::sub(gmp_init(2), gmp_init(3)), -1);
67
+        $this->assertEquals((int) Math::sub(gmp_init(2), gmp_init(3)), -1);
68 68
     }
69 69
     
70 70
     /**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function test_mul(\GMP $a, \GMP $b, int $expected) : void
74 74
     {
75
-        $this->assertEquals($expected, (int)Math::mul($a, $b));
75
+        $this->assertEquals($expected, (int) Math::mul($a, $b));
76 76
     }
77 77
     
78 78
     public function mulProvider() : array
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function test_pow(\GMP $a, int $b, int $expected) : void
92 92
     {
93
-        $this->assertEquals($expected, (int)Math::pow($a, $b));
93
+        $this->assertEquals($expected, (int) Math::pow($a, $b));
94 94
     }
95 95
     
96 96
     public function powProvider() : array
@@ -105,17 +105,17 @@  discard block
 block discarded – undo
105 105
     
106 106
     public function test_bitwiseAnd() : void
107 107
     {
108
-        $this->assertEquals((int)Math::bitwiseAnd(gmp_init('110011', 2), gmp_init('011110', 2)), (int)gmp_init('010010', 2));
108
+        $this->assertEquals((int) Math::bitwiseAnd(gmp_init('110011', 2), gmp_init('011110', 2)), (int) gmp_init('010010', 2));
109 109
     }
110 110
     
111 111
     public function test_bitwiseXor() : void
112 112
     {
113
-        $this->assertEquals((int)Math::bitwiseXor(gmp_init('110011', 2), gmp_init('011110', 2)), (int)gmp_init('101101', 2));
113
+        $this->assertEquals((int) Math::bitwiseXor(gmp_init('110011', 2), gmp_init('011110', 2)), (int) gmp_init('101101', 2));
114 114
     }
115 115
     
116 116
     public function test_rightShift() : void
117 117
     {
118
-        $this->assertEquals((int)Math::rightShift(gmp_init('110011', 2), 3), (int)gmp_init('110', 2));
118
+        $this->assertEquals((int) Math::rightShift(gmp_init('110011', 2), 3), (int) gmp_init('110', 2));
119 119
     }
120 120
     
121 121
     public function test_toString() : void
@@ -130,24 +130,24 @@  discard block
 block discarded – undo
130 130
     
131 131
     public function test_inverseMod() : void
132 132
     {
133
-        $this->assertEquals(9, (int)Math::inverseMod(gmp_init(5), gmp_init(11)));
134
-        $this->assertEquals(11, (int)Math::inverseMod(gmp_init(-4), gmp_init(15)));
133
+        $this->assertEquals(9, (int) Math::inverseMod(gmp_init(5), gmp_init(11)));
134
+        $this->assertEquals(11, (int) Math::inverseMod(gmp_init(-4), gmp_init(15)));
135 135
         $this->assertFalse(Math::inverseMod(gmp_init(5), gmp_init(10)));
136 136
     }
137 137
     
138 138
     public function test_modSub() : void
139 139
     {
140
-        $this->assertEquals((int)Math::modSub(gmp_init(12), gmp_init(4), gmp_init(5)), 3);
140
+        $this->assertEquals((int) Math::modSub(gmp_init(12), gmp_init(4), gmp_init(5)), 3);
141 141
     }
142 142
     
143 143
     public function test_modMul() : void
144 144
     {
145
-        $this->assertEquals((int)Math::modMul(gmp_init(3), gmp_init(4), gmp_init(5)), 2);
145
+        $this->assertEquals((int) Math::modMul(gmp_init(3), gmp_init(4), gmp_init(5)), 2);
146 146
     }
147 147
     
148 148
     public function test_modDiv() : void
149 149
     {
150
-        $this->assertEquals((int)Math::modDiv(gmp_init(12), gmp_init(2), gmp_init(5)), 36);
150
+        $this->assertEquals((int) Math::modDiv(gmp_init(12), gmp_init(2), gmp_init(5)), 36);
151 151
     }
152 152
 }
153 153
 
Please login to merge, or discard this patch.
SKien/Test/PNServer/UtilsCurveTest.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 namespace SKien\Test\PNServer;
5 5
 
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
     public function test_create() : void
31 31
     {
32 32
         $this->assertEquals($this->cv->getSize(), 256);
33
-        $this->assertEquals((int)$this->cv->getA(), 9223372036854775804);
34
-        $this->assertEquals((int)$this->cv->getB(), 4309448131093880907);
35
-        $this->assertEquals((int)$this->cv->getPrime(), 999999999999);
33
+        $this->assertEquals((int) $this->cv->getA(), 9223372036854775804);
34
+        $this->assertEquals((int) $this->cv->getB(), 4309448131093880907);
35
+        $this->assertEquals((int) $this->cv->getPrime(), 999999999999);
36 36
     }
37 37
     
38 38
     public function test_getPoint() : void
@@ -71,12 +71,12 @@  discard block
 block discarded – undo
71 71
         $pt2 = Point::create(gmp_init(10), gmp_init(40));
72 72
         // result must be $pt1
73 73
         $pt = $this->cv->add($pt1, Point::infinity());
74
-        $this->assertSame((int)$pt1->getX(), (int)$pt->getX());
75
-        $this->assertSame((int)$pt1->getY(), (int)$pt->getY());
74
+        $this->assertSame((int) $pt1->getX(), (int) $pt->getX());
75
+        $this->assertSame((int) $pt1->getY(), (int) $pt->getY());
76 76
         // result must be $pt2
77 77
         $pt = $this->cv->add(Point::infinity(), $pt2);
78
-        $this->assertSame((int)$pt2->getX(), (int)$pt->getX());
79
-        $this->assertSame((int)$pt2->getY(), (int)$pt->getY());
78
+        $this->assertSame((int) $pt2->getX(), (int) $pt->getX());
79
+        $this->assertSame((int) $pt2->getY(), (int) $pt->getY());
80 80
         // result must be infinity
81 81
         $pt = $this->cv->add($pt1, $pt2);
82 82
         $this->assertTrue($pt->isInfinity());
Please login to merge, or discard this patch.
SKien/Test/PNServer/PNVapidTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types = 1);
2
+declare(strict_types=1);
3 3
 
4 4
 namespace SKien\Test\PNServer;
5 5
 
Please login to merge, or discard this patch.