Global variable or function should never be used 2

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

  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
    Permalink
    Last edited by Ryan Thompson
  7. {
  8. return dispatch_now(new GetSettingValue($key, $default));
  9. }
  10. }
  • anomalylabs

    This is an accepted principle in Laravel.
  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
    Permalink
    Last edited by Ryan Thompson
  7. {
  8. /* @var SettingInterface $setting */
  9. if (!$setting = dispatch_now(new GetSetting($key))) {
  10. return null;
  11. }
  • anomalylabs

    This is an accepted principle in Laravel.

Methods and properties visibility should always be explicitly defined

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

  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
    Permalink
    Last edited by Ryan Thompson
  7. {
  8. $this->value = $value;
  9. $this->setting = $setting;
  10. }