Skip to content

Commit 4efaf3c

Browse files
authored
Merge pull request #756 from wmde/setidDocs
Fix forgotten Item/Property::setId documentation and exception
2 parents 256b742 + d5b7087 commit 4efaf3c

2 files changed

Lines changed: 10 additions & 16 deletions

File tree

src/Entity/Item.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,18 @@ public function getId() {
8383
}
8484

8585
/**
86-
* Can be integer since 0.1.
87-
* Can be ItemId since 0.5.
88-
* Can be null since 1.0.
86+
* @since 0.5, can be null since 1.0
8987
*
9088
* @param ItemId|null $id
9189
*
9290
* @throws InvalidArgumentException
9391
*/
9492
public function setId( $id ) {
95-
if ( $id === null || $id instanceof ItemId ) {
96-
$this->id = $id;
97-
} else {
98-
throw new InvalidArgumentException( '$id must be an instance of ItemId, an integer,'
99-
. ' or null' );
93+
if ( !( $id instanceof ItemId ) && $id !== null ) {
94+
throw new InvalidArgumentException( '$id must be an ItemId or null' );
10095
}
96+
97+
$this->id = $id;
10198
}
10299

103100
/**

src/Entity/Property.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,18 @@ public function getId() {
8181
}
8282

8383
/**
84-
* Can be integer since 0.1.
85-
* Can be PropertyId since 0.5.
86-
* Can be null since 1.0.
84+
* @since 0.5, can be null since 1.0
8785
*
8886
* @param PropertyId|null $id
8987
*
9088
* @throws InvalidArgumentException
9189
*/
9290
public function setId( $id ) {
93-
if ( $id === null || $id instanceof PropertyId ) {
94-
$this->id = $id;
95-
} else {
96-
throw new InvalidArgumentException( '$id must be an instance of PropertyId, an integer,'
97-
. ' or null' );
91+
if ( !( $id instanceof PropertyId ) && $id !== null ) {
92+
throw new InvalidArgumentException( '$id must be a PropertyId or null' );
9893
}
94+
95+
$this->id = $id;
9996
}
10097

10198
/**

0 commit comments

Comments
 (0)