Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Bug #10777 Sniffer class paths handled incorrectly in Windows
Submitted: 2007-04-19 12:59 UTC
From: dukekala Assigned: squiz
Status: Duplicate Package: PHP_CodeSniffer (version 0.5.0)
PHP Version: 5.2.1 OS: Windows XP
Roadmaps: (Not assigned)    
Subscription  


 [2007-04-19 12:59 UTC] dukekala (Anti Veeranna)
Description: ------------ I tried to get CodeSniffer working on Windows XP and hit the following problem: In file CodeSniffer.php around the line 224 is the following code: $className = substr($file, strpos($file, 'PHP/CodeSniffer/')); $className = substr($className, 26); $className = substr($className, 0, -4); $className = str_replace('/', '_', $className); But on Windows sometimes "\" (backslash) is used as directory separator, in which case the last str_replace doesn't do anything and when later an instance of the Sniffer class is created, then it fails, because the className still contains "/" Quick and easy fix is to change to code to deal with Windows directory separators as well: $className = str_replace('/', '_', $className); $className = str_replace("\\", '_', $className); After this change CodeSniffer started running on Windows as well

Comments

 [2007-04-19 22:06 UTC] squiz (Greg Sherwood)
I think this report may be the same issue as bug #10751 (phpcs fails with fatal error). Can you confirm? I'll be looking into these Windows issues soon, but I have to find a Windows box to test on first.
 [2007-04-20 06:07 UTC] dukekala (Anti Veeranna)
Yes, bug 10751 describes the same issue
 [2007-04-20 06:09 UTC] dukekala (Anti Veeranna)
Or, rather, #10751 describes 2 separate issues - one is with Windows directory separators (which is the same as here) and another is about the linefeeds.
 [2007-04-21 00:51 UTC] squiz (Greg Sherwood)
I'll be working on both issues in the other bug, so I'll mark this as a duplicate for clarity. Thank you for spending the time to report the bug and provide a patch.