UsingInclusionReturnValue
info off by defaultGroup: Code style · PhpStorm name: UsingInclusionReturnValueInspection
Using the value produced by include/require (a file that returns something) couples code to file layout and hides dependencies. Prefer explicit objects or functions; inclusion should be a standalone statement.
Example
php
<?php
require_once __DIR__ . '/bootstrap.php';
include('helpers.php');
function settings(array $env) {
$base = require __DIR__ . '/base.php';
merge(include_once 'extra.php');
$env['db'] = require_once('db.php');
if (true !== include 'optional.php') {
log_missing();
}
return include('defaults.php');
}Reported:
- line 6: Avoid relying on the value returned by an included file.
- line 7: Avoid relying on the value returned by an included file.
- line 8: Avoid relying on the value returned by an included file.
- line 9: Avoid relying on the value returned by an included file.
- line 12: Avoid relying on the value returned by an included file.
Configure
In custos.json:
json
{
"rules": {
"UsingInclusionReturnValue": {
"enabled": true
}
}
}Suppress
Before the statement or declaration (or the first statement of the file), either of:
php
// @custos-ignore UsingInclusionReturnValue
/**
* @noinspection UsingInclusionReturnValueInspection
*/