Php rename()为未记录的返回值NULL

Php rename()为未记录的返回值NULL,php,php-7.2,Php,Php 7.2,从PHP7.0更新到PHP7.2后,一些代码停止工作,我不明白为什么: $res = rename($tmpfile, $output_file); if ($res !== true) { throw new Exception("Unable to rename temporary file"); } 在php7.2中,会触发异常,尽管重命名已成功完成,但该文件完全可读,没有出现任何错误。我仍然得到了异常,因为返回值为NULL。我插入了一些调试代码: $res = rename($t

从PHP7.0更新到PHP7.2后,一些代码停止工作,我不明白为什么:

$res = rename($tmpfile, $output_file);
if ($res !== true) {
   throw new Exception("Unable to rename temporary file");
}
在php7.2中,会触发异常,尽管重命名已成功完成,但该文件完全可读,没有出现任何错误。我仍然得到了异常,因为返回值为NULL。我插入了一些调试代码:

$res = rename($tmpfile, $output_file);
log('Debug: $res ' . $res);
log('Debug: $res true? ' . $res === true);
log('Debug: $res type ' . gettype($res));
if ($res !== true) {
    throw new Exception("Unable to rename temporary file");
}
这将提供以下输出:

2018-08-03 10:37:39 Debug: $res 
2018-08-03 10:37:39 
2018-08-03 10:37:39 Debug: $res type NULL
2018-08-03 10:37:39 CURL_DOWNLOAD Exception: Unable to rename temporary file
#0 /var/www/formr.org/application/Library/Functions.php(1470): CURL::DownloadUrl('http://docs.goo...', '/var/www/formr....', NULL, 'GET', Array, Array)
如您所见,没有输出,类型为NULL。这是一种没有记录的行为。返回值只能是true或false

我找不到任何说明此函数行为已更改的文档。有人明白吗

谢谢你的帮助

编辑:var_转储输出

$res = rename($tmpfile, $output_file);
ob_start();
var_dump($res);
$contents = ob_get_contents();
ob_end_clean();
log('Debug $res: ' . $contents);
给出:

2018-08-03 12:37:40 Debug $res: NULL
正在测试终端中的rename()-函数:

user$ sudo su www-data -s /bin/bash
www-data$ php -a
Interactive mode enabled

php > $old='/var/www/path/changed/filename.xlsx';
php > $new='/var/www/path/changed/newfilename.xlsx';
php > $res = rename($old, $new);
php > var_dump($res);
bool(true)
(出于隐私原因,我更改了文件名和路径,但在原始文件上进行了测试。)

PHP版本:

$ php --version
PHP 7.2.7-0ubuntu0.18.04.2 (cli) (built: Jul  4 2018 16:55:24) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.7-0ubuntu0.18.04.2, Copyright (c) 1999-2018, by Zend Technologies
安装的PHP版本是Ubuntu 18.04附带的版本。我没有自己重新编译它

正如我刚才注意到的,这个程序有自己的两次重命名功能。但它们不是关于重命名文件,而是重命名数据库中的某些内容


它们都只有一个参数。PHP不支持重载或按参数数进行区分,因此可能存在一些干扰?到目前为止,这还不是一个问题。由于文件实际上被重命名了,我不认为调用了错误的函数。

通过Apokryfos的最后一条评论解决了这个问题:正确地使用namespace
\rename($old,$new)
调用重命名函数会给我
bool(true)
作为返回值。

简单的
var\u dump($res)
显示了什么?听起来很奇怪。我唯一能想到的是函数
rename()
的执行在实际重命名之后和返回之前的某个地方中断。您是否尝试过使用不同的输入来查看它是否持续发生?我在我的帖子中添加了var_dump的输出。它给出空值。这可能是因为你安装了一些糟糕的PHP版本,并且它修改了
rename
函数吗?我升级了帖子,插入了手动重命名,PHP版本等等。