php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74214 Phar::extractTo() accepts null to skip $files
Submitted: 2017-03-06 23:23 UTC Modified: 2018-01-29 23:31 UTC
Votes:2
Avg. Score:2.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: benjamin dot morel at gmail dot com Assigned: vrana (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: N/A
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: benjamin dot morel at gmail dot com
New email:
PHP Version: OS:

 

 [2017-03-06 23:23 UTC] benjamin dot morel at gmail dot com
Description:
------------
The documented signature of extractTo() is:

public bool Phar::extractTo ( string $pathto [, string|array $files [, bool $overwrite = false ]] )

Consider that I want to extract all files from a Phar archive to a directory, overwriting existing files; I need to skip the $files parameter to set $overwrite to true.

With $files accepting string|array, I tried an empty string:

$phar->extractTo('dir', '', true);

But this yields an exception:
PharException: Phar Error: attempted to extract non-existent file ""

I also tried an empty array:

$phar->extractTo('dir', [], true);

But it does not extract any file.

Actually, the only thing that works to actually skip the $files parameter is to pass a null value:

$phar->extractTo('dir', null, true);

So it would be nice to document the fact that $files can accept null as well.

Expected result:
----------------
public bool Phar::extractTo ( string $pathto [, string|array|null $files [, bool $overwrite = false ]] )

...

files

The name of a file or directory to extract, or an array of files/directories to extract, or null to skip the parameter

Actual result:
--------------
public bool Phar::extractTo ( string $pathto [, string|array $files [, bool $overwrite = false ]] )

...

files

The name of a file or directory to extract, or an array of files/directories to extract

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-29 23:31 UTC] vrana@php.net
Automatic comment from SVN on behalf of vrana
Revision: http://svn.php.net/viewvc/?view=revision&revision=344088
Log: Document null files (bug #74214)
 [2018-01-29 23:31 UTC] vrana@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: vrana
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 10:01:31 2024 UTC