Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP语法错误:第78行出现意外的T_PAAMAYIM_NEKUDOTAYIM_Php_Static_Static Methods_Php 5.2 - Fatal编程技术网

PHP语法错误:第78行出现意外的T_PAAMAYIM_NEKUDOTAYIM

PHP语法错误:第78行出现意外的T_PAAMAYIM_NEKUDOTAYIM,php,static,static-methods,php-5.2,Php,Static,Static Methods,Php 5.2,我查了所有可能的答案,但很抱歉,我没弄明白。我尝试将属性设置为非静态,但代码板在行中显示了错误: $task = new sfCacheClearTask($sfContext::getInstance()->getEventDispatcher(), new sfFormatter()); 提及 请帮助解决这个问题。谢谢 class doSokiJobTask extends sfBaseTask { CONST STATUS_PENDING = 0; CONST S

我查了所有可能的答案,但很抱歉,我没弄明白。我尝试将属性设置为非静态,但代码板在行中显示了错误:

$task = new sfCacheClearTask($sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
提及

请帮助解决这个问题。谢谢

class doSokiJobTask extends sfBaseTask {

    CONST STATUS_PENDING = 0;
    CONST STATUS_DONE = 1;
    CONST STATUS_IN_PROGRESS = 2;
    CONST STATUS_FAILED = 3;
    CONST STATUS_CANCELLED = 4;

    CONST TIME_TO_DIE = 60;

    public $context = null;
    public $job_name = null;
    public $done = null;
    public $status = null;
    public $start = 0;

    protected function setJobName($name) {
        $this->job_name = strtolower($name);
    }

    protected function configure() {
        $this->addArguments(array(
                //new sfCommandArgument('build', sfCommandArgument::REQUIRED, ''),
        ));

        $this->addOptions(array(
            new sfCommandOption('env', null, sfCommandOption::PARAMETER_OPTIONAL, 'Env to use', 'dev'),
            new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'Env to use', 'frontend'),
            new sfCommandOption('job-type', null, sfCommandOption::PARAMETER_REQUIRED, 'Job to be executed', 'job'),
            new sfCommandOption('daemon', null, sfCommandOption::PARAMETER_REQUIRED, 'Daemon running the job', 0),
        ));

        $this->namespace = 'soki';
        $this->name = 'job';
        $this->briefDescription = 'Lets you run jobs in the background';
        $this->detailedDescription = <<<EOF
The [setup|INFO] task helps run jobs in the background.
Call it with:

  [php symfony setup|INFO]
EOF;
//$this->filesystem = new sfFilesystem(null, $this->formatter);
    }

    protected function execute($arguments = array(), $options = array()) {
        $this->start = $ts_start = microtime(true);
        $options['quiet'] = 'true';
        $configuration = ProjectConfiguration::getApplicationConfiguration($options['application'], $options['env'], true);
        new sfDatabaseManager($configuration);
        $sfContext = sfContext::createInstance($configuration);
        $this->context = $sfContext;
        $this->setJobName($options['job-type']);
        if (true) {
            $file_logger = new sfFileLogger($this->dispatcher, array('file' => $this->configuration->getRootDir() . '/log/jobs.log'));
            $this->dispatcher->connect('command.log', array($file_logger, 'listenToLogEvent'));
        }

        try {
            if (!$this->job_name)
                $this->logSection('INVALID', 'Job Type could not be identified', null, 'ERROR');

            switch ($this->job_name) {
                case 'clear-cache':
                    $task = new sfCacheClearTask($sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
                    $task->run(array(), array('env' => $options['env'], 'app' => $options['application']));
                    $this->done = true;
                    break;
                case 'send-email':
                    $task = new sfProjectSendEmailsTask($sfContext::getInstance()->getEventDispatcher(), new sfFormatter());
                    $task->run(array(), array('env' => $options['env'], 'application' => $options['application'],
                        'message-limit' => sfConfig::get('sf_spool_message_limit', 25)));
                    $this->done = true;
                    break;
                case 'chmod':
                    if (!chmod(sfConfig::get('sf_root_dir') . "/data_society", 0755))
                        throw new Exception('CHMOD failed on ' . sfConfig::get('sf_root_dir') . "/data_society");
                    $this->done = true;
                    break;
                case 'disable-install':
                    $this->done = Application::secureSokiInstaller(true);
                    sokiUtil::clearCacheAsync();
                    break;
                /* case 'enable-install':
                  Application::secureSokiInstaller(false);
                  sokiUtil::clearCacheAsync();
                  break; */
                case 'job':
                    $this->executeJob($arguments, $options);
                    break;
                default:
                    $this->logSection('UNKNOWN', 'Job Type could not be identified', null, 'ERROR');
                    break;
            }
            $ts_end = microtime(true);
            $this->logSection($this->job_name, ($this->done ? 'DONE' : 'FAILED') . ' in ' . round($ts_end - $ts_start) . 's @ ' . $options['env'] . '/' . $options['application'], null, 'INFO');
        } catch (Exception $e) {
            $this->logSection($this->job_name, $e->getMessage(), null, 'ERROR');
            throw $e;
        }
    }

您可以通过类调用静态方法,例如ClassName::methodName,而不是通过实例$instance::methodName