Passed
Push — master ( dad31f...0bbc99 )
by MusikAnimal
06:39 queued 01:28
created

EditCounterController::monthcountsAction()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 16
nc 2
nop 1
dl 0
loc 23
ccs 0
cts 0
cp 0
crap 6
rs 9.0856
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 AppBundle\Helper\I18nHelper;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
10
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
11
use Symfony\Component\HttpFoundation\JsonResponse;
12
use Symfony\Component\HttpFoundation\RedirectResponse;
13
use Symfony\Component\HttpFoundation\Request;
14
use Symfony\Component\HttpFoundation\Response;
15
use Xtools\EditCounter;
16
use Xtools\EditCounterRepository;
17
use Xtools\Page;
18
use Xtools\Project;
19
use Xtools\ProjectRepository;
20
use Xtools\User;
21
22
/**
23
 * Class EditCounterController
24
 */
25
class EditCounterController extends XtoolsController
26
{
27
28
    /** @var User The user being queried. */
29
    protected $user;
30
31
    /** @var Project The project being queried. */
32
    protected $project;
33
34
    /** @var EditCounter The edit-counter, that does all the work. */
35
    protected $editCounter;
36
37
    /**
38
     * Get the tool's shortname.
39
     * @return string
40
     * @codeCoverageIgnore
41
     */
42
    public function getToolShortname()
43
    {
44
        return 'ec';
45
    }
46
47
    /**
48
     * Every action in this controller (other than 'index') calls this first.
49
     * If a response is returned, the calling action is expected to return it.
50
     * @param Request $request
51
     * @param string $key API key, as given in the reuqest. Omit this for actions
52
     *   that are public (only /api/ec actions should pass this in).
53
     * @return null|RedirectResponse
54
     * @codeCoverageIgnore
55
     */
56
    protected function setUpEditCounter(Request $request, $key = null)
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.
Loading history...
60
            return;
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, 'SimpleEditCounterResult');
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($this->project, $this->user);
81
        $this->editCounter->setRepository($editCounterRepo);
82
        $this->editCounter->setI18nHelper(
83
            $this->container->get('app.i18n_helper')
84
        );
85
    }
86
87
    /**
88
     * The initial GET request that displays the search form.
89
     *
90
     * @Route("/ec", name="ec")
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-ec',
113 1
            'xtSubtitle' => 'tool-ec-desc',
114 1
            'xtPage' => 'ec',
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
        // Asynchronously collect some of the data that will be shown.
136
        // If multithreading is turned off, the normal getters in the views will
137
        // collect the necessary data synchronously.
138
        if ($this->container->getParameter('app.multithread')) {
139
            $this->editCounter->prepareData($this->container);
0 ignored issues
show
Unused Code introduced by
The call to Xtools\EditCounter::prepareData() has too many arguments starting with $this->container. ( Ignorable by Annotation )

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

139
            $this->editCounter->/** @scrutinizer ignore-call */ 
140
                                prepareData($this->container);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
140
        }
141
142
        $ret = [
143
            'xtTitle' => $this->user->getUsername() . ' - ' . $this->project->getTitle(),
144
            'xtPage' => 'ec',
145
            'user' => $this->user,
146
            'project' => $this->project,
147
            'ec' => $this->editCounter,
148
        ];
149
150
        // Used when querying for global rights changes.
151
        if ((bool)$this->container->hasParameter('app.is_labs')) {
152
            $ret['metaProject'] = ProjectRepository::getProject('metawiki', $this->container);
153
        }
154
155
        // Output the relevant format template.
156
        return $this->getFormattedReponse($request, 'editCounter/result', $ret);
157
    }
158
159
    /**
160
     * Display the general statistics section.
161
     * @Route("/ec-generalstats/{project}/{username}", name="EditCounterGeneralStats")
162
     * @param Request $request
163
     * @return Response
164
     * @codeCoverageIgnore
165
     */
166
    public function generalStatsAction(Request $request)
167
    {
168
        $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...
169
        if ($ret instanceof RedirectResponse) {
170
            return $ret;
171
        }
172
173
        $isSubRequest = $this->get('request_stack')->getParentRequest() !== null;
174
        $ret = [
175
            'xtTitle' => $this->user->getUsername(),
176
            'xtPage' => 'ec',
177
            'is_sub_request' => $isSubRequest,
178
            'user' => $this->user,
179
            'project' => $this->project,
180
            'ec' => $this->editCounter,
181
        ];
182
183
        // Output the relevant format template.
184
        return $this->getFormattedReponse($request, 'editCounter/general_stats', $ret);
185
    }
186
187
    /**
188
     * Display the namespace totals section.
189
     * @Route("/ec-namespacetotals/{project}/{username}", name="EditCounterNamespaceTotals")
190
     * @param Request $request
191
     * @return Response
192
     * @codeCoverageIgnore
193
     */
194
    public function namespaceTotalsAction(Request $request)
195
    {
196
        $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...
197
        if ($ret instanceof RedirectResponse) {
198
            return $ret;
199
        }
200
201
        $isSubRequest = $this->get('request_stack')->getParentRequest() !== null;
202
        $ret = [
203
            'xtTitle' => $this->user->getUsername(),
204
            'xtPage' => 'ec',
205
            'is_sub_request' => $isSubRequest,
206
            'user' => $this->user,
207
            'project' => $this->project,
208
            'ec' => $this->editCounter,
209
        ];
210
211
        // Output the relevant format template.
212
        return $this->getFormattedReponse($request, 'editCounter/namespace_totals', $ret);
213
    }
214
215
    /**
216
     * Display the timecard section.
217
     * @Route("/ec-timecard/{project}/{username}", name="EditCounterTimecard")
218
     * @param Request $request
219
     * @return Response
220
     * @codeCoverageIgnore
221
     */
222
    public function timecardAction(Request $request)
223
    {
224
        $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...
225
        if ($ret instanceof RedirectResponse) {
226
            return $ret;
227
        }
228
229
        $isSubRequest = $this->get('request_stack')->getParentRequest() !== null;
230
        $optedInPage = $this->project
231
            ->getRepository()
232
            ->getPage($this->project, $this->project->userOptInPage($this->user));
233
234
        $ret = [
235
            'xtTitle' => $this->user->getUsername(),
236
            'xtPage' => 'ec',
237
            'is_sub_request' => $isSubRequest,
238
            'user' => $this->user,
239
            'project' => $this->project,
240
            'ec' => $this->editCounter,
241
            'opted_in_page' => $optedInPage,
242
        ];
243
244
        // Output the relevant format template.
245
        return $this->getFormattedReponse($request, 'editCounter/timecard', $ret);
246
    }
247
248
    /**
249
     * Display the year counts section.
250
     * @Route("/ec-yearcounts/{project}/{username}", name="EditCounterYearCounts")
251
     * @param Request $request
252
     * @return Response
253
     * @codeCoverageIgnore
254
     */
255
    public function yearcountsAction(Request $request)
256
    {
257
        $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...
258
        if ($ret instanceof RedirectResponse) {
259
            return $ret;
260
        }
261
262
        $isSubRequest = $this->container->get('request_stack')->getParentRequest() !== null;
263
        $ret = [
264
            'xtTitle' => $this->user->getUsername(),
265
            'xtPage' => 'ec',
266
            'is_sub_request' => $isSubRequest,
267
            'user' => $this->user,
268
            'project' => $this->project,
269
            'ec' => $this->editCounter,
270
        ];
271
272
        // Output the relevant format template.
273
        return $this->getFormattedReponse($request, 'editCounter/yearcounts', $ret);
274
    }
275
276
    /**
277
     * Display the month counts section.
278
     * @Route("/ec-monthcounts/{project}/{username}", name="EditCounterMonthCounts")
279
     * @param Request $request
280
     * @return Response
281
     * @codeCoverageIgnore
282
     */
283
    public function monthcountsAction(Request $request)
284
    {
285
        $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...
286
        if ($ret instanceof RedirectResponse) {
287
            return $ret;
288
        }
289
290
        $isSubRequest = $this->container->get('request_stack')->getParentRequest() !== null;
291
        $optedInPage = $this->project
292
            ->getRepository()
293
            ->getPage($this->project, $this->project->userOptInPage($this->user));
294
        $ret = [
295
            'xtTitle' => $this->user->getUsername(),
296
            'xtPage' => 'ec',
297
            'is_sub_request' => $isSubRequest,
298
            'user' => $this->user,
299
            'project' => $this->project,
300
            'ec' => $this->editCounter,
301
            'opted_in_page' => $optedInPage,
302
        ];
303
304
        // Output the relevant format template.
305
        return $this->getFormattedReponse($request, 'editCounter/monthcounts', $ret);
306
    }
307
308
    /**
309
     * Display the user rights changes section.
310
     * @Route("/ec-rightschanges/{project}/{username}", name="EditCounterRightsChanges")
311
     * @param Request $request
312
     * @return Response
313
     * @codeCoverageIgnore
314
     */
315
    public function rightschangesAction(Request $request)
316
    {
317
        $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...
318
        if ($ret instanceof RedirectResponse) {
319
            return $ret;
320
        }
321
322
        $isSubRequest = $this->container->get('request_stack')->getParentRequest() !== null;
323
        $ret = [
324
            'xtTitle' => $this->user->getUsername(),
325
            'xtPage' => 'ec',
326
            'is_sub_request' => $isSubRequest,
327
            'user' => $this->user,
328
            'project' => $this->project,
329
            'ec' => $this->editCounter,
330
        ];
331
332
        if ((bool)$this->container->hasParameter('app.is_labs')) {
333
            $ret['metaProject'] = ProjectRepository::getProject('metawiki', $this->container);
334
        }
335
336
        // Output the relevant format template.
337
        return $this->getFormattedReponse($request, 'editCounter/rights_changes', $ret);
338
    }
339
340
    /**
341
     * Display the latest global edits section.
342
     * @Route("/ec-latestglobal/{project}/{username}", name="EditCounterLatestGlobal")
343
     * @param Request $request The HTTP request.
344
     * @return Response
345
     * @codeCoverageIgnore
346
     */
347
    public function latestglobalAction(Request $request)
348
    {
349
        $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...
350
        if ($ret instanceof RedirectResponse) {
351
            return $ret;
352
        }
353
354
        $isSubRequest = $request->get('htmlonly')
355
                        || $this->container->get('request_stack')->getParentRequest() !== null;
356
        return $this->render('editCounter/latest_global.html.twig', [
357
            'xtTitle' => $this->user->getUsername(),
358
            'xtPage' => 'ec',
359
            'is_sub_request' => $isSubRequest,
360
            'user' => $this->user,
361
            'project' => $this->project,
362
            'ec' => $this->editCounter,
363
        ]);
364
    }
365
366
367
    /**
368
     * Below are internal API endpoints for the Edit Counter.
369
     * All only respond with JSON and only to requests passing in the value
370
     * of the 'secret' parameter. This should not be used in JavaScript or clientside
371
     * applications, rather only used internally.
372
     */
373
374
    /**
375
     * Get (most) of the general statistics as JSON.
376
     * @Route("/api/ec/pairdata/{project}/{username}/{key}", name="EditCounterApiPairData")
377
     * @param Request $request
378
     * @param string $key API key.
379
     * @return JsonResponse
380
     * @codeCoverageIgnore
381
     */
382
    public function pairDataApiAction(Request $request, $key)
383
    {
384
        $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...
385
        if ($ret instanceof RedirectResponse) {
386
            return $ret;
387
        }
388
389
        return new JsonResponse(
390
            $this->editCounter->getPairData(),
391
            Response::HTTP_OK
392
        );
393
    }
394
395
    /**
396
     * Get various log counts for the user as JSON.
397
     * @Route("/api/ec/logcounts/{project}/{username}/{key}", name="EditCounterApiLogCounts")
398
     * @param Request $request
399
     * @param string $key API key.
400
     * @return JsonResponse
401
     * @codeCoverageIgnore
402
     */
403
    public function logCountsApiAction(Request $request, $key)
404
    {
405
        $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...
406
        if ($ret instanceof RedirectResponse) {
407
            return $ret;
408
        }
409
410
        return new JsonResponse(
411
            $this->editCounter->getLogCounts(),
412
            Response::HTTP_OK
413
        );
414
    }
415
416
    /**
417
     * Get edit sizes for the user as JSON.
418
     * @Route("/api/ec/editsizes/{project}/{username}/{key}", name="EditCounterApiEditSizes")
419
     * @param Request $request
420
     * @param string $key API key.
421
     * @return JsonResponse
422
     * @codeCoverageIgnore
423
     */
424
    public function editSizesApiAction(Request $request, $key)
425
    {
426
        $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...
427
        if ($ret instanceof RedirectResponse) {
428
            return $ret;
429
        }
430
431
        return new JsonResponse(
432
            $this->editCounter->getEditSizeData(),
433
            Response::HTTP_OK
434
        );
435
    }
436
437
    /**
438
     * Get the namespace totals for the user as JSON.
439
     * @Route("/api/ec/namespacetotals/{project}/{username}/{key}", name="EditCounterApiNamespaceTotals")
440
     * @param Request $request
441
     * @param string $key API key.
442
     * @return Response
443
     * @codeCoverageIgnore
444
     */
445
    public function namespaceTotalsApiAction(Request $request, $key)
446
    {
447
        $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...
448
        if ($ret instanceof RedirectResponse) {
449
            return $ret;
450
        }
451
452
        return new JsonResponse(
453
            $this->editCounter->namespaceTotals(),
454
            Response::HTTP_OK
455
        );
456
    }
457
458
    /**
459
     * Display or fetch the month counts for the user.
460
     * @Route("/api/ec/monthcounts/{project}/{username}/{key}", name="EditCounterApiMonthCounts")
461
     * @param Request $request
462
     * @param string $key API key.
463
     * @return Response
464
     * @codeCoverageIgnore
465
     */
466
    public function monthcountsApiAction(Request $request, $key)
467
    {
468
        $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...
469
        if ($ret instanceof RedirectResponse) {
470
            return $ret;
471
        }
472
473
        return new JsonResponse(
474
            $this->editCounter->monthCounts(),
475
            Response::HTTP_OK
476
        );
477
    }
478
}
479