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\PropertyDeserializer; |
||
7 | use Wikibase\DataModel\Entity\Property; |
||
8 | use Wikibase\DataModel\Entity\PropertyId; |
||
9 | use Wikibase\DataModel\Snak\PropertyNoValueSnak; |
||
10 | use Wikibase\DataModel\Statement\Statement; |
||
11 | use Wikibase\DataModel\Statement\StatementList; |
||
12 | use Wikibase\DataModel\Term\AliasGroup; |
||
13 | use Wikibase\DataModel\Term\AliasGroupList; |
||
14 | use Wikibase\DataModel\Term\Term; |
||
15 | use Wikibase\DataModel\Term\TermList; |
||
16 | |||
17 | /** |
||
18 | * @covers Wikibase\DataModel\Deserializers\PropertyDeserializer |
||
19 | * |
||
20 | * @license GPL-2.0-or-later |
||
21 | * @author Thomas Pellissier Tanon |
||
22 | * @author Bene* < [email protected] > |
||
23 | */ |
||
24 | class PropertyDeserializerTest extends DispatchableDeserializerTest { |
||
25 | |||
26 | protected function buildDeserializer() { |
||
27 | $entityIdDeserializerMock = $this->getMockBuilder( Deserializer::class )->getMock(); |
||
28 | $entityIdDeserializerMock->expects( $this->any() ) |
||
29 | ->method( 'deserialize' ) |
||
30 | ->with( $this->equalTo( 'P42' ) ) |
||
31 | ->will( $this->returnValue( new PropertyId( 'P42' ) ) ); |
||
32 | |||
33 | $termListDeserializerMock = $this->getMockBuilder( Deserializer::class )->getMock(); |
||
34 | $termListDeserializerMock->expects( $this->any() ) |
||
35 | ->method( 'deserialize' ) |
||
36 | ->with( $this->equalTo( [ |
||
37 | 'en' => [ |
||
38 | 'lang' => 'en', |
||
39 | 'value' => 'foo' |
||
40 | ] |
||
41 | ] ) ) |
||
42 | ->will( $this->returnValue( new TermList( [ new Term( 'en', 'foo' ) ] ) ) ); |
||
43 | |||
44 | $aliasGroupListDeserializerMock = $this->getMockBuilder( Deserializer::class )->getMock(); |
||
45 | $aliasGroupListDeserializerMock->expects( $this->any() ) |
||
46 | ->method( 'deserialize' ) |
||
47 | ->with( $this->equalTo( [ |
||
48 | 'en' => [ |
||
49 | 'lang' => 'en', |
||
50 | 'values' => [ 'foo', 'bar' ] |
||
51 | ] |
||
52 | ] ) ) |
||
53 | ->will( $this->returnValue( |
||
54 | new AliasGroupList( [ new AliasGroup( 'en', [ 'foo', 'bar' ] ) ] ) ) |
||
55 | ); |
||
56 | |||
57 | $statement = new Statement( new PropertyNoValueSnak( 42 ) ); |
||
58 | $statement->setGuid( 'test' ); |
||
59 | |||
60 | $statementListDeserializerMock = $this->getMockBuilder( Deserializer::class )->getMock(); |
||
61 | $statementListDeserializerMock->expects( $this->any() ) |
||
62 | ->method( 'deserialize' ) |
||
63 | ->with( $this->equalTo( [ |
||
64 | 'P42' => [ |
||
65 | [ |
||
66 | 'mainsnak' => [ |
||
67 | 'snaktype' => 'novalue', |
||
68 | 'property' => 'P42' |
||
69 | ], |
||
70 | 'type' => 'statement', |
||
71 | 'rank' => 'normal' |
||
72 | ] |
||
73 | ] |
||
74 | ] ) ) |
||
75 | ->will( $this->returnValue( new StatementList( [ $statement ] ) ) ); |
||
76 | |||
77 | return new PropertyDeserializer( |
||
78 | $entityIdDeserializerMock, |
||
0 ignored issues
–
show
|
|||
79 | $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);
![]() |
|||
80 | $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);
![]() |
|||
81 | $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);
![]() |
|||
82 | ); |
||
83 | } |
||
84 | |||
85 | public function deserializableProvider() { |
||
86 | return [ |
||
87 | [ |
||
88 | [ |
||
89 | 'type' => 'property' |
||
90 | ] |
||
91 | ], |
||
92 | ]; |
||
93 | } |
||
94 | |||
95 | public function nonDeserializableProvider() { |
||
96 | return [ |
||
97 | [ |
||
98 | 5 |
||
99 | ], |
||
100 | [ |
||
101 | [] |
||
102 | ], |
||
103 | [ |
||
104 | [ |
||
105 | 'type' => 'item' |
||
106 | ] |
||
107 | ], |
||
108 | ]; |
||
109 | } |
||
110 | |||
111 | public function deserializationProvider() { |
||
112 | $property = Property::newFromType( 'string' ); |
||
113 | |||
114 | $provider = [ |
||
115 | [ |
||
116 | $property, |
||
117 | [ |
||
118 | 'type' => 'property', |
||
119 | 'datatype' => 'string' |
||
120 | ] |
||
121 | ], |
||
122 | ]; |
||
123 | |||
124 | $property = new Property( new PropertyId( 'P42' ), null, 'string' ); |
||
125 | $provider[] = [ |
||
126 | $property, |
||
127 | [ |
||
128 | 'type' => 'property', |
||
129 | 'datatype' => 'string', |
||
130 | 'id' => 'P42' |
||
131 | ] |
||
132 | ]; |
||
133 | |||
134 | $property = Property::newFromType( 'string' ); |
||
135 | $property->setLabel( 'en', 'foo' ); |
||
136 | $provider[] = [ |
||
137 | $property, |
||
138 | [ |
||
139 | 'type' => 'property', |
||
140 | 'datatype' => 'string', |
||
141 | 'labels' => [ |
||
142 | 'en' => [ |
||
143 | 'lang' => 'en', |
||
144 | 'value' => 'foo' |
||
145 | ] |
||
146 | ] |
||
147 | ] |
||
148 | ]; |
||
149 | |||
150 | $property = Property::newFromType( 'string' ); |
||
151 | $property->setDescription( 'en', 'foo' ); |
||
152 | $provider[] = [ |
||
153 | $property, |
||
154 | [ |
||
155 | 'type' => 'property', |
||
156 | 'datatype' => 'string', |
||
157 | 'descriptions' => [ |
||
158 | 'en' => [ |
||
159 | 'lang' => 'en', |
||
160 | 'value' => 'foo' |
||
161 | ] |
||
162 | ] |
||
163 | ] |
||
164 | ]; |
||
165 | |||
166 | $property = Property::newFromType( 'string' ); |
||
167 | $property->setAliases( 'en', [ 'foo', 'bar' ] ); |
||
168 | $provider[] = [ |
||
169 | $property, |
||
170 | [ |
||
171 | 'type' => 'property', |
||
172 | 'datatype' => 'string', |
||
173 | 'aliases' => [ |
||
174 | 'en' => [ |
||
175 | 'lang' => 'en', |
||
176 | 'values' => [ 'foo', 'bar' ] |
||
177 | ] |
||
178 | ] |
||
179 | ] |
||
180 | ]; |
||
181 | |||
182 | $property = Property::newFromType( 'string' ); |
||
183 | $property->getStatements()->addNewStatement( new PropertyNoValueSnak( 42 ), null, null, 'test' ); |
||
184 | $provider[] = [ |
||
185 | $property, |
||
186 | [ |
||
187 | 'type' => 'property', |
||
188 | 'datatype' => 'string', |
||
189 | 'claims' => [ |
||
190 | 'P42' => [ |
||
191 | [ |
||
192 | 'mainsnak' => [ |
||
193 | 'snaktype' => 'novalue', |
||
194 | 'property' => 'P42' |
||
195 | ], |
||
196 | 'type' => 'statement', |
||
197 | 'rank' => 'normal' |
||
198 | ] |
||
199 | ] |
||
200 | ] |
||
201 | ] |
||
202 | ]; |
||
203 | |||
204 | $property = Property::newFromType( 'string' ); |
||
205 | $property->getStatements()->addNewStatement( new PropertyNoValueSnak( 42 ), null, null, 'test' ); |
||
206 | $provider[] = [ |
||
207 | $property, |
||
208 | [ |
||
209 | 'type' => 'property', |
||
210 | 'datatype' => 'string', |
||
211 | 'claims' => [ |
||
212 | 'P42' => [ |
||
213 | [ |
||
214 | 'mainsnak' => [ |
||
215 | 'snaktype' => 'novalue', |
||
216 | 'property' => 'P42' |
||
217 | ], |
||
218 | 'type' => 'statement', |
||
219 | 'rank' => 'normal' |
||
220 | ] |
||
221 | ] |
||
222 | ] |
||
223 | ] |
||
224 | ]; |
||
225 | |||
226 | return $provider; |
||
227 | } |
||
228 | |||
229 | } |
||
230 |
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: