Passed
Push — master ( 35c320...7deb12 )
by MusikAnimal
04:42
created

EditCounterController   B

Complexity

Total Complexity 38

Size/Duplication

Total Lines 445
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
dl 0
loc 445
ccs 9
cts 10
cp 0.9
rs 8.3999
c 0
b 0
f 0
wmc 38

16 Methods

Rating   Name   Duplication   Size   Complexity  
A monthcountsApiAction() 0 10 2
A namespaceTotalsApiAction() 0 10 2
A pairDataApiAction() 0 10 2
A yearcountsAction() 0 19 2
A generalStatsAction() 0 19 2
A latestglobalAction() 0 16 3
A namespaceTotalsAction() 0 19 2
B timecardAction() 0 24 2
A rightschangesAction() 0 23 3
A indexAction() 0 17 3
A logCountsApiAction() 0 10 2
A editSizesApiAction() 0 10 2
A monthcountsAction() 0 23 2
A resultAction() 0 22 3
B setUpEditCounter() 0 30 5
A getIndexRoute() 0 3 1
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 name of the tool's index route.
39
     * This is also the name of the associated model.
40
     * @return string
41
     * @codeCoverageIgnore
42
     */
43
    public function getIndexRoute()
44
    {
45
        return 'EditCounter';
46
    }
47
48
    /**
49
     * Every action in this controller (other than 'index') calls this first.
50
     * If a response is returned, the calling action is expected to return it.
51
     * @param Request $request
52
     * @param string $key API key, as given in the reuqest. Omit this for actions
53
     *   that are public (only /api/ec actions should pass this in).
54
     * @return null|RedirectResponse
55
     * @codeCoverageIgnore
56
     */
57
    protected function setUpEditCounter(Request $request, $key = null)
58
    {
59
        // Return the EditCounter if we already have one.
60
        if ($this->editCounter instanceof EditCounter) {
0 ignored issues
show
introduced by
$this->editCounter is always a sub-type of Xtools\EditCounter.
Loading history...
61
            return;
62
        }
63
64
        // Validate key if attempted to make internal API request.
65
        if ($key && (string)$key !== (string)$this->container->getParameter('secret')) {
66
            throw $this->createAccessDeniedException('This endpoint is for internal use only.');
67
        }
68
69
        // Will redirect to Simple Edit Counter if they have too many edits.
70
        $ret = $this->validateProjectAndUser($request, 'SimpleEditCounterResult');
71
        if ($ret instanceof RedirectResponse) {
72
            return $ret;
73
        } else {
74
            // Get Project and User instances.
75
            list($this->project, $this->user) = $ret;
76
        }
77
78
        // Instantiate EditCounter.
79
        $editCounterRepo = new EditCounterRepository();
80
        $editCounterRepo->setContainer($this->container);
81
        $this->editCounter = new EditCounter(
82
            $this->project,
83
            $this->user,
84
            $this->container->get('app.i18n_helper')
85
        );
86
        $this->editCounter->setRepository($editCounterRepo);
87
    }
88
89
    /**
90
     * The initial GET request that displays the search form.
91
     *
92
     * @Route("/ec", name="EditCounter")
93
     * @Route("/ec/", name="EditCounterSlash")
94
     * @Route("/ec/index.php", name="EditCounterIndexPhp")
95
     * @Route("/ec/{project}", name="EditCounterProject")
96
     *
97
     * @param Request $request
98
     * @return RedirectResponse|Response
99
     */
100 1
    public function indexAction(Request $request)
101
    {
102 1
        $params = $this->parseQueryParams($request);
103
104 1
        if (isset($params['project']) && isset($params['username'])) {
105
            return $this->redirectToRoute('EditCounterResult', $params);
106
        }
107
108
        // Convert the given project (or default project) into a Project instance.
109 1
        $params['project'] = $this->getProjectFromQuery($params);
110
111
        // Otherwise fall through.
112 1
        return $this->render('editCounter/index.html.twig', [
113 1
            'xtPageTitle' => 'tool-editcounter',
114 1
            'xtSubtitle' => 'tool-editcounter-desc',
115 1
            'xtPage' => 'editcounter',
116 1
            'project' => $params['project'],
117
        ]);
118
    }
119
120
    /**
121
     * Display all results.
122
     * @Route("/ec/{project}/{username}", name="EditCounterResult")
123
     * @param Request $request
124
     * @param string $project
125
     * @param string $username
126
     * @return Response
127
     * @codeCoverageIgnore
128
     */
129
    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

129
    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

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