Skip to content

Commit 73b78ca

Browse files
thiemowmdeWMDE bot
authored andcommitted
Use more correct ?? operator instead of ?: where possible
The only reason this code uses ?: is that it was available much earlier, since PHP 5.3, while ?? was only available since PHP 7.0. ?? is more specific and gets only activated on null, while ?: is more relaxed and gets activated on any "falsy" value. While that can be useful it's unspecific and fragile and just not needed in these places. Change-Id: Ibe24e9c67faab1fdea4feb0f09b8d62c973b23af
1 parent 710c306 commit 73b78ca

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/Entity/Item.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public function __construct(
6868
?StatementList $statements = null
6969
) {
7070
$this->id = $id;
71-
$this->fingerprint = $fingerprint ?: new Fingerprint();
72-
$this->siteLinks = $siteLinks ?: new SiteLinkList();
73-
$this->statements = $statements ?: new StatementList();
71+
$this->fingerprint = $fingerprint ?? new Fingerprint();
72+
$this->siteLinks = $siteLinks ?? new SiteLinkList();
73+
$this->statements = $statements ?? new StatementList();
7474
}
7575

7676
/**

src/Entity/Property.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ public function __construct(
7171
?StatementList $statements = null
7272
) {
7373
$this->id = $id;
74-
$this->fingerprint = $fingerprint ?: new Fingerprint();
74+
$this->fingerprint = $fingerprint ?? new Fingerprint();
7575
$this->setDataTypeId( $dataTypeId );
76-
$this->statements = $statements ?: new StatementList();
76+
$this->statements = $statements ?? new StatementList();
7777
}
7878

7979
/**

src/Statement/Statement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public function __construct(
6767
?string $guid = null
6868
) {
6969
$this->mainSnak = $mainSnak;
70-
$this->qualifiers = $qualifiers ?: new SnakList();
71-
$this->references = $references ?: new ReferenceList();
70+
$this->qualifiers = $qualifiers ?? new SnakList();
71+
$this->references = $references ?? new ReferenceList();
7272
$this->setGuid( $guid );
7373
}
7474

src/Term/Fingerprint.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public function __construct(
4747
?TermList $descriptions = null,
4848
?AliasGroupList $aliasGroups = null
4949
) {
50-
$this->labels = $labels ?: new TermList();
51-
$this->descriptions = $descriptions ?: new TermList();
52-
$this->aliasGroups = $aliasGroups ?: new AliasGroupList();
50+
$this->labels = $labels ?? new TermList();
51+
$this->descriptions = $descriptions ?? new TermList();
52+
$this->aliasGroups = $aliasGroups ?? new AliasGroupList();
5353
}
5454

5555
/**

0 commit comments

Comments
 (0)