GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AbstractFormHandler   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 62
rs 10
c 0
b 0
f 0
wmc 11

4 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 3 1
B handle() 0 31 8
A preProcess() 0 3 1
A postProcess() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Core23\Form\Handler;
13
14
use Core23\Form\Handler\Exception\InvalidCallbackException;
15
use Symfony\Component\Form\FormInterface;
16
use Symfony\Component\HttpFoundation\Request;
17
use Symfony\Component\HttpFoundation\Response;
18
19
abstract class AbstractFormHandler implements FormHandlerInterface
20
{
21
    final public function handle(FormInterface $form, Request $request, callable $callback): ?Response
22
    {
23
        if (null !== $response = $this->preProcess($form, $request)) {
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $response is correct as $this->preProcess($form, $request) targeting Core23\Form\Handler\Abst...rmHandler::preProcess() 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...
introduced by
The condition null !== $response = $th...rocess($form, $request) is always false.
Loading history...
24
            return $response;
25
        }
26
27
        $form->handleRequest($request);
28
29
        if (!$form->isSubmitted() || !$form->isValid()) {
30
            return null;
31
        }
32
33
        if (null !== $response = $this->validate($form, $request)) {
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $response is correct as $this->validate($form, $request) targeting Core23\Form\Handler\Abst...FormHandler::validate() 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...
introduced by
The condition null !== $response = $th...lidate($form, $request) is always false.
Loading history...
34
            return $response;
35
        }
36
37
        if (!$this->process($form, $request)) {
38
            return null;
39
        }
40
41
        $response = $callback();
42
43
        if (!$response instanceof Response) {
44
            throw new InvalidCallbackException('Invalid callback response.');
45
        }
46
47
        if (null !== $response = $this->postProcess($form, $request, $response)) {
48
            return $response;
49
        }
50
51
        return null;
52
    }
53
54
    /**
55
     * Executes before form validating and processing is started.
56
     */
57
    protected function preProcess(FormInterface $form, Request $request): ?Response
58
    {
59
        return null;
60
    }
61
62
    /**
63
     * Executes after preprocessing and before form processing is started.
64
     */
65
    protected function validate(FormInterface $form, Request $request): ?Response
0 ignored issues
show
Unused Code introduced by
The parameter $form 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

65
    protected function validate(/** @scrutinizer ignore-unused */ FormInterface $form, Request $request): ?Response

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 $request 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

65
    protected function validate(FormInterface $form, /** @scrutinizer ignore-unused */ Request $request): ?Response

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...
66
    {
67
        return null;
68
    }
69
70
    /**
71
     * Executes the form processing.
72
     */
73
    abstract protected function process(FormInterface $form, Request $request): bool;
74
75
    /**
76
     * Executes after form processing is finished and filters response.
77
     */
78
    protected function postProcess(FormInterface $form, Request $request, Response $response): ?Response
79
    {
80
        return $response;
81
    }
82
}
83