php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #69560 Example comment is incorrect for PharData::compress().
Submitted: 2015-05-01 20:24 UTC Modified: 2016-07-01 20:19 UTC
From: wbuckner at connecteddata dot com Assigned: peehaa (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.6.8 OS: Mac OS X
Private report: No CVE-ID: None
 [2015-05-01 20:24 UTC] wbuckner at connecteddata dot com
Description:
------------
---
From manual page: http://www.php.net/phardata.compress
---

Example #1 incorrectly uses ".phar" instead of ".tar" in the comments. Comments read:

$p1 = $p->compress(Phar::GZ); // copies to /path/to/my.phar.gz <<< HERE
$p2 = $p->compress(Phar::BZ2); // copies to /path/to/my.phar.bz2 <<< HERE
$p3 = $p2->compress(Phar::NONE); // exception: /path/to/my.phar already exists <<<HERE



I fixed it in the online doc editor but not sure if it saved. The reason this happened is the docblock was copied from Phar::compress() but this is PharData::compress()!

Test script:
---------------
php > $p = new PharData('my.tar');
php > $p['myfile.txt'] = 'hi';
php > $p['myfile2.txt'] = 'hi';
php > $p1 = $p->compress(Phar::GZ);

$ ls my.*
my.tar  my.tar.gz

Expected result:
----------------
<?php
$p = new PharData('/path/to/my.tar');
$p['myfile.txt'] = 'hi';
$p['myfile2.txt'] = 'hi';
$p1 = $p->compress(Phar::GZ); // copies to /path/to/my.tar.gz
$p2 = $p->compress(Phar::BZ2); // copies to /path/to/my.tar.bz2
$p3 = $p2->compress(Phar::NONE); // exception: /path/to/my.tar already exists
?>


Actual result:
--------------
<?php
$p = new PharData('/path/to/my.tar');
$p['myfile.txt'] = 'hi';
$p['myfile2.txt'] = 'hi';
$p1 = $p->compress(Phar::GZ); // copies to /path/to/my.phar.gz
$p2 = $p->compress(Phar::BZ2); // copies to /path/to/my.phar.bz2
$p3 = $p2->compress(Phar::NONE); // exception: /path/to/my.phar already exists
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-05-04 11:53 UTC] peehaa@php.net
-Assigned To: +Assigned To: peehaa
 [2016-07-01 20:19 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 [2016-07-01 20:19 UTC] cmb@php.net
This issue has already been fixed in the meantime. Nonetheless,
thanks for your report, and for helping to make our documentation
better.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 13:01:29 2024 UTC