Doc #51732 [Csd->Asn]: Fileinfo __construct with explicit magic file
| From: | pajoye@php.net | Date: | Tue, 04 May 2010 08:52:39 +0000 |
| Subject: | Doc #51732 [Csd->Asn]: Fileinfo __construct with explicit magic file | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-4301@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51732&edit=1
ID: 51732
Updated by: pajoye@php.net
Reported by: franssen dot roland at gmail dot com
Summary: Fileinfo __construct with explicit magic file
-Status: Closed
+Status: Assigned
Type: Documentation Problem
Package: Filesystem function related
Operating System: WINNT
PHP Version: 5.3SVN-2010-05-03 (SVN)
-Assigned To: pajoye
+Assigned To: kalle
New Comment:
However please add a note in the documentation to avoid any kind of
confusions :)
Previous Comments:
------------------------------------------------------------------------
[2010-05-04 10:51:11] pajoye@php.net
Fixed in svn.
Kalle, it allows to set default value to NULL like:
function foo($v=NULL) {
$fileInfo = new finfo(FILEINFO_MIME, $v);
}
without having to test for $v. Other PHP functions act like that.
------------------------------------------------------------------------
[2010-05-04 10:49:00] pajoye@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=298947
Log: - Fixed bug #51732, Fileinfo __construct or open does not work with
NULL
------------------------------------------------------------------------
[2010-05-04 10:01:13] kalle@php.net
Why are you trying to instanciate with the second parameter to the
default value when its optional?
Many functions depends internally on if 2 arguments were sent, if so
then no matter of the value of that specific parameter. In this case
NULL is simply a placeholder.
------------------------------------------------------------------------
[2010-05-03 21:51:44] franssen dot roland at gmail dot com
Description:
------------
Not sure i've filled in correct PHP version; it's 5.3.1 however
(packaged with xampplite 1.7.3).
Im trying to initialize a fileinfo (finfo) object with an explicit NULL
value as 2nd parameter assuming it can locate the magic file by
default.
Which should be fine, corresponding the documentation;
"__construct ([ int $options = FILEINFO_NONE [, string $magic_file =
NULL ]] )"
@ http://php.net/manual/en/function.finfo-open.php
Test script:
---------------
<?php
$fileInfo = new finfo(FILEINFO_MIME, null);
var_dump($fileInfo);
$fileInfo = new finfo(FILEINFO_MIME);
var_dump($fileInfo);
?>
Expected result:
----------------
object(finfo)#2 (0) { }
object(finfo)#5 (0) { }
Actual result:
--------------
Warning: finfo::finfo(): Failed to load magic database at ''. in *** on
line ***
object(finfo)#2 (0) { }
object(finfo)#5 (0) { }
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51732&edit=1