Passed
Push — master ( 782005...8964b9 )
by MusikAnimal
06:51
created

EditCounterController::rightschangesAction()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 23
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 14
nc 3
nop 1
dl 0
loc 23
ccs 0
cts 0
cp 0
crap 12
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
     */
55
    protected function setUpEditCounter(Request $request, $key = null)
56
    {
57
        // Return the EditCounter if we already have one.
58
        if ($this->editCounter instanceof EditCounter) {
0 ignored issues
show
introduced by
$this->editCounter is always a sub-type of Xtools\EditCounter.
Loading history...
59
            return;
60
        }
61
62
        // Validate key if attempted to make internal API request.
63
        if ($key && (string)$key !== (string)$this->container->getParameter('secret')) {
64
            throw $this->createAccessDeniedException('This endpoint is for internal use only.');
65
        }
66
67
        // Will redirect to Simple Edit Counter if they have too many edits.
68
        $ret = $this->validateProjectAndUser($request, 'SimpleEditCounterResult');
69
        if ($ret instanceof RedirectResponse) {
70
            return $ret;
71
        } else {
72
            // Get Project and User instances.
73
            list($this->project, $this->user) = $ret;
74
        }
75
76
        // Instantiate EditCounter.
77
        $editCounterRepo = new EditCounterRepository();
78
        $editCounterRepo->setContainer($this->container);
79
        $this->editCounter = new EditCounter($this->project, $this->user);
80
        $this->editCounter->setRepository($editCounterRepo);
81
        $this->editCounter->setI18nHelper(
82
            $this->container->get('app.i18n_helper')
83
        );
84
    }
85
86
    /**
87
     * The initial GET request that displays the search form.
88
     *
89
     * @Route("/ec", name="ec")
90
     * @Route("/ec", name="EditCounter")
91
     * @Route("/ec/", name="EditCounterSlash")
92
     * @Route("/ec/index.php", name="EditCounterIndexPhp")
93
     * @Route("/ec/{project}", name="EditCounterProject")
94
     *
95
     * @param Request $request
96
     * @return RedirectResponse|Response
97
     */
98 1
    public function indexAction(Request $request)
99
    {
100 1
        $params = $this->parseQueryParams($request);
101
102 1
        if (isset($params['project']) && isset($params['username'])) {
103
            return $this->redirectToRoute('EditCounterResult', $params);
104
        }
105
106
        // Convert the given project (or default project) into a Project instance.
107 1
        $params['project'] = $this->getProjectFromQuery($params);
108
109
        // Otherwise fall through.
110 1
        return $this->render('editCounter/index.html.twig', [
111 1
            'xtPageTitle' => 'tool-ec',
112 1
            'xtSubtitle' => 'tool-ec-desc',
113 1
            'xtPage' => 'ec',
114 1
            'project' => $params['project'],
115
        ]);
116
    }
117
118
    /**
119
     * Display all results.
120
     * @Route("/ec/{project}/{username}", name="EditCounterResult")
121
     * @param Request $request
122
     * @param string $project
123
     * @param string $username
124
     * @return Response
125
     * @codeCoverageIgnore
126
     */
127
    public function resultAction(Request $request, $project, $username)
0 ignored issues
show
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

127
    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...
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

127
    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...
128
    {
129
        $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...
130
        if ($ret instanceof RedirectResponse) {
131
            return $ret;
132
        }
133
134
        // Asynchronously collect some of the data that will be shown.
135
        // If multithreading is turned off, the normal getters in the views will
136
        // collect the necessary data synchronously.
137
        if ($this->container->getParameter('app.multithread')) {
138
            $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

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