Doc #76097 [Opn->Fbk]: foreach does not work with pharfileinfo

From: Date: Wed, 14 Mar 2018 19:59:15 +0000
Subject: Doc #76097 [Opn->Fbk]: foreach does not work with pharfileinfo
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15526@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76097&edit=1 ID: 76097 Updated by: requinix@php.net Reported by: bonnevillessei67 at hotmail dot com Summary: foreach does not work with pharfileinfo -Status: Open +Status: Feedback Type: Documentation Problem -Package: *General Issues +Package: PHAR related Operating System: WAMP 3.0.8 PHP Version: Irrelevant Block user comment: N Private report: N New Comment: I don't see anything that says it does. Are you confusing SplFileInfo with SplFileObject? Previous Comments: ------------------------------------------------------------------------ [2018-03-14 19:56:24] 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76097&edit=1

« previous php.doc.bugs (#15526) next »