duanleiming2014 2015-02-11 08:52
浏览 28
已采纳

xDebug调用nonExisting属性

I have a strange problem with xdebugger. Can somone pls think of a logical explanation?oO?

I have a class:

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;
    }.....

This serves as a base for DB objects. when i use a object to populate it via a db adapter like:

$entity = new EntityExtendingTheClass($arrayOfData);

Now here comes the spooky part, when i run the script normally i get no errors whatsoever. But when i run it with breakpoints i get this wierd problem:

Property composites not found

The wierd thing is. I DONT HAVE in a whole project this property. So there is no way it gets it from code.

The most bizzare thing is when i cach the error i get the call tht an nonexisting property was triedto be called. wich my coude dous not.

Any sugestions?

UPDATE:

Just tried to make it stop via breakpoint(out of desparation) and no breakpoint.

The biggest lol ist tht it only happens when i try to go with debugger in the creation of the object. if i ski it it dous not break.... WTH?

  • 写回答

1条回答 默认 最新

  • dou7466 2015-02-11 09:28
    关注

    Xdebug assigns properties whilst debugging. You could add something to check for the composites property?

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

    Just throwing it out there as a suggestion- might work? :) Maybe you could also check to see if xdebug is installed, and only check for the composites in that case?

    HTH

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置