Passed
Push — master ( 4a4466...1554de )
by Mauro
03:16
created

src/Controller/Task/CreateTask.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

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 App\Controller\Task;
4
5
use Slim\Http\Request;
6
use Slim\Http\Response;
7
8
/**
9
 * Create Task Controller.
10
 */
11 View Code Duplication
class CreateTask extends BaseTask
12
{
13
    /**
14
     * Create a task.
15
     *
16
     * @param Request $request
17
     * @param Response $response
18
     * @param array $args
19
     * @return Response
20
     */
21
    public function __invoke($request, $response, $args)
22
    {
23
        $this->setParams($request, $response, $args);
24
        $input = $this->getInput();
25
        $result = $this->getTaskService()->createTask($input);
0 ignored issues
show
It seems like $input defined by $this->getInput() on line 24 can also be of type null or object; however, App\Service\TaskService::createTask() does only seem to accept array, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
26
27
        return $this->jsonResponse('success', $result, 201);
28
    }
29
}
30