Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

Apps/View/Admin/default/main/search.php (3 issues)

1
<?php
2
3
use Ffcms\Templex\Url\Url;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Url. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
4
5
/** @var \Ffcms\Templex\Template\Template $this */
6
/** @var \Apps\Model\Admin\Main\CollectionSearchResults $model */
7
8
$query = $this->e($model->getQuery());
9
10
$this->layout('_layouts/default', [
11
    'title' => __('Search: %query%', ['query' => $query]),
12
    'breadcrumbs' => [
13
        Url::to('main/index') => __('Main'),
14
        __('Search')
15
    ],
16
    'query' => $query
17
]);
18
19
?>
20
21
<?php $this->start('body') ?>
22
23
<h1><?= __('Search: %query%', ['query' => $query]) ?></h1>
24
<div class="row">
25
    <div class="col">
26
        <form class="form-inline" method="get" action="<?= Url::link(['main/search']) ?>">
27
            <input type="text" class="form-control col" name="search" placeholder="<?= __('Enter search query') ?>" value="<?= $query ?>">&nbsp;
28
            <input type="submit" name="submit" value="<?= __('Search') ?>" class="btn btn-secondary" />
29
        </form>
30
    </div>
31
</div>
32
33
<?php
34
$result = $model->getRelevanceBasedResult();
0 ignored issues
show
Are you sure the assignment to $result is correct as $model->getRelevanceBasedResult() targeting Apps\Model\Admin\Main\Co...tRelevanceBasedResult() 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...
35
if (!$result || count($result) < 1) {
0 ignored issues
show
$result of type void is incompatible with the type Countable|array expected by parameter $var of count(). ( Ignorable by Annotation )

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

35
if (!$result || count(/** @scrutinizer ignore-type */ $result) < 1) {
Loading history...
36
    echo $this->bootstrap()->alert('warning', __('Nothing found'));
37
    $this->stop();
38
    return;
39
}
40
?>
41
<?php foreach ($result as $item): ?>
42
<?php /** @var \Apps\Model\Admin\Main\AbstractSearchItem $item */ ?>
43
    <div class="row mt-2">
44
        <div class="col-md-12">
45
            <div class="search-result">
46
                <div class="h4">
47
                    <a href="<?= $item->getUrl() ?>">
48
                        <?= $model->highlightText($item->getTitle(), 'span', ['class' => 'search-highlight']) ?>
49
                    </a>
50
                    <span class="badge badge-secondary"><?= $item->getMarker() ?></span>
51
                    <small class="float-right text-secondary"><?= $item->getDate() ?></small>
52
                </div>
53
                <p class="text-muted"><?= $model->highlightText($item->getSnippet(), 'span', ['class' => 'search-highlight']) ?>...</p>
54
            </div>
55
        </div>
56
    </div>
57
    <hr class="mt-0 pt-0" />
58
<?php endforeach; ?>
59
60
61
<?php $this->stop() ?>
62