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

Bug #19402 Syntax error when executing phpcs on Windows with parens in PHP path
Submitted: 2012-04-28 01:26 UTC
From: brandonmull Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.3.3)
PHP Version: 5.3.9 OS: Windows 7
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 : 11 + 19 = ?

 
 [2012-04-28 01:26 UTC] brandonmull (Brandon Mull)
Description: ------------ syntax error in unknown script interrupts code sniffer Recently installed PHP_CodeSniffer. No errors during install. Did not install optional dependency "phpunit/PHP_Timer". Tried running code sniffer from command line and got alert box warning of syntax error. Test script: --------------- From command line > phpcs Actual result: -------------- alert box ---------------------------- title - PHP Error message - syntax error, unexpected '(' in Unknown on line 9 ----------------------------

Comments

 [2012-04-28 02:41 UTC] squiz (Greg Sherwood)
-Status: Open +Status: Feedback -Assigned To: +Assigned To: squiz
What code are you running PHPCS on? Running the phpcs command by itself is just going to wait for user input, so the whole command you used or the output from "phpcs -h" would be helpful please.
 [2012-05-04 06:47 UTC] awtrost (Adam Trost)
I have the same issue. It happens when I run phpcs on any php file, or by just running it by itself. I just ran phpcs -h and it did it again. The odd thing is that if I just press ok on the alert box, phpcs continues on like there wasn't an issue (reports errors for the file given, prints out the phpcs help info etc. ). Not sure if this printout is what you were asking for, but here is the print out when i run phpcs -h: Alert box that contains "syntax error, unexpected '(' in Unknown on line 9" Usage: phpcs [-nwlsapvi] [-d key[=value]] [--report=<report>] [--report-file=<reportfile>] [--report-<report>=<reportf ile>] ... [--report-width=<reportWidth>] [--generator=<generator>] [--tab-width=<tabWi dth>] [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<s everity>] [--config-set key value] [--config-delete key] [--config-show] [--standard=<standard>] [--sniffs=<sniffs>] [--encoding=<encoding>] [--extensions=<extensions>] [--ignore=<patterns>] <file> ... -n Do not print warnings (shortcut for --warning-severity=0) -w Print both warnings and errors (on by default) -l Local directory only, no recursion -s Show sniff codes in all reports -a Run interactively -p Show progress of the run -v[v][v] Print verbose output -i Show a list of installed coding standards -d Set the [key] php.ini value to [value] or [true] if value is omitted --help Print this help message --version Print version information <file> One or more files and/or directories to check <extensions> A comma separated list of file extensions to check (only valid if checking a directory) <patterns> A comma separated list of patterns to ignore files and dir ectories <encoding> The encoding of the files being checked (default is iso-88 59-1) <sniffs> A comma separated list of sniff codes to limit the check t o (all sniffs must be part of the specified standard) <severity> The minimum severity required to display an error or warni ng <standard> The name or path of the coding standard to use <tabWidth> The number of spaces each tab represents <generator> The name of a doc generator to use (forces doc generation instead of checking) <report> Print either the "full", "xml", "checkstyle", "csv", "emac s" "source", "summary", "svnblame", "gitblame" or "hgblame" r eport (the "full" report is printed by default) <reportfile> Write the report to the specified file path <reportWidth> How many columns wide screen reports should be printed
 [2012-05-11 10:43 UTC] squiz (Greg Sherwood)
-Status: Feedback +Status: Assigned
 [2012-05-12 22:48 UTC] tkli (Tom Klingenberg)
Which windows and which PHP version are you running?
 [2012-05-12 23:14 UTC] awtrost (Adam Trost)
PHP 5.3.8 (cli) (built: Aug 23 2011 11:50:20) Copyright (c) 1997-2011 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies Windows 7 Professional Service pack 1
 [2012-05-13 00:41 UTC] tkli (Tom Klingenberg)
Please locate the file phpcs.bat inside the PHP installation folder. Open it with a text viewer / editor. There is one line at the end that invokes PHP and PHP_CodeSniffer CLI. Extract only the PHP command (on front) from it, e.g. this is what I have with WindowsXP SP3: "c:\Programme\PHP\.\php.exe" Open a shell (cmd) and execute it bare. Does this trigger your error as well?
 [2012-05-13 00:50 UTC] awtrost (Adam Trost)
this was what my phpcs.bat file had at the beginning of the last line: F:\Programs(x86)\PHP\php.exe ran it in a shell and it doesn't cause the same issue.
 [2012-05-13 01:16 UTC] tkli (Tom Klingenberg)
Can you start phpcs with disabling your php.ini? That is the -n switch, e.g.: php -n -d include_path="c:\Programme\PHP\pear" "c:\Programme\PHP\phpcs" -h
 [2012-05-13 01:19 UTC] awtrost (Adam Trost)
I ran the following: php -n -d include_path="c:\Programs(x86)\PHP\pear" "c:\Programs(x86)\PHP\phpcs" -h and it runs phpcs and gives the same popup error alert box ---------------------------- title - PHP Error message - syntax error, unexpected '(' in Unknown on line 9
 [2012-05-13 01:50 UTC] tkli (Tom Klingenberg)
This bug might be related: http://pear.php.net/bugs/bug.php?id=16644 - I'm on windows XP which has not that (x86) directory and I'm not able to reproduce.
 [2012-05-13 02:00 UTC] tkli (Tom Klingenberg)
Please check if adding the -f parameter and -- at the end in phpcs.bat helps. My edited line: "c:\Programme\PHP\.\php.exe" -d auto_append_file="" -d auto_prepend_file="" -d include_path="c:\Programme\PHP\pear" -f "c:\Programme\PHP\phpcs" -- %* See -f before "c:\Programme\PHP\phpcs". And see -- before %* at the end. Please insert those two changes into your line at the same positions and try again.
 [2012-05-13 02:13 UTC] awtrost (Adam Trost)
I reinstalled php into a directory without parens and it solved the problem.
 [2012-05-13 02:30 UTC] tkli (Tom Klingenberg)
Good to read that you could get it to work.
 [2012-05-13 02:30 UTC] awtrost (Adam Trost)
ya looks like that was the issue. thanks for the help!
 [2012-05-13 02:42 UTC] tkli (Tom Klingenberg)
 [2012-05-14 05:37 UTC] squiz (Greg Sherwood)
-Summary: syntax error when executing phpcs +Summary: Syntax error when executing phpcs on Windows with parens in PHP path
 [2012-05-14 05:40 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
Pull request merged: https://github.com/squizlabs/PHP_CodeSniffer/commit/21c3b4db20a3df8609ebf04c33 64b369f9464f5c Thanks a lot Tom.