[英]phpStorm/Xdebug can't show show child arrays of objects
我正在嘗試調試此代碼:
public function removeBlankLines() {
$this->qp->find('br');
} // <-- break point is here
當我深入到 $this 對象(使用 phpStorm)時,我看不到我感興趣的子數組。它只顯示“無法獲取屬性”屏幕截圖:
我正在“偵聽調試連接”功能。 我正在從命令行運行腳本。 PHP版本:
[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
也許相關: http : //bugs.xdebug.org/view.php ? id=996 ?
http://bugs.xdebug.org/view.php?id=686
這些都是關於如何在內部實現這些類( SplObjectStorage
, ArrayObject
和類似的):
這是因為SplObjectStorage類的對象不是用戶登陸的PHP對象,而是特殊的超級內部PHP對象。 許多其他內部PHP類也會發生類似的情況。
AFAIK無法在PhpStorm方面做任何事情,直到xdebug能夠“支持”它們。
更新:前面提到的xdebug票證已經解決了xdebug 2.3.3 (最新的穩定xdebug版本是2.4.1),應該可以在調試器中查看這些類。
升級說明可以從http://xdebug.org/wizard.php獲得
如果不能選擇升級,則可以將內容作為最后一個轉儲
采取。
在評估表達式時,你可以嘗試類似的東西
file_put_contents('dump.txt',var_export($ requiredVariable,true));
你也會得到一個! can not get property
如果您嘗試檢查的屬性是從父類繼承而在當前范圍內不可見, ! can not get property
錯誤。
xDebug將注釋相關屬性,如:
$childClass = {path\to\child\Child}
*path\to\class\Parent*property = {path\to\property\Property}
哪里:
Parent
是基類 Child
是延伸課 property
是在Parent上定義的繼承屬性 請注意標識此情況的星號*
,並表示“ 從當前范圍不可見 ”。
啟用調試的快速解決方案是將父級屬性的可見性設置為public
。
即
class Parent {
public $property; // instead of private or protected
}
class Child extends Parent{
// You can now inspect parent::$property for instances of Child
}
記得在完成測試后將屬性可見性設置回正確的值。
Linux LDME2
php 5.6.30-0 + deb8u1
xdebug v 2.5.3
我試過這個容器。
php -i | xclip -selection clipboard
投入並按照說明操作
https://xdebug.org/wizard.php
我得到了這個結果( 無法獲得財產 )
sha256sum~ / xdebug-from-src / xdebug-2.5.3 / modules / xdebug.so afbb70941387ff1e191433d2a09ff42a393caac773194c0e9004b844a0f3d73b
我找到了解決這個問題的方法。 而是從源代碼構建,需要從pecl安裝
sudo pecl install xdebug
sha256sum /usr/lib/php5/20131226/xdebug.so b82f2a4ab101323d3600a79223143e2eefe941d404c88af2bd7434fd47caaf13
php -v
PHP 5.6.30-0 + deb8u1(cli)(內置:2017年2月8日08:50:21)版權所有(c)1997-2016 PHP Group Zend Engine v2.6.0,版權所有(c)1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev,版權所有(c)1999-2016,作者:Zend Technologies,Xdebug v2.5.3,版權所有(c)2002-2017,作者:Derick Rethans
我在Yii框架中遇到了類似的問題。 ActiveRecord對象未在調試器監視器中顯示屬性(無法獲取屬性)。
但是有一個簡單的解決方法,在調試器手表中使用$this->attributes
而不是$this
。
如果您了解內部對象結構以及要查找的內容,我認為這種方法可以在許多類似的情況下提供幫助。 如果$this->something
仍無法正常工作,請嘗試使用(array)$this-> something
將其(array)$this-> something
為數組。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.