1.2.731. Multiple Declaration Of Strict_types¶
At least two declare() commands are declaring strict_types in one file. Only one is sufficient, and should be the first expression in the file.
Indeed, any strict_types set to 1 will have the final word. Setting strict_types to 0 will not revert the configuration, wherever is this call made.
<?php
declare(strict_types=1);
declare(strict_types=1);
// rest of the code
?>
See also Declare.
1.2.731.1. Connex PHP features¶
1.2.731.1.1. Suggestions¶
Remove all but one of them. Keep the first one.
1.2.731.1.2. Specs¶
Short name |
Php/MultipleDeclareStrict |
Rulesets |
|
Exakat since |
2.1.8 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |