🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Function signature: xdebug's xdebug_get_profiler_filename can return false : PHPStan 2.1.56 thinks otherwise #14736

Description

@rbairwell

Bug report

According to https://xdebug.org/docs/all_functions#xdebug_get_profiler_filename :

xdebug_get_profiler_filename() : mixed #
Returns the profile information filename

Returns the name of the file which is used to save profile information to, or false if the profiler is not active.

However, given the code:

<?php
if (!extension_loaded('xdebug')) {
    print "Not installed\n";
    exit();
}
if (xdebug_is_debugger_active()) {
    print "Debugger is not active\n";
}
if (xdebug_code_coverage_started()) {
    print "Code coverage is not active\n";
}
if (xdebug_get_gcstats_filename() !== false) {
    print "No garbage collection stats enabled\n";
}
if (xdebug_get_profiler_filename() !== false) {
    print "No profiler enabled\n";
}

PHPStan v2.1.56 reports:

  Line   phpstantest.php                                                                     
 ------ ------------------------------------------------------------------------------------ 
  :15    Strict comparison using !== between string and false will always evaluate to true.  
         🪪  notIdentical.alwaysTrue                                                         
 ------ ------------------------------------------------------------------------------------ 

indicating it is not taking the possible "false" return into account.

I cannot see the xdebug stub on https://github.com/phpstan/phpstan-src/tree/2.1.x/stubs so I do not know how PHPStan is aware of the xdebug_is_debugger_active , xdebug_code_coverage_started and xdebug_get_gcstats_filename functions but is getting xdebug_get_profiler_filename incorrect.

Code snippet that reproduces the problem

https://phpstan.org/r/f7ff962b-5083-4214-81a7-0932db3f86ee

Expected output

None.

Did PHPStan help you today? Did it make you happy in any way?

Slightly annoyed but the issue - but more annoyed that when I went to report this, I got the issue auto-closed with "Looks like you opened an issue without following one of the issue templates:" despite me using the provided issue template "Function signature mismatch".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions