|  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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2018-03-14 19:56 UTC] bonnevillessei67 at hotmail dot com
From manual page:

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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-03-14 19:59 UTC]
-Status: Open +Status: Feedback -Package: *General Issues +Package: PHAR related
 [2018-03-14 19:59 UTC]
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: Wed Oct 21 08:01:23 2020 UTC