File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55* Removed support for calling ` Statement::addNewReference() ` and ` StatementList ` constructor with a
66 single array argument, which was deprecated in ` Version 9.6.0 (2021-03-31) ` . These should now be
77 called with a variadic argument list.
8- * Added ` __serialize() ` and ` __unserialize() ` methods to the ` EntityId ` interface.
8+ * Added ` __serialize() ` and ` __unserialize() ` methods to the ` EntityId ` interface,
9+ and deprecated the ` serialize() ` and ` unserialize() ` methods.
910* Added native type hints to the ` Statement ` and ` StatementList ` classes
1011* Added ` strict_types=1 ` to ` Statement.php ` , ` StatementList.php ` , and related test files
1112* Removed support for repository names in entity IDs (e.g. ` foo:Q1234 ` )
Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ public function __serialize(): array {
7171 * @return string
7272 */
7373 public function serialize () {
74+ wfDeprecated ( __METHOD__ , '1.41 ' );
7475 return $ this ->serialization ;
7576 }
7677
@@ -84,6 +85,7 @@ public function __unserialize( array $data ): void {
8485 * @param string $serialized
8586 */
8687 public function unserialize ( $ serialized ) {
88+ wfDeprecated ( __METHOD__ , '1.41 ' );
8789 $ array = json_decode ( $ serialized );
8890 $ this ->serialization = is_array ( $ array ) ? $ array [1 ] : $ serialized ;
8991 $ this ->serialization = $ this ->serialization ?? '' ;
Original file line number Diff line number Diff line change @@ -65,6 +65,7 @@ public function __serialize(): array {
6565 * @return string
6666 */
6767 public function serialize () {
68+ wfDeprecated ( __METHOD__ , '1.41 ' );
6869 return $ this ->serialization ;
6970 }
7071
@@ -78,6 +79,7 @@ public function __unserialize( array $data ): void {
7879 * @param string $serialized
7980 */
8081 public function unserialize ( $ serialized ) {
82+ wfDeprecated ( __METHOD__ , '1.41 ' );
8183 $ array = json_decode ( $ serialized );
8284 $ this ->serialization = is_array ( $ array ) ? $ array [1 ] : $ serialized ;
8385 $ this ->serialization = $ this ->serialization ?? '' ;
Original file line number Diff line number Diff line change 33namespace Wikibase \DataModel \Tests \Entity ;
44
55use InvalidArgumentException ;
6+ use MediaWikiUnitTestCase ;
67use ReflectionClass ;
78use Wikibase \DataModel \Entity \EntityId ;
89use Wikibase \DataModel \Entity \ItemId ;
2122 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
2223 * @author John Erling Blad < jeblad@gmail.com >
2324 */
24- class EntityIdTest extends \ PHPUnit \ Framework \TestCase {
25+ class EntityIdTest extends MediaWikiUnitTestCase {
2526
2627 public static function instanceProvider () {
2728 $ ids = [];
@@ -73,6 +74,9 @@ public static function deserializationCompatibilityProvider(): array {
7374 * @dataProvider deserializationCompatibilityProvider
7475 */
7576 public function testDeserializationCompatibility ( $ expected , $ serialization ) {
77+ if ( str_starts_with ( $ serialization , 'C: ' ) ) {
78+ $ this ->expectDeprecationAndContinue ( '/::unserialize/ ' );
79+ }
7680 $ this ->assertEquals (
7781 $ expected ,
7882 unserialize ( $ serialization )
Original file line number Diff line number Diff line change 33namespace Wikibase \DataModel \Tests \Entity ;
44
55use DataValues \IllegalValueException ;
6+ use MediaWikiUnitTestCase ;
67use Wikibase \DataModel \Entity \EntityId ;
78use Wikibase \DataModel \Entity \EntityIdValue ;
89use Wikibase \DataModel \Entity \ItemId ;
2021 * @author Thiemo Kreuz
2122 * @author Daniel Kinzler
2223 */
23- class EntityIdValueTest extends \ PHPUnit \ Framework \TestCase {
24+ class EntityIdValueTest extends MediaWikiUnitTestCase {
2425
2526 public function testCanConstruct () {
2627 $ entityId = new ItemId ( 'Q123 ' );
@@ -160,6 +161,9 @@ public static function provideDeserializationCompatibility() {
160161 * @param EntityIdValue $expected
161162 */
162163 public function testDeserializationCompatibility ( $ serialized , EntityIdValue $ expected ) {
164+ if ( str_contains ( $ serialized , 'C:32:"Wikibase\DataModel\Entity\ItemId" ' ) ) {
165+ $ this ->expectDeprecationAndContinue ( '/::unserialize/ ' );
166+ }
163167 $ id = unserialize ( $ serialized );
164168
165169 $ this ->assertEquals ( $ expected , $ id );
Original file line number Diff line number Diff line change 33namespace Wikibase \DataModel \Tests \Entity ;
44
55use InvalidArgumentException ;
6+ use MediaWikiUnitTestCase ;
67use Wikibase \DataModel \Entity \ItemId ;
78
89/**
1415 * @license GPL-2.0-or-later
1516 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
1617 */
17- class ItemIdTest extends \ PHPUnit \ Framework \TestCase {
18+ class ItemIdTest extends MediaWikiUnitTestCase {
1819
1920 /**
2021 * @dataProvider idSerializationProvider
@@ -86,6 +87,7 @@ public function testGetEntityType() {
8687
8788 public function testSerialize () {
8889 $ id = new ItemId ( 'Q1 ' );
90+ $ this ->expectDeprecationAndContinue ( '/ItemId::serialize/ ' );
8991 $ this ->assertSame ( 'Q1 ' , $ id ->serialize () );
9092 }
9193
@@ -94,6 +96,7 @@ public function testSerialize() {
9496 */
9597 public function testUnserialize ( $ json , $ expected ) {
9698 $ id = new ItemId ( 'Q1 ' );
99+ $ this ->expectDeprecationAndContinue ( '/ItemId::unserialize/ ' );
97100 $ id ->unserialize ( $ json );
98101 $ this ->assertSame ( $ expected , $ id ->getSerialization () );
99102 }
Original file line number Diff line number Diff line change 33namespace Wikibase \DataModel \Tests \Entity ;
44
55use InvalidArgumentException ;
6+ use MediaWikiUnitTestCase ;
67use Wikibase \DataModel \Entity \NumericPropertyId ;
78
89/**
1314 *
1415 * @license GPL-2.0-or-later
1516 */
16- class NumericPropertyIdTest extends \ PHPUnit \ Framework \TestCase {
17+ class NumericPropertyIdTest extends MediaWikiUnitTestCase {
1718
1819 /**
1920 * @dataProvider idSerializationProvider
@@ -85,6 +86,7 @@ public function testGetEntityType() {
8586
8687 public function testSerialize () {
8788 $ id = new NumericPropertyId ( 'P1 ' );
89+ $ this ->expectDeprecationAndContinue ( '/NumericPropertyId::serialize/ ' );
8890 $ this ->assertSame ( 'P1 ' , $ id ->serialize () );
8991 }
9092
@@ -93,6 +95,7 @@ public function testSerialize() {
9395 */
9496 public function testUnserialize ( $ json , $ expected ) {
9597 $ id = new NumericPropertyId ( 'P1 ' );
98+ $ this ->expectDeprecationAndContinue ( '/NumericPropertyId::unserialize/ ' );
9699 $ id ->unserialize ( $ json );
97100 $ this ->assertSame ( $ expected , $ id ->getSerialization () );
98101 }
You can’t perform that action at this time.
0 commit comments