Passed
Push — master ( 7c331b...3c78de )
by Jonathan
18:06
created

EditController::configTree()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Uccello\Core\Http\Controllers\Domain;
4
5
use Illuminate\Http\Request;
0 ignored issues
show
Bug introduced by
The type Illuminate\Http\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Uccello\Core\Http\Controllers\Core\EditController as CoreEditController;
7
use Uccello\Core\Models\Domain;
8
use Uccello\Core\Models\Module;
9
10
class EditController extends CoreEditController
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function save(?Domain $domain, Module $module, Request $request, bool $redirect = true)
16
    {
17
        // Default behaviour without redirection
18
        $record = parent::save($domain, $module, $request, false); // Get a fresh version of $record, after saving
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $record is correct as parent::save($domain, $module, $request, false) targeting Uccello\Core\Http\Contro...\EditController::save() 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...
19
20
        // Update current domain if we are editing it (data could have been changed)
21
        if ($this->domain->getKey() === $record->getKey()) {
22
            $this->domain = $record;
0 ignored issues
show
Documentation Bug introduced by
It seems like $record of type void is incompatible with the declared type Uccello\Core\Models\Domain of property $domain.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
23
        }
24
25
        // Redirect to detail view (we use $this->domain instead of $domain because slug could have been changed)
26
        if ($redirect === true) {
27
            $route = ucroute('uccello.detail', $this->domain, $module, [ 'id' => $record->getKey() ]);
28
29
            return redirect($route);
0 ignored issues
show
Bug introduced by
The function redirect was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

29
            return /** @scrutinizer ignore-call */ redirect($route);
Loading history...
30
        }
31
    }
32
}
33