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

View/Front/default/widgets/newcomment/default.php (1 issue)

Labels
1
<?php
2
3
use Apps\Model\Api\Comments\EntityCommentData;
4
use Ffcms\Core\Helper\Date;
5
use Ffcms\Core\Helper\Text;
6
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...
7
8
/** @var EntityCommentData[] $comments */
9
/** @var \Ffcms\Core\Arch\View $this */
10
/** @var int $snippet */
11
?>
12
<?php foreach ($comments as $comment):?>
13
<div class="mb-1 short-comment">
14
    <div class="row mb-1">
15
        <div class="col-md-6">
16
            <i class="fa fa-user"></i>
17
            <?php if ((int)$comment['user']['id'] > 0): ?>
18
                <?= Url::a(['profile/show', [$comment['user']['id']]], $comment['user']['name'], ['style' => 'color: #595959']) ?>
19
            <?php else: ?>
20
                <?= $comment['user']['name'] ?>
21
            <?php endif; ?>
22
        </div>
23
        <div class="col-md-6 pull-right">
24
            <small class="text-secondary pull-right">
25
                <i class="fa fa-calendar"></i> <?= Date::humanize($comment['date']) ?>
26
            </small>
27
        </div>
28
    </div>
29
30
    <div class="row">
31
        <div class="col widget-comment-text">
32
            <a href="<?= \App::$Alias->baseUrl . '/' . $comment['app_name'] . '/comments/' . $comment['app_id'] ?>">
33
                <?= Text::cut(\App::$Security->strip_tags($comment['text']), 0, $snippet) ?>
34
            </a>
35
        </div>
36
    </div>
37
</div>
38
<?php endforeach; ?>
39