php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #76097 foreach does not work with pharfileinfo
Submitted: 2018-03-14 19:56 UTC Modified: 2018-06-24 04:25 UTC
From: bonnevillessei67 at hotmail dot com Assigned:
Status: No Feedback Package: PHAR related
PHP Version: Irrelevant OS: WAMP 3.0.8
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
43 - 25 = ?
Subscribe to this entry?

 
 [2018-03-14 19:56 UTC] bonnevillessei67 at hotmail dot com
Description:
------------
---
From manual page: http://php.net/manual/en/pharfileinfo.construct.php
---

Spent two hours banging my head against the wall to find out 'foreach' does not loop over 'pharfileinfo' objects.

Please update the documentation and explain this limitation.


Test script:
---------------
    $p = new Phar('/path/to/my.phar', 0, 'my.phar');
    $p['testfile.txt'] = "hi\nthere\ndude";
    $file = $p['testfile.txt'];
    foreach ($file as $line => $text) {
        echo "line number $line: $text";
    }
    // this also works
    $file = new PharFileInfo('phar:///path/to/my.phar/testfile.txt');
    foreach ($file as $line => $text) {
        echo "line number $line: $text";
    }

Expected result:
----------------
line number 1: hi
line number 2: there
line number 3: dude
line number 1: hi
line number 2: there
line number 3: dude

Actual result:
--------------
A blank screen is displayed.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-14 19:59 UTC] requinix@php.net
-Status: Open +Status: Feedback -Package: *General Issues +Package: PHAR related
 [2018-03-14 19:59 UTC] requinix@php.net
I don't see anything that says it does. Are you confusing SplFileInfo with SplFileObject?
 [2018-06-24 04:25 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Thu Jul 02 10:01:36 2020 UTC