Skip to content

Commit c2522f2

Browse files
committed
Merge pull request #382 from wmde/derpp
Merge master into 3.0.x-dev
2 parents 40a9b76 + f775d66 commit c2522f2

16 files changed

Lines changed: 57 additions & 35 deletions

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
## Version 2.6.0 (dev)
1111

1212
* Empty strings are now detected as invalid in the `SiteLink` constructor
13+
* Fixed `EntityIdValue::unserialize` accidentally returning itself
1314

1415
## Version 2.5.0 (2014-01-20)
1516

src/Entity/Entity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public function setAllAliases( array $aliasLists ) {
345345
*
346346
* @since 0.1
347347
*
348-
* @return static
348+
* @return self
349349
*/
350350
public function copy() {
351351
return unserialize( serialize( $this ) );

src/Entity/EntityIdValue.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ protected function getNumericId() {
5656
* @param string $value
5757
*
5858
* @throws IllegalValueException
59-
* @return EntityIdValue
6059
*/
6160
public function unserialize( $value ) {
6261
list( $entityType, $numericId ) = json_decode( $value );
@@ -67,7 +66,7 @@ public function unserialize( $value ) {
6766
throw new IllegalValueException( 'Invalid EntityIdValue serialization.' );
6867
}
6968

70-
return $this->__construct( $entityId );
69+
$this->__construct( $entityId );
7170
}
7271

7372
/**
@@ -97,7 +96,7 @@ public function getSortKey() {
9796
*
9897
* @since 0.5
9998
*
100-
* @return EntityId
99+
* @return EntityIdValue
101100
*/
102101
public function getValue() {
103102
return $this;

src/HashableObjectStorage.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
class HashableObjectStorage extends \SplObjectStorage implements \Comparable {
2020

2121
/**
22-
* Constructor.
23-
*
2422
* @since 0.2
2523
*
2624
* @param array $objects

src/Snak/SnakList.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,16 @@ public function getHash() {
116116

117117
/**
118118
* Orders the snaks in the list grouping them by property.
119-
* @param $order array of serliazed propertyIds to order by.
119+
*
120+
* @param string[] $order List of serliazed property ids to order by.
120121
*
121122
* @since 0.5
122123
*/
123124
public function orderByProperty( $order = array() ) {
124125
$snaksByProperty = $this->getSnaksByProperty();
125126
$orderedProperties = array_unique( array_merge( $order, array_keys( $snaksByProperty ) ) );
126127

127-
foreach( $orderedProperties as $property ){
128+
foreach ( $orderedProperties as $property ) {
128129
$snaks = $snaksByProperty[$property];
129130
$this->moveSnaksToBottom( $snaks );
130131
}

src/Term/AliasGroup.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ public function equals( $target ) {
9292
return true;
9393
}
9494

95-
return $target instanceof self
95+
return is_object( $target )
96+
&& get_called_class() === get_class( $target )
9697
&& $this->languageCode === $target->languageCode
9798
&& $this->aliases == $target->aliases;
9899
}

src/Term/AliasGroupFallback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function getActualLanguageCode() {
6161
}
6262

6363
/**
64-
* @return string
64+
* @return string|null
6565
*/
6666
public function getSourceLanguageCode() {
6767
return $this->sourceLanguageCode;

src/Term/Term.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ public function equals( $target ) {
7070
return true;
7171
}
7272

73-
return $target instanceof self
73+
return is_object( $target )
74+
&& get_called_class() === get_class( $target )
7475
&& $this->languageCode === $target->languageCode
7576
&& $this->text === $target->text;
7677
}

src/Term/TermFallback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function getActualLanguageCode() {
5858
}
5959

6060
/**
61-
* @return string
61+
* @return string|null
6262
*/
6363
public function getSourceLanguageCode() {
6464
return $this->sourceLanguageCode;

tests/unit/HashArray/HashArrayTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public function instanceProvider() {
4343

4444
/**
4545
* @dataProvider instanceProvider
46-
*
4746
* @param HashArray $array
4847
*/
4948
public function testHasElement( HashArray $array ) {
@@ -65,7 +64,6 @@ public function testHasElement( HashArray $array ) {
6564

6665
/**
6766
* @dataProvider instanceProvider
68-
*
6967
* @param HashArray $array
7068
*/
7169
public function testRemoveElement( HashArray $array ) {
@@ -100,14 +98,18 @@ public function testRemoveElement( HashArray $array ) {
10098

10199
/**
102100
* @dataProvider instanceProvider
103-
*
104101
* @param HashArray $array
105102
*/
106103
public function testEquals( HashArray $array ) {
107104
$this->assertTrue( $array->equals( $array ) );
108105
$this->assertFalse( $array->equals( 42 ) );
109106
}
110107

108+
/**
109+
* @param array $elements
110+
*
111+
* @return array[]
112+
*/
111113
protected function arrayWrap( array $elements ) {
112114
return array_map(
113115
function ( $element ) {
@@ -118,4 +120,3 @@ function ( $element ) {
118120
}
119121

120122
}
121-

0 commit comments

Comments
 (0)