Doc #80724 [Com]: FilesystemIterator::FOLLOW_SYMLINKS remove KEY_AS_FILE from bitmask

From: Date: Mon, 15 Feb 2021 05:10:28 +0000
Subject: Doc #80724 [Com]: FilesystemIterator::FOLLOW_SYMLINKS remove KEY_AS_FILE from bitmask
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18546@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80724&edit=1 ID: 80724 Comment by: camporter1 at gmail dot com Reported by: antonfedonyuk at gmail dot com Summary: FilesystemIterator::FOLLOW_SYMLINKS remove KEY_AS_FILE from bitmask Status: Open Type: Documentation Problem Package: SPL related Operating System: Any PHP Version: 7.3.27 Block user comment: N Private report: N New Comment: I noticed this testing something where I needed both FOLLOW_SYMLINKS and KEY_AS_FILENAME as well. I've submitted https://github.com/php/php-src/pull/6695 to change the behavior and test even though there might be disagreement about whether this is intentional behavior... Previous Comments: ------------------------------------------------------------------------ [2021-02-12 10:15:12] cmb@php.net This behavior seems to be a deliberate design decision[1]; it actually makes some sense, since you don't want to get the basename only for symlinks, and mixing basenames and paths could be confusing an error prone. This needs to be documented, though. [1] <https://github.com/php/php-src/blob/php-7.4.15/ext/spl/spl_directory.h#L139-L143> ------------------------------------------------------------------------ [2021-02-09 14:05:41] antonfedonyuk at gmail dot com Description: ------------ --- From manual page: https://php.net/class.filesystemiterator --- Flag FilesystemIterator::FOLLOW_SYMLINKS remove FilesystemIterator::KEY_AS_FILENAME from bitmask like this: FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::FOLLOW_SYMLINKS Test script: --------------- <?php // __DIR__ contains only self - 'test.php' $iterator = new FilesystemIterator(__DIR__, FilesystemIterator::KEY_AS_FILENAME); foreach ($iterator as $key => $value) { echo $key; } $iterator2 = new FilesystemIterator(__DIR__, FilesystemIterator::FOLLOW_SYMLINKS | FilesystemIterator::KEY_AS_FILENAME); foreach ($iterator2 as $key => $value) { echo $key; } Expected result: ---------------- iterator: 'test.php' iterator2: 'test.php' Actual result: -------------- iterator: 'test.php' iterator2: 'path/test.php' ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80724&edit=1

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