Removing warning for failed include
| From: | Levi Morrison via internals | Date: | Thu, 26 Mar 2020 00:11:02 +0000 |
| Subject: | Removing warning for failed include | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-109315@lists.php.net to get a copy of this message | ||
It's bothered me for quite some time that a failed include emits a
warning. This is because it's by design that the author chose
include and not require. It's _expected_ that it may fail and they
are okay with that.
As an example, consider a classic autoloading case. It could be as
simple and performant as:
$file = /* something derived from class name */;
include $file;
But because of the warning, in practice authors tend to use
file_exists + require instead:
$file = /* something derived from class name */;
if (file_exists($file)) {
require $file;
}
Weird isn't it? Authors are using require instead of include for the
case where failure is tolerated. This is a clear signal to me that
include isn't doing its job. The warning gets in the way.
Any reasons we shouldn't just remove this warning for PHP 8?