PHP CodeSniffer (PHPcs): Difference between revisions

From HaFrWiki42
Jump to navigation Jump to search
Line 14: Line 14:
* Adjust
* Adjust
<pre>
<pre>
f (is_file(dirname(__FILE__).'/../CodeSniffer/CLI.php') === true) {
if (is_file(dirname(__FILE__).'/../CodeSniffer/CLI.php') === true) {
   include_once dirname(__FILE__).'/../CodeSniffer/CLI.php';
   include_once dirname(__FILE__).'/../CodeSniffer/CLI.php';
else {
else {
Line 30: Line 30:
}
}
</pre>
</pre>


== See also ==
== See also ==

Revision as of 12:18, 19 December 2014

PHP CodeSniffer (PHPcs) is a useful tool for PHP developers.

Introduction

PHPcs is a PHP5 script that tokenises and "sniffs" PHP, JavaScript and CSS files to detect violations of a defined coding standard. It is an essential development tool that ensures your code remains clean and consistent. It can also help prevent some common semantic errors made by developers.

Bug Workarounds

Some users experience warning about not finding the CLI.php file after installing and trying the tools.

  • Search for the location of the phpcs file.
  • open the file with a normal developer text editor.
  • Adjust
if (is_file(dirname(__FILE__).'/../CodeSniffer/CLI.php') === true) {
   include_once dirname(__FILE__).'/../CodeSniffer/CLI.php';
else {
   include_once 'PHP/CodeSniffer/CLI.php';
}

Into something like:

if (is_file(dirname(__FILE__).'/../CodeSniffer/CLI.php') === true) {
   include_once dirname(__FILE__).'/../CodeSniffer/CLI.php';
} else if (is_file('/usr/local/pear/share/pear/PHP/CodeSniffer/CLI.php')) {
   include_once '/usr/local/pear/share/pear/PHP/CodeSniffer/CLI.php';
} else {
   include_once 'PHP/CodeSniffer/CLI.php';
}

See also

top

Reference

top