严格的标准非静态方法


Strict standards non static method

我想修复这个错误:

严格标准:非静态方法Gpf_Settings_Reregional::getInstance()不应静态调用,假设$this来自第39行上的不兼容上下文

产生它的代码:

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

我知道这是PHP 5.3的方法,但我有关于共享托管的5.4,需要在PHP 5.4上调用static

问题:

您正在静态访问一个非静态方法,并打开了严格标准的错误报告。

解决方案:

您可以更新Gpf_Settings_Reregional class

更改

public function getInstance()

public static function getInstance()

如果您无法更改该类,您可以更改错误报告和切换报告严格标准的错误,但最好改进代码。

如何消除php5严格标准的错误?

如果我觉得不错,它已经通过脚本实现了

*/私有静态$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;
}

这就是的问题所在

抽象类Gpf_ApplicationSettings扩展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_Reregional::getinstance()->getThousandsSeparator());$this->addValue(Gpf_Settings_Gpf::REGIONAL_Settings_DIMAL_SEPARATOR,Gpf_Sttings_ReRegional::getInstance()->getDecimalSeparator());$this->addValue(Gpf_Settings_Gpf::REGIONAL_Settings_DATE_FORMAT,Gpf_Sttings_Reregional::getInstance()->getDateFormat());$this->addValue(Gpf_Settings_Gpf::REGIONAL_Settings_TIME_FORMAT,Gpf_Sttings_Reregional::getInstance()->getTimeFormat());

    Gpf_Plugins_Engine::extensionPoint('Core.loadSetting', $this);
}