문제

I'm trying to debug this code:

  public function removeBlankLines() {
    $this->qp->find('br');
  } // <-- break point is here

When I drill down into the $this object (using phpStorm) I can't see the child array I'm interested in. It just displays "can not get property" Screenshot:

phpStorm debug pane screenshot

I'm "listen for debug connections" feature. I'm running the script from the command line. PHP version:

[bwood@mbp ~]$ php -v
PHP 5.4.24 (cli) (built: Jan 19 2014 21:32:15)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

Maybe related: http://bugs.xdebug.org/view.php?id=996?

도움이 되었습니까?

해결책

http://bugs.xdebug.org/view.php?id=686

It's all about how such classes (SplObjectStorage, ArrayObject and alike) are implemented internally:

this is because objects of the class SplObjectStorage are not user land PHP objects but special super duper internal ones. A similar situation will happen with many other internal PHP classes.

AFAIK nothing can be done on PhpStorm's side until xdebug will be able to "support" them.


UPDATE: The aforementioned xdebug ticket was resolved for xdebug 2.3.3 quite some time ago (latest stable xdebug version is 2.4.1) and it should be possible to view such classes in debugger.

다른 팁

  • Upgrade your xdebug to version 2.3.3, it has fixed the problem http://bugs.xdebug.org/view.php?id=686#c3116
  • If you are running vagrant make sure that you upgrade xdebug in
    vagrant virtual machine.
  • Upgrade instructions can be obtained form http://xdebug.org/wizard.php

    If upgrading is not an option, you can dump the contents as a last
    resort.

    In evaluate expression you can try something like

    file_put_contents('dump.txt', var_export($requiredVariable,true));

You will also get a ! can not get property error if the property you are attempting to inspect is inherited from a parent class and not visible from your current scope.

Example:

xDebug will annotate the relevant property like such:

$childClass = {path\to\child\Child}
    *path\to\class\Parent*property = {path\to\property\Property}

Where:

  • Parent is the base class
  • Child is the extending class
  • property is the inherited property, defined on Parent

Note the asterisk * which identify this case and denote 'not visible from current scope'.

Solution:

The quick solution to enable debugging is to set the parent's property's visibility to public.

ie

class Parent {
    public $property;  // instead of private or protected
}

class Child extends Parent{
    // You can now inspect parent::$property for instances of Child 
}

Remember to set the property visibility back to the correct value when finished testing.

Linux LDME2
php5.6.30-0+deb8u1
xdebug v2.5.3

I tryed this recept.

php -i | xclip -selection clipboard

Put to, and followed the instructions

https://xdebug.org/wizard.php

I got this result (can not get property)

sha256sum ~/xdebug-from-src/xdebug-2.5.3/modules/xdebug.so afbb70941387ff1e191433d2a09ff42a393caac773194c0e9004b844a0f3d73b

I finded fix for this problem. Instead build from source, need install from pecl

sudo pecl install xdebug

sha256sum /usr/lib/php5/20131226/xdebug.so b82f2a4ab101323d3600a79223143e2eefe941d404c88af2bd7434fd47caaf13

php -v

PHP 5.6.30-0+deb8u1 (cli) (built: Feb 8 2017 08:50:21) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies with Xdebug v2.5.3, Copyright (c) 2002-2017, by Derick Rethans

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top