Skip to content

Commit 7349bc1

Browse files
committed
Rewrite isset(X) ? X : default to X ?? default
1 parent c787b8c commit 7349bc1

File tree

7 files changed

+12
-13
lines changed

7 files changed

+12
-13
lines changed

src/main/php/rdbms/DefaultDrivers.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ public function drivers() { return array_keys(self::$impl); }
5757
* @return string[] implementations
5858
*/
5959
public function implementationsFor($driver) {
60-
return isset(self::$impl[$driver]) ? self::$impl[$driver] : parent::implementationsFor($driver);
60+
return self::$impl[$driver] ?? parent::implementationsFor($driver);
6161
}
6262
}

src/main/php/rdbms/mysql/MySQLDBAdapter.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static function tableAttributeFrom($record) {
103103
self::$map[$regs[1]], // type
104104
false !== strpos($record['Extra'], 'auto_increment'), // identity
105105
!(empty($record['Null']) || ('NO' == $record['Null'])), // nullable
106-
(int)(isset($regs[3]) ? $regs[3] : 0), // length
106+
(int)($regs[3] ?? 0), // length
107107
0, // precision
108108
0 // scale
109109
);

src/main/php/rdbms/mysqli/MySQLiDBAdapter.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static function tableAttributeFrom($record) {
102102
self::$map[$regs[1]], // type
103103
false !== strpos($record['Extra'], 'auto_increment'), // identity
104104
!(empty($record['Null']) || ('NO' == $record['Null'])), // nullable
105-
(int)(isset($regs[3]) ? $regs[3] : 0), // length
105+
(int)($regs[3] ?? 0), // length
106106
0, // precision
107107
0 // scale
108108
);

src/main/php/rdbms/mysqlx/NamedPipe.class.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ protected function locate() {
4040
return null;
4141
} while (0);
4242

43-
$options= $this->parse($ini);
44-
return isset($options['client']['socket']) ? $pipes.$options['client']['socket'] : null;
43+
return $this->parse($ini)['client']['socket'] ?? null;
4544
}
4645

4746
/**

src/main/php/rdbms/tds/TdsProtocol.class.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function unmarshal($stream, $field, $records) {
128128
self::$recordsFor[0][self::XT_NVARCHAR]= self::$recordsFor[0][self::XT_VARCHAR];
129129
self::$recordsFor[0][self::T_INTN]= newinstance('rdbms.tds.TdsRecord', [], '{
130130
public function unmarshal($stream, $field, $records) {
131-
$len= isset($field["len"]) ? $field["len"] : $stream->getByte();
131+
$len= $field["len"] ?? $stream->getByte();
132132
switch ($len) {
133133
case 1: return $stream->getByte();
134134
case 2: return $stream->getShort();
@@ -180,7 +180,7 @@ public function unmarshal($stream, $field, $records) {
180180
}');
181181
self::$recordsFor[0][self::T_UINTN]= newinstance('rdbms.tds.TdsRecord', [], '{
182182
public function unmarshal($stream, $field, $records) {
183-
$len= isset($field["len"]) ? $field["len"] : $stream->getByte();
183+
$len= $field["len"] ?? $stream->getByte();
184184
switch ($len) {
185185
case 2: return $stream->getShort();
186186
case 4: return $stream->getLong();
@@ -191,7 +191,7 @@ public function unmarshal($stream, $field, $records) {
191191
}');
192192
self::$recordsFor[0][self::T_FLTN]= newinstance('rdbms.tds.TdsRecord', [], '{
193193
public function unmarshal($stream, $field, $records) {
194-
$len= isset($field["len"]) ? $field["len"] : $stream->getByte();
194+
$len= $field["len"] ?? $stream->getByte();
195195
switch ($len) {
196196
case 4: return $this->toFloat($stream->read(4)); break;
197197
case 8: return $this->toDouble($stream->read(8)); break;
@@ -226,7 +226,7 @@ public function unmarshal($stream, $field, $records) {
226226
}');
227227
self::$recordsFor[0][self::T_MONEYN]= newinstance('rdbms.tds.TdsRecord', [], '{
228228
public function unmarshal($stream, $field, $records) {
229-
$len= isset($field["len"]) ? $field["len"] : $stream->getByte();
229+
$len= $field["len"] ?? $stream->getByte();
230230
switch ($len) {
231231
case 4: return $this->toMoney($stream->getInt32()); break;
232232
case 8: return $this->toMoney($stream->getInt32(), $stream->getInt32()); break;

src/main/php/rdbms/tds/TdsV5Protocol.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function unmarshal($stream, $field, $records) {
9393
}');
9494
self::$recordsFor[0][self::T_DATETIMN]= newinstance('rdbms.tds.TdsRecord', [], '{
9595
public function unmarshal($stream, $field, $records) {
96-
$len= isset($field["len"]) ? $field["len"] : $stream->getByte();
96+
$len= $field["len"] ?? $stream->getByte();
9797
switch ($len) {
9898
case 4: return $this->toDate($stream->getShort(), $stream->getShort() * 60); break;
9999
case 8: return $this->toDate($stream->getLong(), $stream->getLong()); break;

src/main/php/rdbms/tds/TdsV7Protocol.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static function __static() { }
1818
protected function setupRecords() {
1919
$records[self::T_NUMERIC]= newinstance('rdbms.tds.TdsRecord', [], '{
2020
public function unmarshal($stream, $field, $records) {
21-
$len= isset($field["len"]) ? $field["len"]- 1 : $stream->getByte()- 1;
21+
$len= ($field["len"] ?? $stream->getByte()) - 1;
2222
if (-1 === $len) return null;
2323
$pos= $stream->getByte();
2424
for ($j= 0, $n= 0, $m= $pos ? 1 : -1; $j < $len; $j+= 4, $m= bcmul($m, "4294967296", 0)) {
@@ -55,7 +55,7 @@ public function unmarshal($stream, $field, $records) {
5555
}');
5656
$records[self::T_UNIQUE]= newinstance('rdbms.tds.TdsRecord', [], '{
5757
public function unmarshal($stream, $field, $records) {
58-
$len= isset($field["len"]) ? $field["len"] : $stream->getByte();
58+
$len= $field["len"] ?? $stream->getByte();
5959
if (0 === $len) return null;
6060
6161
$bytes= $stream->read($len);
@@ -116,7 +116,7 @@ public function unmarshal($stream, $field, $records) {
116116
}');
117117
self::$recordsFor[0][self::T_DATETIMN]= newinstance('rdbms.tds.TdsRecord', [], '{
118118
public function unmarshal($stream, $field, $records) {
119-
$len= isset($field["len"]) ? $field["len"] : $stream->getByte();
119+
$len= $field["len"] ?? $stream->getByte();
120120
switch ($len) {
121121
case 4: return $this->toDate($stream->getShort(), $stream->getShort() * 60); break;
122122
case 8: return $this->toDate($stream->getLong(), $stream->getLong() / 300); break;

0 commit comments

Comments
 (0)