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

 [2015-03-19 09:47 UTC] gulli dot jonsson at gulli dot net
From manual page:

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:

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 ..)


Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-19 10:42 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: salathe
 [2017-01-28 17:17 UTC]
-Package: Documentation problem +Package: SPL related
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 24 13:01:29 2024 UTC