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

View/Front/default/widgets/newcontent/default.php (5 issues)

1
<?php
2
/** @var \Apps\ActiveRecord\Content[] $records */
3
4
use Ffcms\Core\Helper\Date;
5
use Ffcms\Core\Helper\Text;
6
use Ffcms\Core\Helper\Type\Str;
7
8
foreach ($records as $record) {
9
    $title = \App::$Translate->getLocaleText($record->title);
10
    if (Str::likeEmpty($title)) {
11
        continue;
12
    }
13
    $title = Text::snippet($title, 50);
0 ignored issues
show
It seems like $title can also be of type null; however, parameter $text of Ffcms\Core\Helper\Text::snippet() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

13
    $title = Text::snippet(/** @scrutinizer ignore-type */ $title, 50);
Loading history...
14
    $date = Date::humanize($record->created_at);
15
    $categoryUrl = \App::$Alias->baseUrl . '/content/list/' . $record->cpath;
0 ignored issues
show
The property cpath does not exist on Apps\ActiveRecord\Content. Did you mean path?
Loading history...
16
    $categoryLink = '<a href="' . $categoryUrl . '">' . \App::$Translate->getLocaleText($record->ctitle) . '</a>';
0 ignored issues
show
The property ctitle does not exist on Apps\ActiveRecord\Content. Did you mean title?
Loading history...
17
    $newsLink = \App::$Alias->baseUrl . '/content/read/' . $record->cpath;
18
    $newsLink = rtrim($newsLink, '/') . '/' . $record->path;
19
20
    echo '<div class="row"><div class="col-md-12">';
21
    echo '<a href="' . $newsLink . '">&rarr; ' . $title . '</a><br />';
22
    echo '<small class="float-left">' . $categoryLink . '</small>';
23
    echo '<small class="float-right text-secondary">' . $date . '</small>';
0 ignored issues
show
Are you sure $date of type false|string can be used in concatenation? ( Ignorable by Annotation )

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

23
    echo '<small class="float-right text-secondary">' . /** @scrutinizer ignore-type */ $date . '</small>';
Loading history...
24
    echo '</div></div>';
25
    echo '<hr class="pretty" />';
26
}
27
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...