File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4343 },
4444 "extra" : {
4545 "branch-alias" : {
46- "dev-master" : " 6.3 .x-dev"
46+ "dev-master" : " 7.0 .x-dev"
4747 }
4848 },
4949 "scripts" : {
Original file line number Diff line number Diff line change 33namespace Wikibase \DataModel \Snak ;
44
55use Hashable ;
6+ use InvalidArgumentException ;
7+ use Traversable ;
68use Wikibase \DataModel \HashArray ;
79use Wikibase \DataModel \Internal \MapValueHasher ;
810
1820 */
1921class SnakList extends HashArray implements Hashable {
2022
23+ /**
24+ * @param Snak[]|Traversable $snaks
25+ *
26+ * @throws InvalidArgumentException
27+ */
28+ public function __construct ( $ snaks = [] ) {
29+ if ( !is_array ( $ snaks ) && !( $ snaks instanceof Traversable ) ) {
30+ throw new InvalidArgumentException ( '$snaks must be an array or an instance of Traversable ' );
31+ }
32+
33+ foreach ( $ snaks as $ index => $ snak ) {
34+ $ this ->setElement ( $ index , $ snak );
35+ }
36+ }
37+
2138 /**
2239 * @see GenericArrayObject::getObjectType
2340 *
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public function instanceProvider() {
3333 $ instances = [];
3434
3535 foreach ( $ this ->constructorProvider () as $ args ) {
36- $ instances [] = [ new $ class ( array_key_exists ( 0 , $ args ) ? $ args [0 ] : null ) ];
36+ $ instances [] = [ new $ class ( array_key_exists ( 0 , $ args ) ? $ args [0 ] : [] ) ];
3737 }
3838
3939 return $ instances ;
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ public function invalidConstructorArgumentsProvider() {
8585 $ id1 = new PropertyId ( 'P1 ' );
8686
8787 return [
88+ [ null ],
8889 [ false ],
8990 [ 1 ],
9091 [ 0.1 ],
You can’t perform that action at this time.
0 commit comments