Edit report at https://bugs.php.net/bug.php?id=60996&edit=1

 ID:                 60996
 Updated by:         ahar...@php.net
 Reported by:        bob at opsat dot net
 Summary:            Slash agnostic basename()
-Status:             Open
+Status:             Wont fix
 Type:               Feature/Change Request
 Package:            *General Issues
 Operating System:   Any
 PHP Version:        5.3.10
 Block user comment: N
 Private report:     N

 New Comment:

Windows also allows / as a directory separator, which is why basename() 
supports 
both separators on that platform. Given that it's easy enough to write a 
function 
in PHP that calls explode() using \ as a delimiter and accesses the last value 
in 
the array, and namespaces _aren't_ the filesystem, extending basename() doesn't 
make much sense.


Previous Comments:
------------------------------------------------------------------------
[2012-02-06 21:48:23] bob at opsat dot net

Description:
------------
On Windows, basename() works with \ or /. On Unix platforms it only works with 
/.  
Since / is technically wrong on Windows, it should let you be technically wrong 
on  
Unix using \. Why? I noticed this while working on a custom autoloader. I was 
trying to basename('namespace\class') and was getting back 'namespace\class' on 
Unix but only getting 'class' on Windows, and 'class' was the expected output.

Since namespaces use a pseudo-filesystem structure I believe basename() (and 
probably dirname()) should be allowed to work properly on them regardless of 
the 
OS.

"But you are't dealing with files so this is dumb" - when it comes to 
autoloading, 
namespaces and classes are dealing with files... so.

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

// on unix vs on windows

spl_autoload_register(function($name){
        var_dump(basename($name));
        die();
});

new bob\ftw;

?>

Expected result:
----------------
'ftw'

Actual result:
--------------
'bob\ftw' on unix.


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=60996&edit=1

Reply via email to