Global variable or function should never be used 5

  • Major
  • Architecture

More information: https://insight.sensiolabs.com/what-we-analyse/php.use_global_variable_or_function

in src/functions.php, line 8
  1. use BoomCMS\Contracts\Models\Page;
  2. use BoomCMS\Support\Facades\Router;
  3. use BoomCMS\Support\Helpers;
  4. if (!function_exists('meta_keywords')) {
  5. function meta_keywords(Page $page = null)

    meta_keywords() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Rob Taylor
  6. {
  7. $page = $page ?: Router::getActivePage();
  8. return "<meta name='keywords' content='{$page->getKeywords()}'>";
  9. }
in src/functions.php, line 17
  1. return "<meta name='keywords' content='{$page->getKeywords()}'>";
  2. }
  3. }
  4. if (!function_exists('meta_description')) {
  5. function meta_description(Page $page = null)

    meta_description() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Rob Taylor
  6. {
  7. $description = Helpers::description($page);
  8. return "<meta name='description' content='$description'>";
  9. }
in src/functions.php, line 26
  1. return "<meta name='description' content='$description'>";
  2. }
  3. }
  4. if (!function_exists('meta_robots')) {
  5. function meta_robots(Page $page = null)

    meta_robots() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Rob Taylor
  6. {
  7. $page = $page ?: Router::getActivePage();
  8. $content = ($page->allowsExternalIndexing()) ? 'index, follow' : 'noindex, nofollow';
  9. return "<meta name='robots' content='$content'>";
in src/functions.php, line 36
  1. return "<meta name='robots' content='$content'>";
  2. }
  3. }
  4. if (!function_exists('meta_og')) {
  5. function meta_og(Page $page = null)

    meta_og() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Rob Taylor
  6. {
  7. $page = $page ?: Router::getActivePage();
  8. $siteName = Settings::get('site.name');
  9. $description = Helpers::description($page);
in src/functions.php, line 60
  1. return $html;
  2. }
  3. }
  4. if (!function_exists('h1')) {
  5. function h1(Page $page = null)

    h1() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by Rob Taylor
  6. {
  7. $page = $page ?: Router::getActivePage();
  8. return "<h1 id='b-page-title'>{$page->getTitle()}</h1>";
  9. }

Object parameters should be type hinted

  • Minor
  • Bugrisk

More information: https://insight.sensiolabs.com/what-we-analyse/php.object_parameter_not_type_hinted

  1. *
  2. * @param Model $model
  3. *
  4. * @return Model
  5. */
  6. public function save($model): Model

    The parameter model, which is an object, should be typehinted.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  7. {
  8. $model->save();
  9. return $model;
  10. }

Error silenced by the at sign (@)

  • Minor
  • Bugrisk

More information: https://insight.sensiolabs.com/what-we-analyse/php.silenced_error

  1. public function getNews()
  2. {
  3. $key = 'boomcms.news';
  4. return $this->cache->get($key, function () use ($key) {
  5. $response = json_decode(@file_get_contents($this->newsUrl));

    Adding "@" before file_get_contents($this->newsUrl) prevents warning and errors during this function execution from being displayed.
    If you need to do that, you should probably implement a better way to qualify and recover from errors, using Exceptions.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Rob Taylor
  6. $news = $response->news ?? [];
  7. $this->cache->put($key, $news, 3600);
  8. return $news;

Unused method, property, variable or parameter

  • Minor
  • Deadcode

More information: https://insight.sensiolabs.com/what-we-analyse/php.unused_local_variable_or_private_member

  1. * @param Person $person
  2. * @param string $ability
  3. *
  4. * @return bool
  5. */
  6. public function before(Person $person, $ability)

    This ability argument is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Rob Taylor
  7. {
  8. if ($person->isSuperUser()) {
  9. return true;
  10. }

The composer.lock is not up to date.

  • Info
  • Bugrisk

More information: https://insight.sensiolabs.com/what-we-analyse/composer.outdated_lock_file

The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.

Time to fix: about 1 hour
Open Issue Permalink
Last edited by Rob Taylor

Interfaces names should end with "Interface" 23

  • Info
  • Codestyle

More information: https://insight.sensiolabs.com/what-we-analyse/php.interface_has_no_interface_suffix

  1. <?php
  2. namespace BoomCMS\Contracts\Models;
  3. interface Album

    Interface Album should be named AlbumInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  4. {
  5. /**
  6. * Add assets to the album.
  7. *
  8. * @param array $assetIds
  1. use BoomCMS\Database\Models\AssetVersion;
  2. use Carbon\Carbon;
  3. use DateTime;
  4. interface Asset

    Interface Asset should be named AssetInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  5. {
  6. /**
  7. * @return float
  8. */
  9. public function getAspectRatio();
  1. <?php
  2. namespace BoomCMS\Contracts\Models;
  3. interface Group

    Interface Group should be named GroupInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  4. {
  5. public function addRole($roleId, $allowed, $pageId = 0);
  6. /**
  7. * @return int
  1. namespace BoomCMS\Contracts\Models;
  2. use DateTime;
  3. use Illuminate\Support\Collection;
  4. interface Page

    Interface Page should be named PageInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  5. {
  6. /**
  7. * Whether ACL is enabled.
  8. */
  9. public function aclEnabled(): bool;
  1. namespace BoomCMS\Contracts\Models;
  2. use DateTime;
  3. interface PageVersion

    Interface PageVersion should be named PageVersionInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  4. {
  5. /**
  6. * @return int
  7. */
  8. public function getChunkId();
  1. namespace BoomCMS\Contracts\Models;
  2. use Carbon\Carbon;
  3. interface Person

    Interface Person should be named PersonInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  4. {
  5. public function addGroup(Group $group);
  6. /**
  7. * @param Site $site
  1. <?php
  2. namespace BoomCMS\Contracts\Models;
  3. interface Site

    Interface Site should be named SiteInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  4. {
  5. /**
  6. * Returns the email address of the site admin.
  7. *
  8. * @return string
  1. <?php
  2. namespace BoomCMS\Contracts\Models;
  3. interface Tag

    Interface Tag should be named TagInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  4. {
  5. /**
  6. * @return string
  7. */
  8. public function getGroup();
  1. namespace BoomCMS\Contracts\Models;
  2. use BoomCMS\Core\Template\Theme;
  3. use Illuminate\View\View;
  4. interface Template

    Interface Template should be named TemplateInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  5. {
  6. /**
  7. * @return bool
  8. */
  9. public function fileExists();
  1. <?php
  2. namespace BoomCMS\Contracts\Models;
  3. interface URL

    Interface URL should be named URLInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  4. {
  5. /**
  6. * @return string
  7. */
  8. public function __toString();
  1. namespace BoomCMS\Contracts\Repositories;
  2. use BoomCMS\Contracts\Models\Album as AlbumInterface;
  3. use Illuminate\Support\Collection;
  4. interface Album extends Repository

    Interface Album should be named AlbumInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  5. {
  6. /**
  7. * Returns a collection containing all albums.
  8. *
  9. * @return Collection
  1. use BoomCMS\Database\Models\Asset as AssetObject;
  2. use Illuminate\Contracts\Filesystem\Filesystem;
  3. use Illuminate\Support\Collection;
  4. use Symfony\Component\HttpFoundation\File\UploadedFile;
  5. interface Asset extends Repository

    Interface Asset should be named AssetInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  6. {
  7. public function __construct(
  8. AssetObject $model,
  9. AssetVersionRepositoryInterface $version,
  10. Filesystem $filesystem
  1. use BoomCMS\Contracts\Models\Asset as AssetInterface;
  2. use BoomCMS\Database\Models\AssetVersion as AssetVersionModel;
  3. use BoomCMS\FileInfo\Contracts\FileInfoDriver;
  4. use Symfony\Component\HttpFoundation\File\UploadedFile;
  5. interface AssetVersion extends Repository

    Interface AssetVersion should be named AssetVersionInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  6. {
  7. public function __construct(AssetVersionModel $model);
  8. /**
  9. * Create a version with the given attributes.
  1. namespace BoomCMS\Contracts\Repositories;
  2. use BoomCMS\Contracts\Models\Site as SiteInterface;
  3. use BoomCMS\Database\Models\Group as GroupModel;
  4. interface Group extends Repository

    Interface Group should be named GroupInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  5. {
  6. public function __construct(GroupModel $model = null);
  7. /**
  8. * @param SiteInterface $site
  1. namespace BoomCMS\Contracts\Repositories;
  2. use BoomCMS\Contracts\Models\Page as PageInterface;
  3. use Illuminate\Database\Eloquent\Collection;
  4. interface Page extends Repository

    Interface Page should be named PageInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  5. {
  6. /**
  7. * @param array $attrs
  8. *
  9. * @return PageInterface
  1. namespace BoomCMS\Contracts\Repositories;
  2. use BoomCMS\Contracts\Models\Page as PageInterface;
  3. interface PageVersion

    Interface PageVersion should be named PageVersionInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  4. {
  5. /**
  6. * @param PageInterface $page
  7. *
  8. * @return $this
  1. namespace BoomCMS\Contracts\Repositories;
  2. use BoomCMS\Contracts\Models\Person as PersonInterface;
  3. use Illuminate\Support\Collection;
  4. interface Person extends Repository

    Interface Person should be named PersonInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  5. {
  6. /**
  7. * @param array $credentials
  8. *
  9. * @return PersonInterface
  1. namespace BoomCMS\Contracts\Repositories;
  2. use BoomCMS\Foundation\Database\Model;
  3. interface Repository

    Interface Repository should be named RepositoryInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  4. {
  5. /**
  6. * Delete a single model or multiple models by ID.
  7. *
  8. * @param array|Model
  1. use BoomCMS\Contracts\Models\Person as PersonInterface;
  2. use BoomCMS\Contracts\Models\Site as SiteInterface;
  3. use BoomCMS\Database\Models\Site as SiteModel;
  4. interface Site extends Repository

    Interface Site should be named SiteInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  5. {
  6. /**
  7. * @param SiteModel $model
  8. */
  9. public function __construct(SiteModel $model);
  1. namespace BoomCMS\Contracts\Repositories;
  2. use BoomCMS\Contracts\Models\Tag as TagInterface;
  3. interface Tag extends Repository

    Interface Tag should be named TagInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  4. {
  5. /**
  6. * @param SiteInterface $site
  7. * @param string $name
  8. * @param string $group
  1. namespace BoomCMS\Contracts\Repositories;
  2. use BoomCMS\Contracts\Models\Template as TemplateInterface;
  3. interface Template extends Repository

    Interface Template should be named TemplateInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  4. {
  5. /**
  6. * @param array $attrs
  7. *
  8. * @return TemplateInterface
  1. namespace BoomCMS\Contracts\Repositories;
  2. use BoomCMS\Contracts\Models\Page as PageInterface;
  3. use BoomCMS\Contracts\Models\URL as URLInterface;
  4. interface URL extends Repository

    Interface URL should be named URLInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  5. {
  6. /**
  7. * @param string $location
  8. * @param PageInterface $page
  9. * @param bool $isPrimary
  1. namespace BoomCMS\FileInfo\Contracts;
  2. use Imagick;
  3. interface FileInfoDriver

    Interface FileInfoDriver should be named FileInfoDriverInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Rob Taylor
  4. {
  5. /**
  6. * Returns the aspect ratio of the file.
  7. *
  8. * If the file doesn't have an aspect ratio (e.g. documents) then 0 is returned