Passed
Push — master ( 4ac0e3...997f64 )
by MusikAnimal
07:16
created

EditCounterController::monthcountsAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 23
ccs 0
cts 0
cp 0
crap 6
rs 9.552
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file contains only the EditCounterController class.
4
 */
5
6
namespace AppBundle\Controller;
7
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9
use Symfony\Component\HttpFoundation\JsonResponse;
10
use Symfony\Component\HttpFoundation\RedirectResponse;
11
use Symfony\Component\HttpFoundation\Request;
12
use Symfony\Component\HttpFoundation\Response;
13
use Xtools\EditCounter;
14
use Xtools\EditCounterRepository;
15
use Xtools\Project;
16
use Xtools\ProjectRepository;
17
use Xtools\User;
18
19
/**
20
 * Class EditCounterController
21
 */
22
class EditCounterController extends XtoolsController
23
{
24
25
    /** @var User The user being queried. */
26
    protected $user;
27
28
    /** @var Project The project being queried. */
29
    protected $project;
30
31
    /** @var EditCounter The edit-counter, that does all the work. */
32
    protected $editCounter;
33
34
    /**
35
     * Get the name of the tool's index route.
36
     * This is also the name of the associated model.
37
     * @return string
38
     * @codeCoverageIgnore
39
     */
40
    public function getIndexRoute()
41
    {
42
        return 'EditCounter';
43
    }
44
45
    /**
46
     * Every action in this controller (other than 'index') calls this first.
47
     * If a response is returned, the calling action is expected to return it.
48
     * @param Request $request
49
     * @param string $key API key, as given in the request. Omit this for actions
50
     *   that are public (only /api/ec actions should pass this in).
51
     * @param bool $tooHighEditCount Whether to redirect if the user has too high of an edit count.
52
     * @return RedirectResponse|null
53
     * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException If accessing internal endpoint.
54
     * @codeCoverageIgnore
55
     */
56
    protected function setUpEditCounter(Request $request, $key = null, $tooHighEditCount = true)
57
    {
58
        // Return the EditCounter if we already have one.
59
        if ($this->editCounter instanceof EditCounter) {
0 ignored issues
show
introduced by
$this->editCounter is always a sub-type of Xtools\EditCounter. If $this->editCounter can have other possible types, add them to src/AppBundle/Controller/EditCounterController.php:31.
Loading history...
60
            return null;
61
        }
62
63
        // Validate key if attempted to make internal API request.
64
        if ($key && (string)$key !== (string)$this->container->getParameter('secret')) {
65
            throw $this->createAccessDeniedException('This endpoint is for internal use only.');
66
        }
67
68
        // Will redirect to Simple Edit Counter if they have too many edits.
69
        $ret = $this->validateProjectAndUser($request, $tooHighEditCount ? 'SimpleEditCounterResult' : null);
70
        if ($ret instanceof RedirectResponse) {
71
            return $ret;
72
        } else {
73
            // Get Project and User instances.
74
            list($this->project, $this->user) = $ret;
75
        }
76
77
        // Instantiate EditCounter.
78
        $editCounterRepo = new EditCounterRepository();
79
        $editCounterRepo->setContainer($this->container);
80
        $this->editCounter = new EditCounter(
81
            $this->project,
82
            $this->user,
83
            $this->container->get('app.i18n_helper')
84
        );
85
        $this->editCounter->setRepository($editCounterRepo);
86
    }
87
88
    /**
89
     * The initial GET request that displays the search form.
90
     *
91
     * @Route("/ec", name="EditCounter")
92
     * @Route("/ec/", name="EditCounterSlash")
93
     * @Route("/ec/index.php", name="EditCounterIndexPhp")
94
     * @Route("/ec/{project}", name="EditCounterProject")
95
     *
96
     * @param Request $request
97
     * @return RedirectResponse|Response
98
     */
99 1
    public function indexAction(Request $request)
100
    {
101 1
        $params = $this->parseQueryParams($request);
102
103 1
        if (isset($params['project']) && isset($params['username'])) {
104
            return $this->redirectToRoute('EditCounterResult', $params);
105
        }
106
107
        // Convert the given project (or default project) into a Project instance.
108 1
        $params['project'] = $this->getProjectFromQuery($params);
109
110
        // Otherwise fall through.
111 1
        return $this->render('editCounter/index.html.twig', [
112 1
            'xtPageTitle' => 'tool-editcounter',
113 1
            'xtSubtitle' => 'tool-editcounter-desc',
114 1
            'xtPage' => 'editcounter',
115 1
            'project' => $params['project'],
116
        ]);
117
    }
118
119
    /**
120
     * Display all results.
121
     * @Route("/ec/{project}/{username}", name="EditCounterResult")
122
     * @param Request $request
123
     * @param string $project
124
     * @param string $username
125
     * @return Response
126
     * @codeCoverageIgnore
127
     */
128
    public function resultAction(Request $request, $project, $username)
0 ignored issues
show
Unused Code introduced by
The parameter $username is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

128
    public function resultAction(Request $request, $project, /** @scrutinizer ignore-unused */ $username)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $project is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

128
    public function resultAction(Request $request, /** @scrutinizer ignore-unused */ $project, $username)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
129
    {
130
        $ret = $this->setUpEditCounter($request);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $ret is correct as $this->setUpEditCounter($request) targeting AppBundle\Controller\Edi...ler::setUpEditCounter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
131
        if ($ret instanceof RedirectResponse) {
132
            return $ret;
133
        }
134
135
        $ret = [
136
            'xtTitle' => $this->user->getUsername() . ' - ' . $this->project->getTitle(),
137
            'xtPage' => 'editcounter',
138
            'user' => $this->user,
139
            'project' => $this->project,
140
            'ec' => $this->editCounter,
141
        ];
142
143
        // Used when querying for global rights changes.
144
        if ((bool)$this->container->hasParameter('app.is_labs')) {
145
            $ret['metaProject'] = ProjectRepository::getProject('metawiki', $this->container);
146
        }
147
148
        // Output the relevant format template.
149
        return $this->getFormattedResponse($request, 'editCounter/result', $ret);
150
    }
151
152
    /**
153
     * Display the general statistics section.
154
     * @Route("/ec-generalstats/{project}/{username}", name="EditCounterGeneralStats")
155
     * @param Request $request
156
     * @return Response
157
     * @codeCoverageIgnore
158
     */
159
    public function generalStatsAction(Request $request)
160
    {
161
        $ret = $this->setUpEditCounter($request);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $ret is correct as $this->setUpEditCounter($request) targeting AppBundle\Controller\Edi...ler::setUpEditCounter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
162
        if ($ret instanceof RedirectResponse) {
163
            return $ret;
164
        }
165
166
        $isSubRequest = $this->get('request_stack')->getParentRequest() !== null;
167
        $ret = [
168
            'xtTitle' => $this->user->getUsername(),
169
            'xtPage' => 'editcounter',
170
            'is_sub_request' => $isSubRequest,
171
            'user' => $this->user,
172
            'project' => $this->project,
173
            'ec' => $this->editCounter,
174
        ];
175
176
        // Output the relevant format template.
177
        return $this->getFormattedResponse($request, 'editCounter/general_stats', $ret);
178
    }
179
180
    /**
181
     * Display the namespace totals section.
182
     * @Route("/ec-namespacetotals/{project}/{username}", name="EditCounterNamespaceTotals")
183
     * @param Request $request
184
     * @return Response
185
     * @codeCoverageIgnore
186
     */
187
    public function namespaceTotalsAction(Request $request)
188
    {
189
        $ret = $this->setUpEditCounter($request);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $ret is correct as $this->setUpEditCounter($request) targeting AppBundle\Controller\Edi...ler::setUpEditCounter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
190
        if ($ret instanceof RedirectResponse) {
191
            return $ret;
192
        }
193
194
        $isSubRequest = $this->get('request_stack')->getParentRequest() !== null;
195
        $ret = [
196
            'xtTitle' => $this->user->getUsername(),
197
            'xtPage' => 'editcounter',
198
            'is_sub_request' => $isSubRequest,
199
            'user' => $this->user,
200
            'project' => $this->project,
201
            'ec' => $this->editCounter,
202
        ];
203
204
        // Output the relevant format template.
205
        return $this->getFormattedResponse($request, 'editCounter/namespace_totals', $ret);
206
    }
207
208
    /**
209
     * Display the timecard section.
210
     * @Route("/ec-timecard/{project}/{username}", name="EditCounterTimecard")
211
     * @param Request $request
212
     * @return Response
213
     * @codeCoverageIgnore
214
     */
215
    public function timecardAction(Request $request)
216
    {
217
        $ret = $this->setUpEditCounter($request);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $ret is correct as $this->setUpEditCounter($request) targeting AppBundle\Controller\Edi...ler::setUpEditCounter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
218
        if ($ret instanceof RedirectResponse) {
219
            return $ret;
220
        }
221
222
        $isSubRequest = $this->get('request_stack')->getParentRequest() !== null;
223
        $optedInPage = $this->project
224
            ->getRepository()
225
            ->getPage($this->project, $this->project->userOptInPage($this->user));
226
227
        $ret = [
228
            'xtTitle' => $this->user->getUsername(),
229
            'xtPage' => 'editcounter',
230
            'is_sub_request' => $isSubRequest,
231
            'user' => $this->user,
232
            'project' => $this->project,
233
            'ec' => $this->editCounter,
234
            'opted_in_page' => $optedInPage,
235
        ];
236
237
        // Output the relevant format template.
238
        return $this->getFormattedResponse($request, 'editCounter/timecard', $ret);
239
    }
240
241
    /**
242
     * Display the year counts section.
243
     * @Route("/ec-yearcounts/{project}/{username}", name="EditCounterYearCounts")
244
     * @param Request $request
245
     * @return Response
246
     * @codeCoverageIgnore
247
     */
248
    public function yearcountsAction(Request $request)
249
    {
250
        $ret = $this->setUpEditCounter($request);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $ret is correct as $this->setUpEditCounter($request) targeting AppBundle\Controller\Edi...ler::setUpEditCounter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
251
        if ($ret instanceof RedirectResponse) {
252
            return $ret;
253
        }
254
255
        $isSubRequest = $this->container->get('request_stack')->getParentRequest() !== null;
256
        $ret = [
257
            'xtTitle' => $this->user->getUsername(),
258
            'xtPage' => 'editcounter',
259
            'is_sub_request' => $isSubRequest,
260
            'user' => $this->user,
261
            'project' => $this->project,
262
            'ec' => $this->editCounter,
263
        ];
264
265
        // Output the relevant format template.
266
        return $this->getFormattedResponse($request, 'editCounter/yearcounts', $ret);
267
    }
268
269
    /**
270
     * Display the month counts section.
271
     * @Route("/ec-monthcounts/{project}/{username}", name="EditCounterMonthCounts")
272
     * @param Request $request
273
     * @return Response
274
     * @codeCoverageIgnore
275
     */
276
    public function monthcountsAction(Request $request)
277
    {
278
        $ret = $this->setUpEditCounter($request);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $ret is correct as $this->setUpEditCounter($request) targeting AppBundle\Controller\Edi...ler::setUpEditCounter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
279
        if ($ret instanceof RedirectResponse) {
280
            return $ret;
281
        }
282
283
        $isSubRequest = $this->container->get('request_stack')->getParentRequest() !== null;
284
        $optedInPage = $this->project
285
            ->getRepository()
286
            ->getPage($this->project, $this->project->userOptInPage($this->user));
287
        $ret = [
288
            'xtTitle' => $this->user->getUsername(),
289
            'xtPage' => 'editcounter',
290
            'is_sub_request' => $isSubRequest,
291
            'user' => $this->user,
292
            'project' => $this->project,
293
            'ec' => $this->editCounter,
294
            'opted_in_page' => $optedInPage,
295
        ];
296
297
        // Output the relevant format template.
298
        return $this->getFormattedResponse($request, 'editCounter/monthcounts', $ret);
299
    }
300
301
    /**
302
     * Display the user rights changes section.
303
     * @Route("/ec-rightschanges/{project}/{username}", name="EditCounterRightsChanges")
304
     * @param Request $request
305
     * @return Response
306
     * @codeCoverageIgnore
307
     */
308
    public function rightschangesAction(Request $request)
309
    {
310
        $ret = $this->setUpEditCounter($request, null, false);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $ret is correct as $this->setUpEditCounter($request, null, false) targeting AppBundle\Controller\Edi...ler::setUpEditCounter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
311
        if ($ret instanceof RedirectResponse) {
312
            return $ret;
313
        }
314
315
        $isSubRequest = $this->container->get('request_stack')->getParentRequest() !== null;
316
        $ret = [
317
            'xtTitle' => $this->user->getUsername(),
318
            'xtPage' => 'editcounter',
319
            'is_sub_request' => $isSubRequest,
320
            'user' => $this->user,
321
            'project' => $this->project,
322
            'ec' => $this->editCounter,
323
        ];
324
325
        if ((bool)$this->container->hasParameter('app.is_labs')) {
326
            $ret['metaProject'] = ProjectRepository::getProject('metawiki', $this->container);
327
        }
328
329
        // Output the relevant format template.
330
        return $this->getFormattedResponse($request, 'editCounter/rights_changes', $ret);
331
    }
332
333
    /**
334
     * Display the latest global edits section.
335
     * @Route(
336
     *     "/ec-latestglobal-contributions/{project}/{username}/{offset}",
337
     *     name="EditCounterLatestGlobalContribs",
338
     *     requirements={"offset" = "|\d*"},
339
     *     defaults={"offset" = 0}
340
     * )
341
     * @Route(
342
     *     "/ec-latestglobal/{project}/{username}/{offset}",
343
     *     name="EditCounterLatestGlobal",
344
     *     requirements={"offset" = "|\d*"},
345
     *     defaults={"offset" = 0}
346
     * ),
347
     * @param Request $request The HTTP request.
348
     * @return Response
349
     * @codeCoverageIgnore
350
     */
351
    public function latestglobalAction(Request $request)
352
    {
353
        $ret = $this->setUpEditCounter($request);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $ret is correct as $this->setUpEditCounter($request) targeting AppBundle\Controller\Edi...ler::setUpEditCounter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
354
        if ($ret instanceof RedirectResponse) {
355
            return $ret;
356
        }
357
358
        $isSubRequest = $request->get('htmlonly')
359
                        || $this->container->get('request_stack')->getParentRequest() !== null;
360
        return $this->render('editCounter/latest_global.html.twig', [
361
            'xtTitle' => $this->user->getUsername(),
362
            'xtPage' => 'editcounter',
363
            'is_sub_request' => $isSubRequest,
364
            'user' => $this->user,
365
            'project' => $this->project,
366
            'ec' => $this->editCounter,
367
            'offset' => $request->get('offset'),
368
            'pageSize' => $request->get('pagesize'),
369
        ]);
370
    }
371
372
373
    /**
374
     * Below are internal API endpoints for the Edit Counter.
375
     * All only respond with JSON and only to requests passing in the value
376
     * of the 'secret' parameter. This should not be used in JavaScript or clientside
377
     * applications, rather only used internally.
378
     */
379
380
    /**
381
     * Get (most) of the general statistics as JSON.
382
     * @Route("/api/ec/pairdata/{project}/{username}/{key}", name="EditCounterApiPairData")
383
     * @param Request $request
384
     * @param string $key API key.
385
     * @return JsonResponse|RedirectResponse
386
     * @codeCoverageIgnore
387
     */
388
    public function pairDataApiAction(Request $request, $key)
389
    {
390
        $ret = $this->setUpEditCounter($request, $key);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $ret is correct as $this->setUpEditCounter($request, $key) targeting AppBundle\Controller\Edi...ler::setUpEditCounter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
391
        if ($ret instanceof RedirectResponse) {
392
            return $ret;
393
        }
394
395
        return new JsonResponse(
396
            $this->editCounter->getPairData(),
397
            Response::HTTP_OK
398
        );
399
    }
400
401
    /**
402
     * Get various log counts for the user as JSON.
403
     * @Route("/api/ec/logcounts/{project}/{username}/{key}", name="EditCounterApiLogCounts")
404
     * @param Request $request
405
     * @param string $key API key.
406
     * @return JsonResponse|RedirectResponse
407
     * @codeCoverageIgnore
408
     */
409
    public function logCountsApiAction(Request $request, $key)
410
    {
411
        $ret = $this->setUpEditCounter($request, $key);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $ret is correct as $this->setUpEditCounter($request, $key) targeting AppBundle\Controller\Edi...ler::setUpEditCounter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
412
        if ($ret instanceof RedirectResponse) {
413
            return $ret;
414
        }
415
416
        return new JsonResponse(
417
            $this->editCounter->getLogCounts(),
418
            Response::HTTP_OK
419
        );
420
    }
421
422
    /**
423
     * Get edit sizes for the user as JSON.
424
     * @Route("/api/ec/editsizes/{project}/{username}/{key}", name="EditCounterApiEditSizes")
425
     * @param Request $request
426
     * @param string $key API key.
427
     * @return JsonResponse|RedirectResponse
428
     * @codeCoverageIgnore
429
     */
430
    public function editSizesApiAction(Request $request, $key)
431
    {
432
        $ret = $this->setUpEditCounter($request, $key);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $ret is correct as $this->setUpEditCounter($request, $key) targeting AppBundle\Controller\Edi...ler::setUpEditCounter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
433
        if ($ret instanceof RedirectResponse) {
434
            return $ret;
435
        }
436
437
        return new JsonResponse(
438
            $this->editCounter->getEditSizeData(),
439
            Response::HTTP_OK
440
        );
441
    }
442
443
    /**
444
     * Get the namespace totals for the user as JSON.
445
     * @Route("/api/ec/namespacetotals/{project}/{username}/{key}", name="EditCounterApiNamespaceTotals")
446
     * @param Request $request
447
     * @param string $key API key.
448
     * @return Response|RedirectResponse
449
     * @codeCoverageIgnore
450
     */
451
    public function namespaceTotalsApiAction(Request $request, $key)
452
    {
453
        $ret = $this->setUpEditCounter($request, $key);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $ret is correct as $this->setUpEditCounter($request, $key) targeting AppBundle\Controller\Edi...ler::setUpEditCounter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
454
        if ($ret instanceof RedirectResponse) {
455
            return $ret;
456
        }
457
458
        return new JsonResponse(
459
            $this->editCounter->namespaceTotals(),
460
            Response::HTTP_OK
461
        );
462
    }
463
464
    /**
465
     * Display or fetch the month counts for the user.
466
     * @Route("/api/ec/monthcounts/{project}/{username}/{key}", name="EditCounterApiMonthCounts")
467
     * @param Request $request
468
     * @param string $key API key.
469
     * @return Response
470
     * @codeCoverageIgnore
471
     */
472
    public function monthcountsApiAction(Request $request, $key)
473
    {
474
        $ret = $this->setUpEditCounter($request, $key);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $ret is correct as $this->setUpEditCounter($request, $key) targeting AppBundle\Controller\Edi...ler::setUpEditCounter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
475
        if ($ret instanceof RedirectResponse) {
476
            return $ret;
477
        }
478
479
        return new JsonResponse(
480
            $this->editCounter->monthCounts(),
481
            Response::HTTP_OK
482
        );
483
    }
484
}
485