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 AlexisLefebvre\Bundle\AsyncTweetsBundle\Command; |
||
4 | |||
5 | use Symfony\Component\Console\Input\InputArgument; |
||
6 | use Symfony\Component\Console\Input\InputInterface; |
||
7 | |||
8 | class StatusesHomeTimelineTestCommand extends StatusesHomeTimelineCommand |
||
9 | { |
||
10 | 9 | protected function configure() |
|
11 | { |
||
12 | 9 | parent::configure(); |
|
13 | |||
14 | $this |
||
15 | 9 | ->setName('statuses:hometimelinetest') |
|
16 | 9 | ->setDescription('Fetch home timeline test') |
|
17 | 9 | ->addArgument( |
|
18 | 9 | 'test', |
|
19 | 9 | InputArgument::OPTIONAL, |
|
20 | 9 | 'Return data for tests' |
|
21 | ); |
||
22 | 9 | } |
|
23 | |||
24 | /** |
||
25 | * Read tweet(s) from a JSON file. |
||
26 | * |
||
27 | * @param string $filename |
||
28 | * |
||
29 | * @return array |
||
30 | */ |
||
31 | 3 | protected function getTestContent($filename) |
|
32 | { |
||
33 | 3 | return json_decode(file_get_contents( |
|
34 | 3 | sprintf(__DIR__.'/../../tests/Command/data/%s', $filename) |
|
35 | )); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @param InputInterface $input |
||
40 | * |
||
41 | * @return string|null|array |
||
0 ignored issues
–
show
|
|||
42 | */ |
||
43 | 7 | protected function getContent(InputInterface $input) |
|
44 | { |
||
45 | 7 | switch ($input->getArgument('test')) { |
|
46 | 7 | case 'json': |
|
47 | 2 | return $this->getTestContent( |
|
48 | 2 | 'tweets_32_bits.json'); |
|
49 | 5 | case 'json_with_retweet': |
|
50 | 1 | return $this->getTestContent( |
|
51 | 1 | 'tweet_with_retweet.json'); |
|
52 | 4 | case 'not_array': |
|
53 | // Return null instead of JSON |
||
54 | 1 | return; |
|
55 | 3 | case 'empty_array': |
|
56 | // Return an empty array instead of JSON |
||
57 | 2 | return []; |
|
58 | default: |
||
59 | // Normal behaviour |
||
60 | 1 | return parent::getContent($input); |
|
61 | } |
||
62 | } |
||
63 | } |
||
64 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.