View Issue Details

IDProjectCategoryView StatusLast Update
0002131XdebugStep Debuggingpublic2022-11-02 16:38
Reportermoises_flowize Assigned Toderick  
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionno change required 
PlatformUbuntu over WSLOSWindowsOS Version10
Product Version3.1.5 
Summary0002131: Internal pointer of SplFileObject is modified for every "Step Over"
Description

The debugger is updating the internal pointer of a SplFileObjectfor every "step over" after opening the file.

Steps To Reproduce

$file_stream = new SplFileObject('/home/my-file.csv', 'rb');

echo $file_stream->current();
echo $file_stream->current();
echo $file_stream->current();
echo $file_stream->current();
echo $file_stream->current();
echo $file_stream->current();

If you stop at the breakpoint after opening the file, every time you execute a "Step over" it will move the internal pointer, and it will output a different line.
If you don't execute the "step over", then the content of the line is correct.

Tagsphp8.0, PHPStorm, SPL
Attached Files
xdebub-bug.png (98,486 bytes)   
xdebub-bug.png (98,486 bytes)   
xdebub-bug2.png (58,585 bytes)   
xdebub-bug2.png (58,585 bytes)   
Operating SystemUBuntu run over WSL in Windows 10
PHP Version8.0.20-8.0.29

Activities

derick

2022-10-31 10:03

administrator   ~0006416

Thanks for your report, I'll have a look at at later time. It would not surprise me if this is actually a bug in Spl, where it advances when it shouldn't though.

derick

2022-11-02 16:22

administrator   ~0006425

Hi,

as expected, this is a bug in Spl. It advances the file pointer when you call __toString. The following script (not run with the debugger), also shows this problem:

<?php
$file_stream = new SplFileObject(__FILE__, 'rb');

echo $file_stream->current(); (string) $file_stream; // line 4
echo $file_stream->current(); (string) $file_stream; // line 5
echo $file_stream->current(); (string) $file_stream; // line 6
echo $file_stream->current(); (string) $file_stream; // line 7
echo $file_stream->current(); (string) $file_stream; // line 8
echo $file_stream->current(); (string) $file_stream; // line 9
?>

This bug gets triggered because PhpStorm 2022.2 has a new __toString object view. You can turn this off through "PHP » Debug » Evaluation » Enable '__toString' object view" to work around this.

As this is not a bug in Xdebug, I am closing this ticket.

cheers,
Derick

derick

2022-11-02 16:29

administrator   ~0006427

Apparently this is not a bug in Spl either, but a "feature": https://www.php.net/manual/en/splfileobject.tostring.php — I'll make a ticket with PhpStorm, to turn this off for SplFileObject.

derick

2022-11-02 16:38

administrator   ~0006429

https://youtrack.jetbrains.com/issue/WI-69513/toString-object-view-causes-reads-with-SplFileObject

Issue History

Date Modified Username Field Change
2022-10-28 10:22 moises_flowize New Issue
2022-10-28 10:22 moises_flowize Tag Attached: php8.0
2022-10-28 10:22 moises_flowize Tag Attached: PHPStorm
2022-10-28 10:22 moises_flowize Tag Attached: SPL
2022-10-28 10:22 moises_flowize File Added: xdebub-bug.png
2022-10-28 10:22 moises_flowize File Added: xdebub-bug2.png
2022-10-31 10:03 derick Assigned To => derick
2022-10-31 10:03 derick Status new => acknowledged
2022-10-31 10:03 derick Note Added: 0006416
2022-11-02 16:22 derick Status acknowledged => resolved
2022-11-02 16:22 derick Resolution open => no change required
2022-11-02 16:22 derick Note Added: 0006425
2022-11-02 16:29 derick Note Added: 0006427
2022-11-02 16:38 derick Note Added: 0006429