0

こんにちは、多次元配列とそれらの設定に関して、このクラスに問題があり、なぜこのように動作するのか理解できません...修正を手伝ってくれる人はいますか?

いくつかの使用例:

echo $config->session->gcDivisor;
echo $config['session']['gcDivisor'];
$config['logged'] = '1';
$config->logged = '1';
$config['user']['logged'] = '1';
$config->user->logged = '1';

各行のエラー

Notice:  Trying to get property of non-object in /home/biroexpert/subdomains/prod/index.php on line 33

200

Notice:  Undefined index:  user in /home/biroexpert/subdomains/prod/Library/Twelve/Config/Config.php on line 67

Notice:  Indirect modification of overloaded element of Twelve\Config\Config has no effect in /home/biroexpert/subdomains/prod/index.php on line 37

Notice:  Undefined index:  user in /home//subdomains/prod/Library/Twelve/Config/Config.php on line 87

Notice:  Indirect modification of overloaded property Twelve\Config\Config::$user has no effect in /home//subdomains/prod/index.php on line 38

Strict Standards:  Creating default object from empty value in /home//subdomains/prod/index.php on line 38

コード

<?php
namespace Twelve\Config;
use \ArrayObject;
use \Twelve\SingletonPattern\LazySingleton;
use \Twelve\SingletonPattern\Interfaces\ILazySingleton;

/**
 *  Singleton With Configuration Info
 */
class Config extends ArrayObject implements ILazySingleton
{
    /**
     * Stores FileName
     * @var Config
     */
    protected static $_configFile = '';

    /**
     * Config Settings Array
     * @var Config
     */
    protected $_settings = array();

    public static function getInstance(){
        return LazySingleton::getInstance(__CLASS__);
    }

    /**
     *  Set the Config File Path
     */
    public static function setFile($filePath)
    {
        static::$_configFile = $filePath;
    }

    public function __construct()
    {
        LazySingleton::validate(__CLASS__);

        $values = include(static::$_configFile);
        if(is_array($values))
        {
            // Allow accessing properties as either array keys or object properties:
            $this->_settings = new ArrayObject($values, ArrayObject::ARRAY_AS_PROPS);
        }
    }

    // some debug method
    public function dumpArray()
    {
        echo "<pre>";
        print_r($this->_settings);
    }

    public function getIterator()
    {
        return $this->_settings->getIterator();
    }

    public function offsetExists($index)
    {
        return $this->_settings->offsetExists($index);
    }

    public function offsetGet($index)
    {
        return $this->_settings->offsetGet($index);
    }

    public function offsetSet($key, $value)
    {
        return $this->_settings->offsetSet($key, $value);
    }

    public function offsetUnset($index)
    {
        return $this->_settings->offsetUnset($index);
    }

    public function count()
    {
        return $this->_settings->count();
    }
    /**
     * Prevent Cloning
     */
    public function __clone()
    {
        trigger_error('Clone is not allowed.', E_USER_ERROR);

        // No Cloning Allowed
    }
}
4

0 に答える 0