-3

我正在尝试安装 php 代码嗅探器。我已经设法达到运行后 php /Users/ryanfernandes/pear/bin/phpcs --version显示信息的地步。但是当我尝试运行代码嗅探器时

php /Users/username/pear/bin/phpcs /Users/username/development/htdocs/test.php 
PHP Warning:  fwrite() expects parameter 1 to be resource, boolean given in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 155

Warning: fwrite() expects parameter 1 to be resource, boolean given in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 155
PHP Warning:  stream_get_meta_data() expects parameter 1 to be resource, boolean given in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 206

Warning: stream_get_meta_data() expects parameter 1 to be resource, boolean given in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 206
PHP Warning:  file_get_contents(): Filename cannot be empty in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 208

Warning: file_get_contents(): Filename cannot be empty in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 208
PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 209

Warning: fclose() expects parameter 1 to be resource, boolean given in /Users/username/pear/share/pear/PHP/CodeSniffer/Reporting.php on line 209

任何帮助将非常感激。

谢谢

4

1 回答 1

1

从错误消息看来,您使用的是 PHP_CodeSniffer 版本 1.5.4。PHP_CodeSniffer 使用 tmpfile() 函数来创建一个临时文件。可以通过运行找到创建它的目录:

php -r 'echo sys_get_temp_dir().PHP_EOL;'

确保允许您写入该目录,因为 tmpfile() 方法显然返回 FALSE,如果目录不可写,最常见的情况是。

于 2014-11-12T03:39:16.033 回答