View Issue Details

IDProjectCategoryView StatusLast Update
0001542XdebugStep Debuggingpublic2019-02-04 16:58
Reporterlinus Assigned Toderick  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
Product Version2.6.0 
Summary0001542: variables created in a function body won't show up in PhpStorm
Description

When using Xdebug with PhpStorm and PHP 7.2 I cannot see the value of a variable set in a function. In contrast, if the variable is also a parameter to that function I can see it.

Sorry if this was mentioned somewhere, I couldn't find anything about this.

Steps To Reproduce

create PhpStorm project (empty) and add the following as index.php

'''
function hello($name){
$x = 2;
return "Hello" . $name;
}

echo hello("World");
'''

create a run configuration using php's built-in webserver

set breakpoint on $x = 2 line

open page in browser and step into

have a look at the variables info

Additional Information

$ php7.2 -v
PHP 7.2.3-1+ubuntu17.10.1+deb.sury.org+1 (cli) (built: Mar 6 2018 11:19:27) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.3-1+ubuntu17.10.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans

$ php7.1 -v
PHP 7.1.15-1+ubuntu17.10.1+deb.sury.org+2 (cli) (built: Mar 6 2018 11:10:54) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.1.15-1+ubuntu17.10.1+deb.sury.org+2, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans

$ apt show php-xdebug
Package: php-xdebug
Version: 2.6.0+2.5.5-1+ubuntu17.10.1+deb.sury.org+1

TagsNo tags attached.
Operating SystemUbuntu 16.04
PHP Version7.2.0-7.2.4

Activities

linus

2018-03-28 07:38

reporter   ~0004622

I might add that in addition to Ubuntu, this also doesn't work in Windows 7 (using XAMPP and PHP 7.2.3), but I am told by a colleague that it works just fine in PHP 7.2.0 (also XAMPP, but on Windows 10).

derick

2019-02-04 16:58

administrator   ~0004874

Last edited: 2019-02-04 16:58

This is due to OPcache optimising out the $x = 2 as it has no effect. Compare what PHP generates with OPcache enabled:


compiled vars: none
line #* E I O op fetch ext return operands

2 0 E > EXT_STMT
1 NOP
7 2 EXT_STMT
3 INIT_FCALL 'hello'
4 EXT_FCALL_BEGIN
5 SEND_VAL 'World'
6 DO_FCALL 0 $0
7 EXT_FCALL_END
8 ECHO $0
8 9 > RETURN 1

with when it is disabled (php -dvld.active=1 -dopcache.enable_cli=0 /tmp/1542.inc):


compiled vars: !0 = $name, !1 = $x
line #* E I O op fetch ext return operands

2 0 E > EXT_NOP
1 RECV !0
3 2 EXT_STMT
3 ASSIGN !1, 2
4 4 EXT_STMT
5 CONCAT 0000003:0000003 'Hello', !0
6 > RETURN 0000003:0000003
5 7 EXT_STMT
8
> RETURN null

Issue History

Date Modified Username Field Change
2018-03-27 15:44 linus New Issue
2018-03-28 07:38 linus Note Added: 0004622
2019-02-04 16:58 derick Note Added: 0004874
2019-02-04 16:58 derick Status new => resolved
2019-02-04 16:58 derick Resolution open => no change required
2019-02-04 16:58 derick Assigned To => derick
2019-02-04 16:58 derick Note Edited: 0004874
2020-03-12 16:33 derick Category Remote Debugging => Step Debugging