Issues (652)

app/Providers/RouteServiceProvider.php (4 issues)

1
<?php
2
3
namespace Uccello\Core\Providers;
4
5
use App\Providers\RouteServiceProvider as DefaultRouteServiceProvider;
0 ignored issues
show
The type App\Providers\RouteServiceProvider 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 Illuminate\Support\Facades\Route;
7
use Uccello\Core\Models\Domain;
8
use Uccello\Core\Models\Module;
9
10
/**
11
 * Route Service Provider
12
 */
13
class RouteServiceProvider extends DefaultRouteServiceProvider
14
{
15
    /**
16
     * @inheritDoc
17
     */
18
    public function boot()
19
    {
20
        parent::boot();
21
22
        // Bind domain
23
        Route::bind('domain', function ($value) {
24
            if (preg_match('`^[0-9]+$`', $value)) { // By id
25
                $domain = Domain::findOrFail($value);
26
            } else { // By slug
27
                $domain = Domain::where('slug', $value)->first() ?? abort(404);
0 ignored issues
show
Are you sure the usage of abort(404) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
28
            }
29
            return $domain;
30
        });
31
32
        // Bind module
33
        Route::bind('module', function ($value) {
34
            if (preg_match('`^[0-9]+$`', $value)) { // By id
35
                $module = Module::findOrFail($value);
36
            } else { // By name
37
                $module = Module::where('name', $value)->first() ?? abort(404);
0 ignored issues
show
Are you sure the usage of abort(404) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
38
            }
39
            return $module;
40
        });
41
    }
42
43
    /**
44
     * @inheritDoc
45
     */
46
    public function map()
47
    {
48
        parent::map();
49
50
        $this->mapUccelloRoutes();
51
    }
52
53
    /**
54
     * Define "uccello" routes for the application.
55
     *
56
     * @return void
57
     */
58
    protected function mapUccelloRoutes()
59
    {
60
        // Web
61
        Route::middleware('web', 'auth')
0 ignored issues
show
The call to Illuminate\Support\Facades\Route::middleware() has too many arguments starting with 'auth'. ( Ignorable by Annotation )

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

61
        Route::/** @scrutinizer ignore-call */ 
62
               middleware('web', 'auth')

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...
62
            ->namespace('Uccello\Core\Http\Controllers') // We prefer to do this instead of modifying $this->namespace, else LoginController is not find
63
            ->group(__DIR__.'/../../routes/web.php');
64
    }
65
}