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

Bug #20234 phpcbf patch command absolute paths
Submitted: 2014-04-06 04:15 UTC
From: klausi Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version SVN)
PHP Version: 5.5.11 OS: Ubuntu 13.10
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 27 - 26 = ?

 
 [2014-04-06 04:15 UTC] klausi (Klaus Purer)
Description: ------------ The generated phpcbf-fixed.diff contains references to absolute paths, therefore the patch command used to apply the changes fails. Output of phpcbf: Array ( [0] => Ignoring potentially dangerous file name /home/klausi/workspace/coder/coder_sniffer/Test/good2.php [1] => can't find file to patch at input line 3 [2] => Perhaps you used the wrong -p or --strip option? [3] => The text leading up to this was: [4] => -------------------------- [5] => |--- /home/klausi/workspace/coder/coder_sniffer/Test/good2.php [6] => |+++ PHP_CodeSniffer [7] => -------------------------- [8] => No file to patch. Skipping patch. [9] => 1 out of 1 hunk ignored ) Returned: 1

Comments

 [2014-04-07 06:34 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz
I've committed a potential fix here: https://github.com/squizlabs/PHP_CodeSniffer/commit/d5ed485c2baae89b372e2682f3 c97e2250181ced I don't have access to a patch version that has this problem (looks to be 2.7+) so I can't actually replicate the issue. If you are able to test and let me know, I would appreciate it. The code still works on older patch versions for me.
 [2014-05-03 00:15 UTC] phlopsi (Patrick Fischer)
It seems i am having a related problem so i didn't open a new issue. I am running Windows 7, have PHP Version 5.5.8 and installed phpcbf through composer (composer global require "squizlabs/php_codesniffer=2.0.x@dev") I ran the following command to beautify/fix AccessControl.php, also found on bitbucket (https://bitbucket.org/Phlopsi/access-control/src/82ab6e0dd76b59dd6eb7bd0c12e48f62dc4e327e/src/org/bitbucket/phlopsi/access_control/AccessControl.php?at=0.1.0): C:\Users\Patrick\Downloads>phpcbf.bat --standard=PSR2 -vvv AccessControl.php > report.txt cygwin warning: MS-DOS style path detected: C:\Users\Patrick\Downloads\AccessControl.php Preferred POSIX equivalent is: /cygdrive/c/Users/Patrick/Downloads/AccessControl.php CYGWIN environment variable option "nodosfilewarning" turns off this warning. Consult the user's guide for more details about POSIX paths: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames cygwin warning: MS-DOS style path detected: C:\Users\Patrick\Downloads/phpcbf-fixed.diff Preferred POSIX equivalent is: /cygdrive/c/Users/Patrick/Downloads/phpcbf-fixed.diff CYGWIN environment variable option "nodosfilewarning" turns off this warning. Consult the user's guide for more details about POSIX paths: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames Yes, the message came twice. I also noticed that some directory separators are mixed Windows/Linux, in the report file too. Report can be found here: https://gist.github.com/phlopsi/b06b0339f748be6fa997#file-report-txt
 [2014-05-06 05:25 UTC] squiz (Greg Sherwood)
I've committed another fix here: https://github.com/squizlabs/PHP_CodeSniffer/commit/2e2a712fd344f64ae1de498ba0 81c615283cf9f8 This gets me relative paths on Windows under cygwin. You you please try that out.
 [2014-05-06 11:51 UTC] phlopsi (Patrick Fischer)
my file got fixed correctly, now. thank you. btw, the warnings are still there but the directory separators in it are not mixed anymore, so i guess it just doesn't like windows paths in general =) C:\Users\Patrick\Downloads>phpcbf.bat --standard=PSR2 -vvv AccessControl.php > report.txt cygwin warning: MS-DOS style path detected: C:\Users\Patrick\Downloads\phpcs-fixed.tmp Preferred POSIX equivalent is: /cygdrive/c/Users/Patrick/Downloads/phpcs-fixed.tmp CYGWIN environment variable option "nodosfilewarning" turns off this warning. Consult the user's guide for more details about POSIX paths: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames cygwin warning: MS-DOS style path detected: C:\Users\Patrick\Downloads/phpcbf-fixed.diff Preferred POSIX equivalent is: /cygdrive/c/Users/Patrick/Downloads/phpcbf-fixed.diff CYGWIN environment variable option "nodosfilewarning" turns off this warning. Consult the user's guide for more details about POSIX paths: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames just for reference, i updated the report here: https://gist.github.com/phlopsi/b06b0339f748be6fa997#file-report-txt
 [2014-05-06 11:55 UTC] squiz (Greg Sherwood)
-Status: Feedback +Status: Closed
Thanks for testing this for me. I'll close this off now as I think it's working on a few platforms.