-1

I want to fix this error:

Strict Standards: Non-static method Gpf_Settings_Regional::getInstance() should not be called statically, assuming $this from incompatible context on line 39

The code producing it:

$this->addValue(Gpf_Settings_Gpf::REGIONAL_SETTINGS_DECIMAL_SEPARATOR, 
Gpf_Settings_Regional::getInstance()->getDecimalSeparator());

I know this is method for PHP 5.3, but I have 5.4 on shared hosting and need to call static on PHP 5.4

twoleggedhorse
  • 4,938
  • 4
  • 23
  • 38
Niel Hrgic
  • 11
  • 1
  • 2

2 Answers2

2

Problem:

You are accessing a non-static method statically with strict standards error reporting switched on.

Solutions:

You can update Gpf_Settings_Regional class

change

public function getInstance()

to

public static function getInstance()

If you are unable to change that class you can change error reporting and switch of reporting of strict standards errors, but it would be better to improve the code.

How to eliminate php5 Strict standards errors?

Community
  • 1
  • 1
Michal M.
  • 1,072
  • 1
  • 11
  • 14
0

if i see good it's already made it by script

*/ private static $instance;

public static function create(Gpf_Application $application) {
    setlocale(LC_ALL, 'en.UTF-8');
    self::$instance = $application;
    self::$instance->registerRolePrivileges();
    self::$instance->initLogger();
    self::$instance->addSmartyPluginsDir();
    $timezone = Gpf_Settings_Gpf::DEFAULT_TIMEZONE;
    try {
        $timezone = Gpf_Settings::get(Gpf_Settings_Gpf::TIMEZONE_NAME);
    } catch (Gpf_Exception $e) {
        Gpf_Log::error('Unable to load timezone: %s - using default one.', $e->getMessage());
    }
    if(false === @date_default_timezone_set($timezone)) {
        Gpf_Log::error('Unable to set timezone %s:', $timezone);
    }
}

public function getDefaultLanguage() {
    return 'en-US';
}

/**
 * @return Gpf_Application
 */
public static function getInstance() {
    if(self::$instance === null) {
        throw new Gpf_Exception('Application not initialize');
    }
    return self::$instance;
}

and this is part where problem is

abstract class Gpf_ApplicationSettings extends Gpf_Object {

/**
 * @var Gpf_Data_RecordSet
 */
private $recordSet;

const CODE = "code";
const VALUE = "value";

protected function loadSetting() {
    $this->addValue("theme", Gpf_Session::getAuthUser()->getTheme());
    $this->addValue("date_time_format", 'MM/d/yyyy HH:mm:ss');
    $this->addValue("programVersion", Gpf_Application::getInstance()->getVersion());
    $this->addValue(Gpf_Settings_Gpf::NOT_FORCE_EMAIL_USERNAMES, Gpf_Settings::get(Gpf_Settings_Gpf::NOT_FORCE_EMAIL_USERNAMES));

    $quickLaunchSettings = new Gpf_Desktop_QuickLaunch();
    $this->addValue(Gpf_Desktop_QuickLaunch::SHOW_QUICK_LAUNCH, $quickLaunchSettings->getShowQuickLaunch());

    $this->addValue(Gpf_Settings_Gpf::REGIONAL_SETTINGS_THOUSANDS_SEPARATOR,

Gpf_Settings_Regional::getinstance()->getThousandsSeparator()); $this->addValue(Gpf_Settings_Gpf::REGIONAL_SETTINGS_DECIMAL_SEPARATOR, Gpf_Settings_Regional::getInstance()->getDecimalSeparator()); $this->addValue(Gpf_Settings_Gpf::REGIONAL_SETTINGS_DATE_FORMAT, Gpf_Settings_Regional::getInstance()->getDateFormat()); $this->addValue(Gpf_Settings_Gpf::REGIONAL_SETTINGS_TIME_FORMAT, Gpf_Settings_Regional::getInstance()->getTimeFormat());

    Gpf_Plugins_Engine::extensionPoint('Core.loadSetting', $this);
}
Niel Hrgic
  • 11
  • 1
  • 2