benmatselby / atom-php-checkstyle

✅ [DEPRECATED] Checkstyle reporter for PHP, utilising phpcs, phpmd, php linter and php-cs-fixer
MIT License
21 stars 5 forks source link

Getting exception 'UnexpectedValueException' upon running phpcs #19

Closed jegtnes closed 10 years ago

jegtnes commented 10 years ago

Hey there,

I've installed this package and set the right executable paths for phpcs, phpcsfixer, and phpmd. All of these have been installed with Homebrew.

Phpmd works, but when enabling phpcs I get an error every time the package runs. Looking at Atom's console, running the same command in Terminal results in the following UnexpectedValueExceptions:

/usr/local/bin/php -l -d display_errors=On /Path/to/File.php; /usr/local/bin/phpcs --standard=PSR2 --report=checkstyle /Path/to/File.php; /usr/local/bin/phpmd /Path/to/File.php text codesize,cleancode,controversial,naming,unusedcode;  
No syntax errors detected in /Path/to/File.php
PHP Fatal error:  Uncaught exception 'UnexpectedValueException' with message 'DirectoryIterator::__construct(/usr/local/etc/php-code-sniffer/Standards): failed to open dir: No such file or directory' in /usr/local/Cellar/php-code-sniffer/1.5.2/CodeSniffer.php:1961
Stack trace:
#0 /usr/local/Cellar/php-code-sniffer/1.5.2/CodeSniffer.php(1961): DirectoryIterator->__construct('/usr/local/etc/...')
#1 /usr/local/Cellar/php-code-sniffer/1.5.2/CodeSniffer/CLI.php(733): PHP_CodeSniffer::getInstalledStandards()
#2 /usr/local/Cellar/php-code-sniffer/1.5.2/CodeSniffer/CLI.php(538): PHP_CodeSniffer_CLI->validateStandard(Array)
#3 /usr/local/Cellar/php-code-sniffer/1.5.2/scripts/phpcs(37): PHP_CodeSniffer_CLI->process()
#4 {main}
  thrown in /usr/local/Cellar/php-code-sniffer/1.5.2/CodeSniffer.php on line 1961

Fatal error: Uncaught exception 'UnexpectedValueException' with message 'DirectoryIterator::__construct(/usr/local/etc/php-code-sniffer/Standards): failed to open dir: No such file or directory' in /usr/local/Cellar/php-code-sniffer/1.5.2/CodeSniffer.php:1961
Stack trace:
#0 /usr/local/Cellar/php-code-sniffer/1.5.2/CodeSniffer.php(1961): DirectoryIterator->__construct('/usr/local/etc/...')
#1 /usr/local/Cellar/php-code-sniffer/1.5.2/CodeSniffer/CLI.php(733): PHP_CodeSniffer::getInstalledStandards()
#2 /usr/local/Cellar/php-code-sniffer/1.5.2/CodeSniffer/CLI.php(538): PHP_CodeSniffer_CLI->validateStandard(Array)
#3 /usr/local/Cellar/php-code-sniffer/1.5.2/scripts/phpcs(37): PHP_CodeSniffer_CLI->process()
#4 {main}
  thrown in /usr/local/Cellar/php-code-sniffer/1.5.2/CodeSniffer.php on line 1961

Isolating the error to the command /usr/local/bin/phpcs --report=checkstyle --standard=PSR2 /Path/to/File.php I attempted to remove and tweak the parameters, and it seems the error is thrown by the '--standard=PSR2' flag. By removing this in the Terminal it works and returns warnings about my code.

I'm not too familiar with PHPCS, so this might not be an issue related to the package, and if it's not—my apologies. :) A quick pointer in the right direction would be fabulous, though. Thanks!

benmatselby commented 10 years ago

This is a PHP error, so please look at:

'DirectoryIterator::__construct(/usr/local/etc/php-code-sniffer/Standards): failed to open dir: No such file or directory'

Does /usr/local/etc/php-code-sniffer/Standards exist? This doesn't look related to the plugin, just the configuration on your machine. When you specify a --standard you are telling phpcs which coding standard to use, if you do not specify this, it will default to a standard. Unsure how it does this as I've not looked into the phpcs code in a while, but potentially you are hitting different code.

Closing the issue, as with the information I have this does not seem to be a bug.

hvsharma63 commented 6 years ago

I'm getting the error similar to this phpcs: Uncaught UnexpectedValueException: DirectoryIterator::__construct(vendor/wimg/php-compatibility,vendor/wimg/php-compatibility): The system cannot find the path specified. (code: 3) in C:\Users\HAX63\AppData\Roaming\Composer\vendor\squizlabs\php_codesniffer\src\Util\Standards.php:93 in Visual Studio Code. Help if you've any solution

benmatselby commented 6 years ago

Hi @hvsharma63

I'm no longer maintaining this plugin as I do not use Atom any more.. I believe https://github.com/atomlinter may be of interest to you

hvsharma63 commented 6 years ago

Okay. 👍