Global variable or function should never be used 2

  • Major
  • Architecture

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

  1. * Get a setting.
  2. *
  3. * @param $key
  4. * @return FieldType
  5. */
  6. function setting($key)

    setting() 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 Ryan Thompson
  7. {
  8. /* @var SettingInterface $setting */
  9. if (!$setting = dispatch_now(new GetSetting($key))) {
  10. return null;
  11. }
  1. *
  2. * @param $key
  3. * @param null $default
  4. * @return FieldType
  5. */
  6. function setting_value($key, $default = null)

    setting_value() 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 Ryan Thompson
  7. {
  8. return dispatch_now(new GetSettingValue($key, $default));
  9. }
  10. }

Unused method, property, variable or parameter

  • Minor
  • Deadcode

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

Updated rule! We've recently tweaked this rule. This may explain the disappearance of false positives, or new suggestions not linked to any activity in the code.
  1. */
  2. public function handle(SettingsWereSaved $event)
  3. {
  4. $builder = $event->getBuilder();
  5. if (!($namespace = $builder->getEntry()) == 'streams') {

    This namespace local variable is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Ryan Thompson
  6. return;
  7. }
  8. $maintenance = $builder->getFormValue('maintenance');

Text files should end with a newline character 12

  • Info
  • Codestyle

More information: https://insight.symfony.com/what-we-analyse/missing_e_o_l

  1. 'plugins' => 'Beépülők',
  2. 'modules' => 'Modulok',
  3. 'extensions' => 'Kiegészítők',
  4. 'field_types' => 'Mező Típus',
  5. ],
  6. ];

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by kiger
  1. 'name' => 'Név',
  2. ],
  3. 'description' => [
  4. 'name' => 'Leírás',
  5. ],
  6. ];

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by kiger
  1. <?php
  2. return [
  3. 'env_locked' => 'A beállítás zárolva.',
  4. ];

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by kiger
  1. 'name' => 'Beállítások',
  2. 'option' => [
  3. 'write' => 'Hozzáférhet a beállításokhoz?',
  4. ],
  5. ],
  6. ];

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by kiger
  1. 'plugins' => 'Plugin',
  2. 'modules' => 'Moduli',
  3. 'extensions' => 'Estensioni',
  4. 'field_types' => 'Field Type',
  5. ],
  6. ];

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Christian Giupponi
  1. 'name' => 'Nome',
  2. ],
  3. 'description' => [
  4. 'name' => 'Descrizione',
  5. ],
  6. ];

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Christian Giupponi
  1. <?php
  2. return [
  3. 'env_locked' => 'Questa impostazione è bloccata.',
  4. ];

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Christian Giupponi
  1. 'name' => 'Impostazioni',
  2. 'option' => [
  3. 'write' => 'Può gestire le impostazioni di sistema?',
  4. ],
  5. ],
  6. ];

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Christian Giupponi
  1. 'plugins' => 'Pluginler',
  2. 'modules' => 'Modüller',
  3. 'extensions' => 'Eklentiler',
  4. 'field_types' => 'Alan Tipleri',
  5. ],
  6. ];

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Ali Selcuk
  1. 'name' => 'İsim',
  2. ],
  3. 'description' => [
  4. 'name' => 'Açıklama',
  5. ],
  6. ];

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Ali Selcuk
  1. <?php
  2. return [
  3. 'env_locked' => 'Bu ayar şu anda kilitlidir.',
  4. ];

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Ali Selcuk
  1. 'name' => 'Ayarlar',
  2. 'option' => [
  3. 'write' => 'Sistem ayarlarını yönetebilir mi?',
  4. ],
  5. ],
  6. ];

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Ali Selcuk

Methods and properties visibility should always be explicitly defined

  • Info
  • Readability

More information: https://insight.symfony.com/what-we-analyse/php.method_or_property_missing_visibility

New rule! We've recently added this rule to Insight. Don't be surprised to see new suggestions even though the codebase didn't change.
  1. * Create a new ModifyValue instance.
  2. *
  3. * @param SettingInterface $setting
  4. * @param $value
  5. */
  6. function __construct(SettingInterface $setting, $value)

    This method has no explicit visibility which may lead to maintainability issues. You should always declare a visibility for methods and properties.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Ryan Thompson
  7. {
  8. $this->value = $value;
  9. $this->setting = $setting;
  10. }