-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix 8861 properly #8869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Fix 8861 properly #8869
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
--TEST-- | ||
Check Glob iterator is okay with SplFileInfo getPath method calls | ||
--FILE-- | ||
<?php | ||
|
||
$o = new GlobIterator(__DIR__.'/*.abcdefghij'); | ||
|
||
echo "Test getATime()\n"; | ||
var_dump($o->getATime()); | ||
echo "Test getBasename()\n"; | ||
var_dump($o->getBasename()); | ||
echo "Test getCTime()\n"; | ||
var_dump($o->getCTime()); | ||
echo "Test getExtension()\n"; | ||
var_dump($o->getExtension()); | ||
echo "Test getFilename()\n"; | ||
var_dump($o->getFilename()); | ||
echo "Test getGroup()\n"; | ||
var_dump($o->getGroup()); | ||
echo "Test getInode()\n"; | ||
var_dump($o->getInode()); | ||
echo "Test getMTime()\n"; | ||
var_dump($o->getMTime()); | ||
echo "Test getOwner()\n"; | ||
var_dump($o->getOwner()); | ||
echo "Test getPath()\n"; | ||
var_dump($o->getPath()); | ||
echo "Test getPathInfo()\n"; | ||
var_dump($o->getPathInfo()); | ||
echo "Test getPathname()\n"; | ||
var_dump($o->getPathname()); | ||
echo "Test getPerms()\n"; | ||
var_dump($o->getPerms()); | ||
echo "Test getRealPath()\n"; | ||
var_dump($o->getRealPath()); | ||
echo "Test getSize()\n"; | ||
var_dump($o->getSize()); | ||
echo "Test getType()\n"; | ||
var_dump($o->getType()); | ||
echo "Test isDir()\n"; | ||
var_dump($o->isDir()); | ||
echo "Test isExecutable()\n"; | ||
var_dump($o->isExecutable()); | ||
echo "Test isFile()\n"; | ||
var_dump($o->isFile()); | ||
echo "Test isLink()\n"; | ||
var_dump($o->isLink()); | ||
echo "Test isReadable()\n"; | ||
var_dump($o->isReadable()); | ||
echo "Test isWritable()\n"; | ||
var_dump($o->isWritable()); | ||
echo "Test __toString()\n"; | ||
var_dump($o->__toString()); | ||
echo "Test __debugInfo()\n"; | ||
var_dump($o); | ||
|
||
?> | ||
--EXPECTF-- | ||
Test getATime() | ||
bool(false) | ||
Test getBasename() | ||
string(0) "" | ||
Test getCTime() | ||
bool(false) | ||
Test getExtension() | ||
string(0) "" | ||
Test getFilename() | ||
string(0) "" | ||
Test getGroup() | ||
bool(false) | ||
Test getInode() | ||
bool(false) | ||
Test getMTime() | ||
bool(false) | ||
Test getOwner() | ||
bool(false) | ||
Test getPath() | ||
string(0) "" | ||
Test getPathInfo() | ||
NULL | ||
Test getPathname() | ||
string(0) "" | ||
Test getPerms() | ||
bool(false) | ||
Test getRealPath() | ||
string(%d) "%s" | ||
Test getSize() | ||
bool(false) | ||
Test getType() | ||
bool(false) | ||
Test isDir() | ||
bool(false) | ||
Test isExecutable() | ||
bool(false) | ||
Test isFile() | ||
bool(false) | ||
Test isLink() | ||
bool(false) | ||
Test isReadable() | ||
bool(false) | ||
Test isWritable() | ||
bool(false) | ||
Test __toString() | ||
string(0) "" | ||
Test __debugInfo() | ||
object(GlobIterator)#1 (4) { | ||
["pathName":"SplFileInfo":private]=> | ||
string(0) "" | ||
["fileName":"SplFileInfo":private]=> | ||
string(0) "" | ||
["glob":"DirectoryIterator":private]=> | ||
string(%d) "glob://%s" | ||
["subPathName":"RecursiveDirectoryIterator":private]=> | ||
string(0) "" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
--TEST-- | ||
SPL: SplFileInfo::_debugInfo() basic test | ||
--FILE-- | ||
<?php | ||
// without $suffix | ||
var_dump(new \SplFileInfo('/path/to/a.txt')); | ||
var_dump(new \SplFileInfo('path/to/b')); | ||
var_dump(new \SplFileInfo('c.txt')); | ||
var_dump(new \SplFileInfo('d')); | ||
var_dump(new \SplFileInfo('~/path/to//e')); | ||
|
||
// with $suffix | ||
var_dump(new \SplFileInfo('path/to/a.txt')); | ||
var_dump(new \SplFileInfo('path/to/bbb.txt')); | ||
var_dump(new \SplFileInfo('path/to/ccc.txt')); | ||
var_dump(new \SplFileInfo('d.txt')); | ||
var_dump(new \SplFileInfo('e.txt')); | ||
var_dump(new \SplFileInfo('f')); | ||
?> | ||
--EXPECT-- | ||
object(SplFileInfo)#1 (2) { | ||
["pathName":"SplFileInfo":private]=> | ||
string(14) "/path/to/a.txt" | ||
["fileName":"SplFileInfo":private]=> | ||
string(5) "a.txt" | ||
} | ||
object(SplFileInfo)#1 (2) { | ||
["pathName":"SplFileInfo":private]=> | ||
string(9) "path/to/b" | ||
["fileName":"SplFileInfo":private]=> | ||
string(1) "b" | ||
} | ||
object(SplFileInfo)#1 (2) { | ||
["pathName":"SplFileInfo":private]=> | ||
string(5) "c.txt" | ||
["fileName":"SplFileInfo":private]=> | ||
string(5) "c.txt" | ||
} | ||
object(SplFileInfo)#1 (2) { | ||
["pathName":"SplFileInfo":private]=> | ||
string(1) "d" | ||
["fileName":"SplFileInfo":private]=> | ||
string(1) "d" | ||
} | ||
object(SplFileInfo)#1 (2) { | ||
["pathName":"SplFileInfo":private]=> | ||
string(12) "~/path/to//e" | ||
["fileName":"SplFileInfo":private]=> | ||
string(1) "e" | ||
} | ||
object(SplFileInfo)#1 (2) { | ||
["pathName":"SplFileInfo":private]=> | ||
string(13) "path/to/a.txt" | ||
["fileName":"SplFileInfo":private]=> | ||
string(5) "a.txt" | ||
} | ||
object(SplFileInfo)#1 (2) { | ||
["pathName":"SplFileInfo":private]=> | ||
string(15) "path/to/bbb.txt" | ||
["fileName":"SplFileInfo":private]=> | ||
string(7) "bbb.txt" | ||
} | ||
object(SplFileInfo)#1 (2) { | ||
["pathName":"SplFileInfo":private]=> | ||
string(15) "path/to/ccc.txt" | ||
["fileName":"SplFileInfo":private]=> | ||
string(7) "ccc.txt" | ||
} | ||
object(SplFileInfo)#1 (2) { | ||
["pathName":"SplFileInfo":private]=> | ||
string(5) "d.txt" | ||
["fileName":"SplFileInfo":private]=> | ||
string(5) "d.txt" | ||
} | ||
object(SplFileInfo)#1 (2) { | ||
["pathName":"SplFileInfo":private]=> | ||
string(5) "e.txt" | ||
["fileName":"SplFileInfo":private]=> | ||
string(5) "e.txt" | ||
} | ||
object(SplFileInfo)#1 (2) { | ||
["pathName":"SplFileInfo":private]=> | ||
string(1) "f" | ||
["fileName":"SplFileInfo":private]=> | ||
string(1) "f" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--TEST-- | ||
SPL: SplFileInfo::getBasename() basic test | ||
--FILE-- | ||
<?php | ||
// without $suffix | ||
echo (new \SplFileInfo('/path/to/a.txt'))->getBasename() . PHP_EOL; | ||
echo (new \SplFileInfo('path/to/b'))->getBasename() . PHP_EOL; | ||
echo (new \SplFileInfo('c.txt'))->getBasename() . PHP_EOL; | ||
echo (new \SplFileInfo('d'))->getBasename() . PHP_EOL; | ||
echo (new \SplFileInfo('~/path/to//e'))->getBasename() . PHP_EOL . PHP_EOL; | ||
|
||
// with $suffix | ||
echo (new \SplFileInfo('path/to/a.txt'))->getBasename('.txt') . PHP_EOL; | ||
echo (new \SplFileInfo('path/to/bbb.txt'))->getBasename('b.txt') . PHP_EOL; | ||
echo (new \SplFileInfo('path/to/ccc.txt'))->getBasename('to/ccc.txt') . PHP_EOL; | ||
echo (new \SplFileInfo('d.txt'))->getBasename('txt') . PHP_EOL; | ||
echo (new \SplFileInfo('e.txt'))->getBasename('e.txt') . PHP_EOL; | ||
echo (new \SplFileInfo('f'))->getBasename('.txt'); | ||
?> | ||
--EXPECT-- | ||
a.txt | ||
b | ||
c.txt | ||
d | ||
e | ||
|
||
a | ||
bb | ||
ccc.txt | ||
d. | ||
e.txt | ||
f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--TEST-- | ||
SPL: SplFileInfo::getFilename() basic test | ||
--FILE-- | ||
<?php | ||
|
||
echo (new \SplFileInfo('/path/to/a.txt'))->getFilename() . PHP_EOL; | ||
echo (new \SplFileInfo('path/to/b'))->getFilename() . PHP_EOL; | ||
echo (new \SplFileInfo('c.txt'))->getFilename() . PHP_EOL; | ||
echo (new \SplFileInfo('d'))->getFilename() . PHP_EOL; | ||
echo (new \SplFileInfo('~/path/to//e'))->getFilename() . PHP_EOL . PHP_EOL; | ||
|
||
?> | ||
--EXPECT-- | ||
a.txt | ||
b | ||
c.txt | ||
d | ||
e |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't that be a leading slash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this behaves differently on a windows machine, but
\SplFileInfo
IMHO always only worked properly with forward slashes. See https://3v4l.org/lsPaS.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huuum maybe it's wording, I used trailing as in
'foo/bar.baz'
the path isfoo
so we need to skip the slash just afterfoo
therefore trailing the path?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, more reasons for me to hate SPL :|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, that works as expected on Windows (3v4l.org runs Linux).