View Issue Details

IDProjectCategoryView StatusLast Update
0002263XdebugStep Debuggingpublic2024-07-17 18:15
Reporterduzenko Assigned Toderick  
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionwon't fix 
Summary0002263: Ignore warnings on select lines?
Description
    public function getFileAsString() {
        $path = ...
        return file_get_contents( $path );
    }

When the file $path does not exist I get a breakpoint in my IDE - which is what I usually want on PHP warnings
However this particular function (getFileAsString) was designed to return false in such cases and it's intended behavior, so I would like XDebug not to stop here.

I'd think that adding an '@' should generally prevent warning breakpoints but in practice it does not work. Is there any other to suppress warnings on specific lines of code?

Steps To Reproduce
    public function getFileAsString() {
        $path = '\tmp\exists.not';
        return file_get_contents( $path );
    }
TagsNo tags attached.
Operating System
PHP Version8.2.0-8.2.9

Activities

duzenko

2024-04-22 10:39

reporter   ~0006928

I understand that I can add a branch and check the condition manually. However in general I'd like to avoid xdebug-specific code that does not do anything useful on production

        if( !file_exists( $path ) ) return false;

derick

2024-05-06 10:46

administrator   ~0006944

Hi,

I am not sure how to do this. In many cases, people do want breakpoints when a warning gets silenced. For example, using @mysql_open() with the MySQL extension not being loaded would be mega annoying to debug otherwise.

I would think that this is a use-case specific issue which is better suited in IDEs. For example, PhpStorm already has "Step Filters" functionality (Preferences > PHP > Debug > Step Filters) which does this for stepping. It might actually also work for breakpoints too. If it doesn't, I would probably file a feature request with them.

On the Xdebug side, I can't see a reasonably simple way of how to configure this. I certainly can't make breakpoints not work for any location where @ is used, due to other use cases. I could add an option, but then IDEs need to support this toggle as well.

cheers,
Derick

duzenko

2024-05-06 11:10

reporter   ~0006946

@derick
Why does it need support from IDE?
I already have to do some configuring via the XDebug ini files, such as IP-address of the IDE machine.
Why should we not use the ini for options like this? I understand you reluctance to add a new option for every user need however I'm not sure if I'm the only person having this issue
I think that IDE step filter would not make sense here because it's too general and would also suppress warning from other lines in this function or other calls to @file_get_contents, etc

What about PHPDoc? Could it be used instead of global option?

derick

2024-07-17 18:15

administrator   ~0007005

I am not going add a new INI setting for this, as I don't really know how that setting's values should even look like. You were also the only one to ask for this.

Issue History

Date Modified Username Field Change
2024-04-22 10:37 duzenko New Issue
2024-04-22 10:39 duzenko Note Added: 0006928
2024-05-06 10:46 derick Severity minor => feature
2024-05-06 10:46 derick Status new => feedback
2024-05-06 10:46 derick Note Added: 0006944
2024-05-06 11:10 duzenko Note Added: 0006946
2024-05-06 11:10 duzenko Status feedback => new
2024-07-17 18:15 derick Assigned To => derick
2024-07-17 18:15 derick Status new => resolved
2024-07-17 18:15 derick Resolution open => won't fix
2024-07-17 18:15 derick Note Added: 0007005