gpt4 book ai didi

php - xdebug、phpunit 和 vim。上下文中的 'uninitialized' 变量

转载 作者:可可西里 更新时间:2023-10-31 23:49:10 24 4
gpt4 key购买 nike

我正在使用这个 vim 插件 https://github.com/ludovicPelle/vim-xdebug使用 xdebug

Xdebug 和 vim 插件在常规脚本中运行良好。我可以单步执行并打印出变量。

当我尝试单步执行基本单元测试时,它顺利到达断点并停止,我可以单步执行代码,但我无法再查看变量的内容。

我正试图让它与一个非常基本的单元测试一起工作

class testClass extends \PHPUnit_Framework_TestCase
{
public function testSomething()
{
$a = 5;
$b = 6;
$c = 7;
}
}

当我走到方法的末尾并尝试打印出 $a 的内容时,出现以下错误。

13 : send =====> property_get -i 13 -d 0 -n a
13 : recv <===== {{{ <?xml version="1.0" encoding="iso-8859-1"?>
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="13" status="break" reason="ok"><error code="300"><message><![CDATA[can not get property]]></message></error></response>
}}}
response status=break xmlns=urn:debugger_protocol_v1 xmlns:xdebug=http://xdebug.org/dbgp/xdebug reason=ok command=property_get transaction_id=13
error code=300 : Can not get property (when the requested property to get did not exist, this is NOT used for an existing but uninitialized property, which just gets the type "uninitialised" (See: PreferredTypeNames)).
message
can not get property

当我打印出整个上下文时,3 个变量显示如下

$command = 'context_get';
a = /* uninitialized */'';
b = /* uninitialized */'';
c = /* uninitialized */'';

我知道 phpunit 在运行测试类的方法时会使用一些有趣的技巧,所以这可能就是调试器不返回方法中的变量的原因。任何建议将不胜感激,谢谢。

最佳答案

你需要做这样的事情

class testClass extends \PHPUnit_Framework_TestCase
{
$a = 0;
$b = 0;
$c = 0;

function dosomething() {
$a = 5;
$b = 6;
$c = 7;
}
}

或者你需要包含一个变量文件

你的 var.php 文件

  $a = 0;
$b = 0;
$c = 0;

?>

关于php - xdebug、phpunit 和 vim。上下文中的 'uninitialized' 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14411123/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com