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 Elastica\Test; |
||
4 | |||
5 | use Elastica\Document; |
||
6 | use Elastica\Test\Base as BaseTest; |
||
7 | |||
8 | /** |
||
9 | * Tests the example code. |
||
10 | * |
||
11 | * @internal |
||
12 | */ |
||
13 | class ExampleTest extends BaseTest |
||
14 | { |
||
15 | /** |
||
16 | * @group functional |
||
17 | */ |
||
18 | public function testBasicGettingStarted(): void |
||
19 | { |
||
20 | $client = $this->_getClient(); |
||
21 | $index = $client->getIndex('ruflin'); |
||
22 | |||
23 | $id = 2; |
||
24 | $data = ['firstname' => 'Nicolas', 'lastname' => 'Ruflin']; |
||
25 | $doc = new Document($id, $data); |
||
26 | |||
27 | $index->addDocument($doc); |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @group functional |
||
32 | */ |
||
33 | public function testExample(): void |
||
34 | { |
||
35 | // Creates a new index 'xodoa' and a type 'user' inside this index |
||
36 | $client = $this->_getClient(); |
||
37 | $index = $client->getIndex('elastica_test'); |
||
38 | $index->create([], true); |
||
39 | |||
40 | // Adds 1 document to the index |
||
41 | $index->addDocument(new Document(1, ['username' => 'hans', 'test' => ['2', '3', '5']])); |
||
42 | |||
43 | // Adds a list of documents with _bulk upload to the index |
||
44 | $index->addDocuments([ |
||
45 | new Document(2, ['username' => 'john', 'test' => ['1', '3', '6']]), |
||
46 | new Document(3, ['username' => 'rolf', 'test' => ['2', '3', '7']]), |
||
47 | ]); |
||
48 | |||
49 | // Refresh index |
||
50 | $index->refresh(); |
||
51 | |||
52 | $resultSet = $index->search('rolf'); |
||
0 ignored issues
–
show
|
|||
53 | } |
||
54 | } |
||
55 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.