Completed
Push — master ( 9f54f5...eb5f5d )
by Andrii
01:42
created

src/views/package/_search_item.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
use hiqdev\assetpackagist\assets\AppAsset;
4
use hiqdev\assetpackagist\models\AssetPackage;
5
use yii\helpers\Html;
6
use yii\helpers\Url;
7
8
$bundle = AppAsset::register($this);
9
$logoUrl = $bundle->baseUrl . '/logo';
10
$package = new AssetPackage(strtolower($model->platform), $model->name);
11
12
$url = Url::to(['package/detail', 'fullname' =>  $package->fullName]);
0 ignored issues
show
The property fullName does not exist on object<hiqdev\assetpackagist\models\AssetPackage>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
13
$url = str_replace('%2F', '/', $url);
14
?>
15
<div class="row well well-sm">
16
    <div class="col-sm-9">
17
        <h4 class="search-result-item-heading">
18
            <img src="<?= $logoUrl . '/' . strtolower($model->platform) ?>.svg" title="<?= Html::encode($model->platform) ?>" height="20px" />
19
            <a href="<?= $url ?>"><?= Html::encode($package->fullName) ?></a>
0 ignored issues
show
The property fullName does not exist on object<hiqdev\assetpackagist\models\AssetPackage>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
20
        </h4>
21
        <?php if ($model->description): ?>
22
            <p class="description"><?= Html::encode($model->description) ?></p>
23
        <?php endif ?>
24
        <?php if ($model->latest_release_number): ?>
25
            <p class="latest_release_number">
26
                Latest Release: <span class="label label-success"><?= Html::encode($model->latest_release_number) ?></span>
27
                <?php if ($model->latest_release_published_at): ?>
28
                at <?= Yii::$app->formatter->asDateTime($model->latest_release_published_at) ?>
29
                (<?= Yii::$app->formatter->asRelativeTime($model->latest_release_published_at)?>)
30
                <?php endif ?>
31
            </p>
32
        <?php endif ?>
33
        <?php if (!empty($model->keywords)): ?>
34
            <p class="keywords">
35
                Keywords:
36
                <?= '<span class="label label-default">' . implode('</span> <span class="label label-default">', $model->keywords) . '</span>' ?>
37
            </p>
38
        <?php endif ?>
39
    </div>
40
    <div class="col-sm-3 text-align-center">
41
        <?php if ($model->homepage): ?>
42
            <p class="homepage">
43
                <a href="<?= Html::encode($model->homepage) ?>" target="_blank">
44
                    <i class="fa fa-fw fa-globe" aria-hidden="true"></i> Homepage
45
                </a>
46
            </p>
47
        <?php endif ?>
48
        <?php if ($model->repository_url): ?>
49
            <p class="repository_url">
50
                <a href="<?= Html::encode($model->repository_url) ?>" target="_blank">
51
                    <i class="fa fa-fw fa-random" aria-hidden="true"></i> Repository
52
                </a>
53
            </p>
54
        <?php endif ?>
55
        <?php if (!empty($model->normalized_licenses)): ?>
56
            <p class="normalized_licenses">
57
                <i class="fa fa-fw fa-balance-scale"></i> License:
58
                <?= implode(',', $model->normalized_licenses) ?>
59
            </p>
60
        <?php endif ?>
61
        <?php if ($package->isAvailable()): ?>
62
            <a class="btn btn-success btn-sm" href="<?= $url ?>">Ready to use</a>
63
        <?php else: ?>
64
            <a class="btn btn-warning btn-sm" href="<?= $url ?>">Fetch</a>
65
        <?php endif ?>
66
    </div>
67
</div>
68