|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-05-25 20:50 UTC] remco at priya dot software
Description:
------------
see the test script
( ! ) Warning: touch(): Utime failed: Operation not permitted in /mnt/c/Library/Server/Vendor/Priya/Module/File/Class/File.class.php on line 40
Test script:
---------------
//works
public static function touch($url='', $time=null, $atime=null){
if($atime === null){
return touch($url, $time);
} else {
return touch($url, $time, $atime);
}
}
// doesnt work:
public static function touch($url='', $time=null, $atime=null){
return touch($url, $time, $atime);
}
//$url = '/mnt/c/Library/Server/Vendor/Priya/Application/Data/Cache/01/1578ee0fedd628ca8227e04bfc7b1e3917fb1833.json' (length=106)
//$time = 1527281173
//$atime = null
( ! ) Warning: touch(): Utime failed: Operation not permitted in /mnt/c/Library/Server/Vendor/Priya/Module/File/Class/File.class.php on line 40
Expected result:
----------------
no warning with the "fix"...
no warning with the "doesn't work"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 21 14:00:01 2025 UTC |
There is no way to *skip* optional function parameters in PHP. A respective RFC[1] had been declined. Passing NULL to an optional parameter does *not* necessarily use its default, but NULL, which in this case is converted to 0. So it is up to the userland developer to pass appropriate default values, e.g. in this case: function my_touch($url, $time, $atime=null) { return touch($url, $time, $atime ?? $time); } [1] <https://wiki.php.net/rfc/skipparams>