1.2.1328. Use Constants As Returns¶
When a native PHP function returns only constants, it is recommended to use those constants to identify the returned values.
<?php
if (preg_last_error() != PREG_NO_ERROR ) {
// An error occured with the last Regex call
}
// Who will guess PREG_JIT_STACKLIMIT_ERROR ?
if (preg_last_error() == 6 ) {
// An error occured with the last Regex call
}
?>
1.2.1328.1. Suggestions¶
Use the valid constants to identify the results
1.2.1328.2. Specs¶
Short name |
Functions/UseConstantsAsReturns |
Rulesets |
|
Exakat since |
2.3.9 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Available in |