Conditions | 4 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
19 | public function testNamespaces() |
||
20 | { |
||
21 | $client = static::createClient(); |
||
22 | $isSingle = $this->container->getParameter('app.single_wiki'); |
||
23 | |||
24 | // Test 404 (for single-wiki setups, that wiki's namespaces are always returned). |
||
25 | $crawler = $client->request('GET', '/api/namespaces/wiki.that.doesnt.exist.org'); |
||
26 | if ($isSingle) { |
||
27 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
||
28 | } else { |
||
29 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); |
||
30 | } |
||
31 | |||
32 | if (!$isSingle && $this->container->getParameter('app.is_labs')) { |
||
33 | $crawler = $client->request('GET', '/api/namespaces/fr.wikipedia.org'); |
||
34 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
||
35 | |||
36 | // Check that a correct namespace value was returned |
||
37 | $namespaces = (array) json_decode($client->getResponse()->getContent()); |
||
38 | $this->assertEquals('Utilisateur', array_values($namespaces)[2]); // User in French |
||
39 | } |
||
40 | } |
||
41 | } |
||
42 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.