Skip to content

Detect feature-detecting code as dead code #2540

@staabm

Description

@staabm

Its a good practice to use feature detects instead of hardcoding certain version-checks or try to sniff the environment.

This can lead to dead code, e.g.

        // prevent session locking trough other addons
        if (function_exists('session_abort')) {
            session_abort();
        } else {
            session_write_close();
        }

This code is written like that because depending on the php-version the function in question might exists or not. In case it is missing we have implemented a less optimal alternative.

When upgrading the min-php version of the project this code might easily be dead, because the function will always exist.

Maybe there is some way to detect this kind of codes and report it as dead

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions