Doc #69339 [Opn->Csd]: realpath(false) returns CWD

From: Date: Sat, 06 Oct 2018 11:57:23 +0000
Subject: Doc #69339 [Opn->Csd]: realpath(false) returns CWD
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16053@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69339&edit=1 ID: 69339 Updated by: cmb@php.net Reported by: sebastian@php.net Summary: realpath(false) returns CWD -Status: Open +Status: Closed Type: Documentation Problem Package: Filesystem function related Operating System: Linux PHP Version: 5.6.7 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2018-10-06 11:56:55] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=345785 Log: Fix #69339: realpath(false) returns CWD There is nothing special with realpath() regarding type juggling, so there's no need to mention that NULL can be passed instead of an empty string. That even wouldn't work for strict_types. ------------------------------------------------------------------------ [2015-03-31 10:52:36] cmb@php.net Having a look at the implementation of realpath[1], there is nothing special with the arguments '' or NULL happening. Actually, realpath expects a string, so other argument types will be juggled to string, and an empty string is treated as relative path. That's seems to be pretty fine, so I'm changing to "Documentation Problem". However, I'm not sure that it makes sense to document special cases such as NULL and FALSE(or even simplexml_load_string('<foo></foo>')). [1] <http://lxr.php.net/xref/PHP_5_6/ext/standard/file.c#2306> ------------------------------------------------------------------------ [2015-03-31 09:04:32] sebastian@php.net Description: ------------ realpath(false) returns the CWD. This is the behavior that the manual describes for blank or NULL values: "Whilst a path must be supplied, the value can be blank or NULL In these cases, the value is interpreted as the current directory." Either this is a bug in PHP or the documented needs to be amended. Test script: --------------- <?php var_dump(realpath(false)); var_dump(realpath(true)); var_dump(realpath(0)); var_dump(realpath(null)); var_dump(realpath('')); Expected result: ---------------- bool(false) bool(false) bool(false) string(8) "/home/sb" string(8) "/home/sb" Actual result: -------------- string(8) "/home/sb" bool(false) bool(false) string(8) "/home/sb" string(8) "/home/sb" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69339&edit=1

« previous php.doc.bugs (#16053) next »