Issues (51)

src/Traits/LocaleScopes.php (6 issues)

1
<?php
2
3
namespace Fomvasss\UrlAliases\Traits;
4
5
trait LocaleScopes
6
{
7
8
    /**
9
     * @param $query
10
     * @param null $locale
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $locale is correct as it would always require null to be passed?
Loading history...
11
     * @return mixed
12
     */
13
    public function scopeByLocale($query, $locale = null)
14
    {
15
        $locale = $locale ?: \UrlAliasLocalization::getCurrentLocale();
0 ignored issues
show
The type UrlAliasLocalization 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...
$locale is of type null, thus it always evaluated to false.
Loading history...
16
17
        return $query->whereLocale($locale)
18
            ->orWhereNull('locale');
19
    }
20
21
22
    /**
23
     * @param $query
24
     * @param null $locales
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $locales is correct as it would always require null to be passed?
Loading history...
25
     * @return mixed
26
     */
27
    public function scopeByLocales($query, $locales = null)
28
    {
29
        $locales = $locales ?: session('app_locales');
0 ignored issues
show
The function session 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
        $locales = $locales ?: /** @scrutinizer ignore-call */ session('app_locales');
Loading history...
$locales is of type null, thus it always evaluated to false.
Loading history...
30
31
        if ($locales) {
32
            return $query->whereIn('locale', is_array($locales) ? $locales : [$locales])
33
                ->orWhereNull('locale');
34
        }
35
    }
36
}