Skip to content

Commit 4a93c2c

Browse files
committed
Merged pull request xdebug#1017
2 parents e629434 + 784e49c commit 4a93c2c

File tree

5 files changed

+93
-5
lines changed

5 files changed

+93
-5
lines changed

src/lib/var_export_xml.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,8 +676,15 @@ void xdebug_var_export_xml_node(zval **struc, xdebug_str *name, xdebug_xml_node
676676

677677
zend_string_release(unmangled);
678678

679-
if (info && info != ZEND_WRONG_PROPERTY_INFO && info->flags & ZEND_ACC_READONLY) {
680-
flags |= XDEBUG_OBJECT_ITEM_TYPE_READONLY;
679+
if (info && info != ZEND_WRONG_PROPERTY_INFO) {
680+
if (info->flags & ZEND_ACC_READONLY) {
681+
flags |= XDEBUG_OBJECT_ITEM_TYPE_READONLY;
682+
}
683+
#if PHP_VERSION_ID >= 80400
684+
if (info->flags & ZEND_ACC_VIRTUAL) {
685+
continue;
686+
}
687+
#endif
681688
}
682689
}
683690
#endif

tests/debugger/bug02314-001.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ dbgpRunFile( $filename, $commands );
4040

4141
-> context_get -i 4 -c 0
4242
<?xml version="1.0" encoding="iso-8859-1"?>
43-
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="4" context="0"><property name="$date" fullname="$date" type="object" classname="DateTime" children="1" numchildren="3" page="0" pagesize="32"><property name="date" fullname="$date-&gt;date" facet="public" type="string" size="26" encoding="base64"><![CDATA[MTk4MC0wMS0wMSAwMDowMDowMC4wMDAwMDA=]]></property><property name="timezone_type" fullname="$date-&gt;timezone_type" facet="public" type="int"><![CDATA[3]]></property><property name="timezone" fullname="$date-&gt;timezone" facet="public" type="string" size="3" encoding="base64"><![CDATA[VVRD]]></property></property><property name="$foo" fullname="$foo" type="object" classname="Foo" children="1" numchildren="2" page="0" pagesize="32"><property name="time_string" fullname="$foo-&gt;time_string" facet="public" type="string" size="8" encoding="base64"><![CDATA[MTI6MzQ6NTY=]]></property><property name="date" fullname="$foo-&gt;date" facet="public" type="object" classname="DateTime" children="1" numchildren="3"></property></property></response>
43+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="4" context="0"><property name="$date" fullname="$date" type="object" classname="DateTime" children="1" numchildren="3" page="0" pagesize="32"><property name="date" fullname="$date-&gt;date" facet="public" type="string" size="26" encoding="base64"><![CDATA[MTk4MC0wMS0wMSAwMDowMDowMC4wMDAwMDA=]]></property><property name="timezone_type" fullname="$date-&gt;timezone_type" facet="public" type="int"><![CDATA[3]]></property><property name="timezone" fullname="$date-&gt;timezone" facet="public" type="string" size="3" encoding="base64"><![CDATA[VVRD]]></property></property><property name="$foo" fullname="$foo" type="object" classname="Foo" children="1" numchildren="1" page="0" pagesize="32"><property name="date" fullname="$foo-&gt;date" facet="public" type="object" classname="DateTime" children="1" numchildren="3"></property></property></response>
4444

4545
-> property_get -i 5 -c 0 -n $foo
4646
<?xml version="1.0" encoding="iso-8859-1"?>
47-
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="5"><property name="$foo" fullname="$foo" type="object" classname="Foo" children="1" numchildren="2" page="0" pagesize="32"><property name="time_string" fullname="$foo-&gt;time_string" facet="public" type="string" size="8" encoding="base64"><![CDATA[MTI6MzQ6NTY=]]></property><property name="date" fullname="$foo-&gt;date" facet="public" type="object" classname="DateTime" children="1" numchildren="3"></property></property></response>
47+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="property_get" transaction_id="5"><property name="$foo" fullname="$foo" type="object" classname="Foo" children="1" numchildren="1" page="0" pagesize="32"><property name="date" fullname="$foo-&gt;date" facet="public" type="object" classname="DateTime" children="1" numchildren="3"></property></property></response>
4848

4949
-> property_get -i 6 -c 0 -n $foo->date
5050
<?xml version="1.0" encoding="iso-8859-1"?>

tests/debugger/bug02314-002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ dbgpRunFile( $filename, $commands );
3939

4040
-> context_get -i 4 -c 0
4141
<?xml version="1.0" encoding="iso-8859-1"?>
42-
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="4" context="0"><property name="$date" fullname="$date" type="object" classname="DateTime" children="1" numchildren="3" page="0" pagesize="32"><property name="date" fullname="$date-&gt;date" facet="public" type="string" size="26" encoding="base64"><![CDATA[MTk4MC0wMS0wMSAwMDowMDowMC4wMDAwMDA=]]></property><property name="timezone_type" fullname="$date-&gt;timezone_type" facet="public" type="int"><![CDATA[3]]></property><property name="timezone" fullname="$date-&gt;timezone" facet="public" type="string" size="3" encoding="base64"><![CDATA[VVRD]]></property></property><property name="$foo" fullname="$foo" type="object" classname="Foo" children="1" numchildren="2" page="0" pagesize="32"><property name="time_string" fullname="$foo-&gt;time_string" facet="public" type="string" size="8" encoding="base64"><![CDATA[MTI6MzQ6NTY=]]></property><property name="date" fullname="$foo-&gt;date" facet="private" type="object" classname="DateTime" children="1" numchildren="3"></property></property></response>
42+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="4" context="0"><property name="$date" fullname="$date" type="object" classname="DateTime" children="1" numchildren="3" page="0" pagesize="32"><property name="date" fullname="$date-&gt;date" facet="public" type="string" size="26" encoding="base64"><![CDATA[MTk4MC0wMS0wMSAwMDowMDowMC4wMDAwMDA=]]></property><property name="timezone_type" fullname="$date-&gt;timezone_type" facet="public" type="int"><![CDATA[3]]></property><property name="timezone" fullname="$date-&gt;timezone" facet="public" type="string" size="3" encoding="base64"><![CDATA[VVRD]]></property></property><property name="$foo" fullname="$foo" type="object" classname="Foo" children="1" numchildren="1" page="0" pagesize="32"><property name="date" fullname="$foo-&gt;date" facet="private" type="object" classname="DateTime" children="1" numchildren="3"></property></property></response>
4343

4444
-> property_get -i 5 -c 0 -n $foo->date
4545
<?xml version="1.0" encoding="iso-8859-1"?>

tests/debugger/bug02343.inc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
$example = new class {
3+
private string $name;
4+
5+
public function __construct() { }
6+
7+
public DateTimeImmutable $datetime {
8+
get {
9+
return new DateTimeImmutable();
10+
}
11+
set (mixed $void) {}
12+
}
13+
};
14+
15+
echo $example->datetime->format("c");
16+
echo "DONE\n";

tests/debugger/bug02343.phpt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
--TEST--
2+
Test for bug #2343: Virtual properties can not be shown safely
3+
--SKIPIF--
4+
<?php
5+
require __DIR__ . '/../utils.inc';
6+
check_reqs('PHP >= 8.4; dbgp');
7+
?>
8+
--FILE--
9+
<?php
10+
require 'dbgp/dbgpclient.php';
11+
$filename = dirname(__FILE__) . '/bug02343.inc';
12+
13+
$commands = array(
14+
'feature_set -n extended_properties -v 1',
15+
'feature_set -n max_depth -v 2',
16+
"breakpoint_set -t line -f file://{$filename} -n 9",
17+
'breakpoint_set -t exception -x *',
18+
'run',
19+
'context_get -c 0',
20+
'step_into',
21+
'context_get -c 0',
22+
'detach',
23+
);
24+
25+
dbgpRunFile( $filename, $commands );
26+
?>
27+
--EXPECTF--
28+
<?xml version="1.0" encoding="iso-8859-1"?>
29+
<init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file://bug02343.inc" language="PHP" xdebug:language_version="" protocol_version="1.0" appid=""><engine version=""><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2099 by Derick Rethans]]></copyright></init>
30+
31+
-> feature_set -i 1 -n extended_properties -v 1
32+
<?xml version="1.0" encoding="iso-8859-1"?>
33+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="extended_properties" success="1"></response>
34+
35+
-> feature_set -i 2 -n max_depth -v 2
36+
<?xml version="1.0" encoding="iso-8859-1"?>
37+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_depth" success="1"></response>
38+
39+
-> breakpoint_set -i 3 -t line -f file://bug02343.inc -n 9
40+
<?xml version="1.0" encoding="iso-8859-1"?>
41+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="3" id="{{PID}}0001"></response>
42+
43+
-> breakpoint_set -i 4 -t exception -x *
44+
<?xml version="1.0" encoding="iso-8859-1"?>
45+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="4" id="{{PID}}0002"></response>
46+
47+
-> run -i 5
48+
<?xml version="1.0" encoding="iso-8859-1"?>
49+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="5" status="break" reason="ok"><xdebug:message filename="file://bug02343.inc" lineno="9"></xdebug:message></response>
50+
51+
-> context_get -i 6 -c 0
52+
<?xml version="1.0" encoding="iso-8859-1"?>
53+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="6" context="0"><property type="object" children="0" numchildren="0" page="0" pagesize="32"><name encoding="base64"><![CDATA[JHRoaXM=]]></name><fullname encoding="base64"><![CDATA[JHRoaXM=]]></fullname><classname encoding="base64"><![CDATA[%s]]></classname></property></response>
54+
55+
-> step_into -i 7
56+
<?xml version="1.0" encoding="iso-8859-1"?>
57+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="7" status="break" reason="ok"><xdebug:message filename="file://bug02343.inc" lineno="16"></xdebug:message></response>
58+
59+
-> context_get -i 8 -c 0
60+
<?xml version="1.0" encoding="iso-8859-1"?>
61+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="8" context="0"><property type="object" children="0" numchildren="0" page="0" pagesize="32"><name encoding="base64"><![CDATA[JGV4YW1wbGU=]]></name><fullname encoding="base64"><![CDATA[JGV4YW1wbGU=]]></fullname><classname encoding="base64"><![CDATA[%s]]></classname></property></response>
62+
63+
-> detach -i 9
64+
<?xml version="1.0" encoding="iso-8859-1"?>
65+
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="detach" transaction_id="9" status="stopping" reason="ok"></response>

0 commit comments

Comments
 (0)