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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bonnevillessei67 at hotmail dot com
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 07:01:32 2024 UTC