Passed
Push — master ( fa3542...0a3787 )
by Mihail
05:11
created

Apps/View/Admin/default/comments/publish.php (3 issues)

Labels
1
<?php
2
use Ffcms\Core\Helper\Date;
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
use Ffcms\Core\Helper\Simplify;
5
use Ffcms\Core\Helper\Type\Str;
6
7
/** @var Apps\Model\Admin\Comments\FormCommentDelete $model */
8
/** @var string $type */
9
/** @var \Ffcms\Templex\Template\Template $this */
10
11
$this->layout('_layouts/default', [
12
    'title' => __('Publish comments'),
13
    'breadcrumbs' => [
14
        Url::to('main/index') => __('Main'),
15
        Url::to('widget/index') => __('Widgets'),
16
        Url::to('comments/index') => __('Comments'),
17
        __('Publish comments and answers')
18
    ]
19
]);
20
$records = $model->getRecord();
21
?>
22
23
<?php $this->start('body') ?>
24
25
<?= $this->insert('comments/_tabs') ?>
0 ignored issues
show
Are you sure the usage of $this->insert('comments/_tabs') targeting League\Plates\Template\Template::insert() 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...
26
27
<h1><?= __('Publish comments and answers') ?></h1>
28
<?= __('Are you sure to moderate and make public this comments and answers?') ?>
29
30
<?php
31
$table = $this->table(['class' => 'table table-striped'])
32
    ->head([
33
        ['text' => '#'],
34
        ['text' => __('Message')],
35
        ['text' => __('Author')],
36
        ['text' => __('Date')]
37
    ]);
38
foreach ($records as $item) {
39
    $table->row([
40
        ['text' => $item->id],
41
        ['text' => Str::sub(\App::$Security->strip_tags($item->message), 0, 50)],
0 ignored issues
show
It seems like App::Security->strip_tags($item->message) can also be of type array and null; however, parameter $string of Ffcms\Core\Helper\Type\Str::sub() 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

41
        ['text' => Str::sub(/** @scrutinizer ignore-type */ \App::$Security->strip_tags($item->message), 0, 50)],
Loading history...
42
        ['text' => Simplify::parseUserLink($item->user_id, $item->guest_name, 'user/update'), 'html' => true],
43
        ['text' => Date::convertToDatetime($item->created_at, Date::FORMAT_TO_HOUR)]
44
    ]);
45
}
46
47
?>
48
<div class="table-responsive"><?= $table->display() ?></div>
49
50
<?php $form = $this->form($model) ?>
51
<?= $form->start() ?>
52
53
<?= $form->button()->submit(__('Publish'), ['class' => 'btn btn-warning'])?>
54
55
<?= $form->stop() ?>
56
57
<?php $this->stop() ?>
58