Skip to content

Commit a59a1c7

Browse files
committed
Undeprecate term setters in Item and Property
Right now code as follows is deprecated: $item = new Item(); $item->setLabel( 'en', 'foo' ); $item->setDescription( 'de', 'bar' ); This is caused by these setters being deprecated in Entity, which was done to deprecate code assuming all entities have these terms, and to discourage bad interface seggergation. The above code suffers from neither these problems, and is a style often used in tests, and has no clean alternative due to PHPs lack of named parameters. Hence this undeprecation in Item and Property, keeping the one in Entity.
1 parent 491e81f commit a59a1c7

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

RELEASE-NOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ Other breaking changes:
5757
* Renamed `Claim\ClaimGuidParsingException` to `Statement\StatementGuidParsingException`, leaving a b/c alias in place
5858
* Renamed `StatementListProvider` to `Statement\StatementListProvider`, leaving a b/c alias in place
5959

60+
#### Other changes
61+
62+
* `Item::setLabel`, `Item::setDescription` and `Item::setAliases` are no longer deprecated
63+
* `Property::setLabel`, `Property::setDescription` and `Property::setAliases` are no longer deprecated
64+
6065
## Version 2.6.1 (2015-04-25)
6166

6267
* Allow installation together with Diff 2.x.

src/Entity/Item.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,36 @@ public function setId( $id ) {
7676
}
7777
}
7878

79+
/**
80+
* @param string $languageCode
81+
* @param string $value
82+
*
83+
* @throws InvalidArgumentException
84+
*/
85+
public function setLabel( $languageCode, $value ) {
86+
$this->fingerprint->setLabel( $languageCode, $value );
87+
}
88+
89+
/**
90+
* @param string $languageCode
91+
* @param string $value
92+
*
93+
* @throws InvalidArgumentException
94+
*/
95+
public function setDescription( $languageCode, $value ) {
96+
$this->fingerprint->setDescription( $languageCode, $value );
97+
}
98+
99+
/**
100+
* @param string $languageCode
101+
* @param string[] $aliases
102+
*
103+
* @throws InvalidArgumentException
104+
*/
105+
public function setAliases( $languageCode, array $aliases ) {
106+
$this->fingerprint->setAliasGroup( $languageCode, $aliases );
107+
}
108+
79109
/**
80110
* @since 0.1 return type changed in 0.3
81111
*

src/Entity/Property.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,36 @@ public function setId( $id ) {
7373
}
7474
}
7575

76+
/**
77+
* @param string $languageCode
78+
* @param string $value
79+
*
80+
* @throws InvalidArgumentException
81+
*/
82+
public function setLabel( $languageCode, $value ) {
83+
$this->fingerprint->setLabel( $languageCode, $value );
84+
}
85+
86+
/**
87+
* @param string $languageCode
88+
* @param string $value
89+
*
90+
* @throws InvalidArgumentException
91+
*/
92+
public function setDescription( $languageCode, $value ) {
93+
$this->fingerprint->setDescription( $languageCode, $value );
94+
}
95+
96+
/**
97+
* @param string $languageCode
98+
* @param string[] $aliases
99+
*
100+
* @throws InvalidArgumentException
101+
*/
102+
public function setAliases( $languageCode, array $aliases ) {
103+
$this->fingerprint->setAliasGroup( $languageCode, $aliases );
104+
}
105+
76106
/**
77107
* @since 0.1 return type changed in 0.3
78108
*

0 commit comments

Comments
 (0)