xDebug调用nonExisting属性


xDebug calls nonExisting properties

我对xdebugger有一个奇怪的问题。有人能想出一个合乎逻辑的解释吗?哦?

我有一门课:

abstract class AbstractEntity
{
    public $last_modified;
    public $massEntry = array();
    public function __construct(array $properties = null)
    {
        if (!empty($properties)) {
            $this->assignProperties($properties);
        }
    }
    public function __set($property, $value = null)
    {
        if (property_exists($this, $property)) {
            $this->$property = $value;
            return $this;
        }
        throw new InvalidPropertyException("Property $property not found.");
    }
    public function __get($property)
    {
        if (property_exists($this, $property)) {
            return $this->$property;
        }
        throw new InvalidPropertyException("Property $property not found.");
    }
   public function assignProperties(array $properties)
   {
      $availableProps = array_keys(get_object_vars($this));
      foreach ($availableProps as $property) {
          if (isset($properties[$property])) {
              $this->$property = $properties[$property];
          }
      }
    }
    public function toArray()
    {
        return (array) $this;
    }.....

这是DB对象的基础。当我使用一个对象通过数据库适配器来填充它时,比如:

$entity = new EntityExtendingTheClass($arrayOfData);

现在是诡异的部分,当我正常运行脚本时,我没有任何错误。但当我用断点运行它时,我会遇到一个更糟糕的问题:

Property composites not found

更糟糕的是,我在整个项目中都没有这处房产。所以它不可能从代码中得到它。

最奇怪的是,当我发现错误时,我得到了一个调用,试图调用一个不存在的属性。我的兄弟不会。

有什么建议吗?

更新:

只是试图通过断点(出于绝望)使其停止,而没有断点。

最大的问题是,只有当我试图在创建对象时使用调试器时,才会发生这种情况。如果我滑雪,它就不会坏。。。。WTH?

Xdebug在调试时分配属性。你可以添加一些东西来检查复合材料的属性吗?

public function __get($property)
{
    if (property_exists($this, $property) || $property == 'composites') {
        return $this->$property;
    }
    throw new InvalidPropertyException("Property $property not found.");
}

只是把它作为一个建议扔出去——可能有用吗?:)也许您还可以检查是否安装了xdebug,在这种情况下只检查复合材料?

HTH