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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gulli dot jonsson at gulli dot net
New email:
PHP Version: OS:

 

 [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

Pull Requests

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 Nov 21 15:01:30 2024 UTC