This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Tests\Wikibase\DataModel\Deserializers; |
||
4 | |||
5 | use Deserializers\Deserializer; |
||
6 | use Wikibase\DataModel\Deserializers\ItemDeserializer; |
||
7 | use Wikibase\DataModel\Entity\Item; |
||
8 | use Wikibase\DataModel\Entity\ItemId; |
||
9 | use Wikibase\DataModel\SiteLink; |
||
10 | use Wikibase\DataModel\Snak\PropertyNoValueSnak; |
||
11 | use Wikibase\DataModel\Statement\Statement; |
||
12 | use Wikibase\DataModel\Statement\StatementList; |
||
13 | use Wikibase\DataModel\Term\AliasGroup; |
||
14 | use Wikibase\DataModel\Term\AliasGroupList; |
||
15 | use Wikibase\DataModel\Term\Term; |
||
16 | use Wikibase\DataModel\Term\TermList; |
||
17 | |||
18 | /** |
||
19 | * @covers Wikibase\DataModel\Deserializers\ItemDeserializer |
||
20 | * |
||
21 | * @license GPL-2.0-or-later |
||
22 | * @author Thomas Pellissier Tanon |
||
23 | * @author Bene* < [email protected] > |
||
24 | */ |
||
25 | class ItemDeserializerTest extends DispatchableDeserializerTest { |
||
26 | |||
27 | protected function buildDeserializer() { |
||
28 | $entityIdDeserializerMock = $this->getMockBuilder( Deserializer::class )->getMock(); |
||
29 | $entityIdDeserializerMock->expects( $this->any() ) |
||
30 | ->method( 'deserialize' ) |
||
31 | ->with( $this->equalTo( 'Q42' ) ) |
||
32 | ->will( $this->returnValue( new ItemId( 'Q42' ) ) ); |
||
33 | |||
34 | $termListDeserializerMock = $this->getMockBuilder( Deserializer::class )->getMock(); |
||
35 | $termListDeserializerMock->expects( $this->any() ) |
||
36 | ->method( 'deserialize' ) |
||
37 | ->with( $this->equalTo( [ |
||
38 | 'en' => [ |
||
39 | 'lang' => 'en', |
||
40 | 'value' => 'foo' |
||
41 | ] |
||
42 | ] ) ) |
||
43 | ->will( $this->returnValue( new TermList( [ new Term( 'en', 'foo' ) ] ) ) ); |
||
44 | |||
45 | $aliasGroupListDeserializerMock = $this->getMockBuilder( Deserializer::class )->getMock(); |
||
46 | $aliasGroupListDeserializerMock->expects( $this->any() ) |
||
47 | ->method( 'deserialize' ) |
||
48 | ->with( $this->equalTo( [ |
||
49 | 'en' => [ |
||
50 | 'lang' => 'en', |
||
51 | 'values' => [ 'foo', 'bar' ] |
||
52 | ] |
||
53 | ] ) ) |
||
54 | ->will( $this->returnValue( |
||
55 | new AliasGroupList( [ new AliasGroup( 'en', [ 'foo', 'bar' ] ) ] ) ) |
||
56 | ); |
||
57 | |||
58 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
59 | $statement->setGuid( 'test' ); |
||
60 | |||
61 | $statementListDeserializerMock = $this->getMockBuilder( Deserializer::class )->getMock(); |
||
62 | $statementListDeserializerMock->expects( $this->any() ) |
||
63 | ->method( 'deserialize' ) |
||
64 | ->with( $this->equalTo( [ |
||
65 | 'P42' => [ |
||
66 | [ |
||
67 | 'mainsnak' => [ |
||
68 | 'snaktype' => 'novalue', |
||
69 | 'property' => 'P42' |
||
70 | ], |
||
71 | 'type' => 'statement', |
||
72 | 'rank' => 'normal' |
||
73 | ] |
||
74 | ] |
||
75 | ] ) ) |
||
76 | ->will( $this->returnValue( new StatementList( [ $statement ] ) ) ); |
||
77 | |||
78 | $siteLinkDeserializerMock = $this->getMockBuilder( Deserializer::class )->getMock(); |
||
79 | $siteLinkDeserializerMock->expects( $this->any() ) |
||
80 | ->method( 'deserialize' ) |
||
81 | ->with( $this->equalTo( [ |
||
82 | 'site' => 'enwiki', |
||
83 | 'title' => 'Nyan Cat', |
||
84 | 'badges' => [] |
||
85 | ] ) ) |
||
86 | ->will( $this->returnValue( new SiteLink( 'enwiki', 'Nyan Cat' ) ) ); |
||
87 | |||
88 | return new ItemDeserializer( |
||
89 | $entityIdDeserializerMock, |
||
0 ignored issues
–
show
|
|||
90 | $termListDeserializerMock, |
||
0 ignored issues
–
show
$termListDeserializerMock is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Deserializers\Deserializer> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
91 | $aliasGroupListDeserializerMock, |
||
0 ignored issues
–
show
$aliasGroupListDeserializerMock is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Deserializers\Deserializer> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
92 | $statementListDeserializerMock, |
||
0 ignored issues
–
show
$statementListDeserializerMock is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Deserializers\Deserializer> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
93 | $siteLinkDeserializerMock |
||
0 ignored issues
–
show
$siteLinkDeserializerMock is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Deserializers\Deserializer> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
94 | ); |
||
95 | } |
||
96 | |||
97 | public function deserializableProvider() { |
||
98 | return [ |
||
99 | [ |
||
100 | [ |
||
101 | 'type' => 'item' |
||
102 | ] |
||
103 | ], |
||
104 | ]; |
||
105 | } |
||
106 | |||
107 | public function nonDeserializableProvider() { |
||
108 | return [ |
||
109 | [ |
||
110 | 5 |
||
111 | ], |
||
112 | [ |
||
113 | [] |
||
114 | ], |
||
115 | [ |
||
116 | [ |
||
117 | 'type' => 'property' |
||
118 | ] |
||
119 | ], |
||
120 | ]; |
||
121 | } |
||
122 | |||
123 | public function deserializationProvider() { |
||
124 | $provider = [ |
||
125 | [ |
||
126 | new Item(), |
||
127 | [ |
||
128 | 'type' => 'item' |
||
129 | ] |
||
130 | ], |
||
131 | ]; |
||
132 | |||
133 | $item = new Item( new ItemId( 'Q42' ) ); |
||
134 | $provider[] = [ |
||
135 | $item, |
||
136 | [ |
||
137 | 'type' => 'item', |
||
138 | 'id' => 'Q42' |
||
139 | ] |
||
140 | ]; |
||
141 | |||
142 | $item = new Item(); |
||
143 | $item->setLabel( 'en', 'foo' ); |
||
144 | $provider[] = [ |
||
145 | $item, |
||
146 | [ |
||
147 | 'type' => 'item', |
||
148 | 'labels' => [ |
||
149 | 'en' => [ |
||
150 | 'lang' => 'en', |
||
151 | 'value' => 'foo' |
||
152 | ] |
||
153 | ] |
||
154 | ] |
||
155 | ]; |
||
156 | |||
157 | $item = new Item(); |
||
158 | $item->setDescription( 'en', 'foo' ); |
||
159 | $provider[] = [ |
||
160 | $item, |
||
161 | [ |
||
162 | 'type' => 'item', |
||
163 | 'descriptions' => [ |
||
164 | 'en' => [ |
||
165 | 'lang' => 'en', |
||
166 | 'value' => 'foo' |
||
167 | ] |
||
168 | ] |
||
169 | ] |
||
170 | ]; |
||
171 | |||
172 | $item = new Item(); |
||
173 | $item->setAliases( 'en', [ 'foo', 'bar' ] ); |
||
174 | $provider[] = [ |
||
175 | $item, |
||
176 | [ |
||
177 | 'type' => 'item', |
||
178 | 'aliases' => [ |
||
179 | 'en' => [ |
||
180 | 'lang' => 'en', |
||
181 | 'values' => [ 'foo', 'bar' ] |
||
182 | ] |
||
183 | ] |
||
184 | ] |
||
185 | ]; |
||
186 | |||
187 | $item = new Item(); |
||
188 | $item->getStatements()->addNewStatement( new PropertyNoValueSnak( 42 ), null, null, 'test' ); |
||
189 | $provider[] = [ |
||
190 | $item, |
||
191 | [ |
||
192 | 'type' => 'item', |
||
193 | 'claims' => [ |
||
194 | 'P42' => [ |
||
195 | [ |
||
196 | 'mainsnak' => [ |
||
197 | 'snaktype' => 'novalue', |
||
198 | 'property' => 'P42' |
||
199 | ], |
||
200 | 'type' => 'statement', |
||
201 | 'rank' => 'normal' |
||
202 | ] |
||
203 | ] |
||
204 | ] |
||
205 | ] |
||
206 | ]; |
||
207 | |||
208 | $item = new Item(); |
||
209 | $item->getSiteLinkList()->addNewSiteLink( 'enwiki', 'Nyan Cat' ); |
||
210 | $provider[] = [ |
||
211 | $item, |
||
212 | [ |
||
213 | 'type' => 'item', |
||
214 | 'sitelinks' => [ |
||
215 | 'enwiki' => [ |
||
216 | 'site' => 'enwiki', |
||
217 | 'title' => 'Nyan Cat', |
||
218 | 'badges' => [] |
||
219 | ] |
||
220 | ] |
||
221 | ] |
||
222 | ]; |
||
223 | |||
224 | return $provider; |
||
225 | } |
||
226 | |||
227 | } |
||
228 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: