php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #69261 getPathname() returns path based on what's passed to the iterator
Submitted: 2015-03-19 09:47 UTC Modified: 2017-01-28 17:17 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: gulli dot jonsson at gulli dot net Assigned: salathe (profile)
Status: Assigned Package: SPL related
PHP Version: 5.5.22 OS: Fedora 20
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:
28 + 14 = ?
Subscribe to this entry?

 
 [2015-03-19 09:47 UTC] gulli dot jonsson at gulli dot net
Description:
------------
---
From manual page: http://www.php.net/directoryiterator.getpathname
---

This method only gets the pathname based on the path given when creating the DirectoryIterator, not a full pathname. The documentation could be more specific on this.

I'm assuming that the documentation is just not accurate enough and that it's not a bug in the method itself.


Test script:
---------------
<?php

foreach (new DirectoryIterator('.') as $file) {
    print $file->getPathname()."\n";
}

foreach (new DirectoryIterator(__DIR__) as $file) {
    print $file->getPathname()."\n";
}

foreach (new DirectoryIterator('somesubdir') as $file) {
    print $file->getPathname()."\n";
}


Expected result:
----------------
Based on the documentation I expected this output (skipped the . and ..)

/home/gulli/cli/directoryiterator.php
/home/gulli/cli/directoryiterator.php
/home/gulli/cli/somesubdir/somefileinsubdir.txt


Actual result:
--------------
./directoryiterator.php
/home/gulli/cli/directoryiterator.php
somesubdir/somefileinsubdir.txt


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-19 10:42 UTC] salathe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: salathe
 [2017-01-28 17:17 UTC] cmb@php.net
-Package: Documentation problem +Package: SPL related
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC