Skip to content

Commit

Permalink
No longer needs composer to run phpcs/cbf or tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Apr 9, 2015
1 parent b315e71 commit 08503d4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 4 deletions.
22 changes: 22 additions & 0 deletions autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
spl_autoload_register(
function ($class) {
$ds = DIRECTORY_SEPARATOR;
$path = null;

if (substr($class, 0, 16) === 'PHP_CodeSniffer\\') {
if (substr($class, 0, 22) === 'PHP_CodeSniffer\Tests\\') {
$path = __DIR__.$ds.'tests'.$ds.substr(str_replace('\\', $ds, $class), 22).'.php';
} else {
$path = __DIR__.$ds.'src'.$ds.substr(str_replace('\\', $ds, $class), 16).'.php';
}
}

if ($path !== null && is_file($path) === true) {
include $path;
return true;
}

return false;
}
);
2 changes: 1 addition & 1 deletion bin/phpcbf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @link http://pear.php.net/package/PHP_CodeSniffer
*/

require_once 'vendor/autoload.php';
require_once __DIR__.'/../autoload.php';

use PHP_CodeSniffer\Runner;

Expand Down
2 changes: 1 addition & 1 deletion bin/phpcs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @link http://pear.php.net/package/PHP_CodeSniffer
*/

require_once 'vendor/autoload.php';
require_once __DIR__.'/../autoload.php';

use PHP_CodeSniffer\Runner;

Expand Down
2 changes: 1 addition & 1 deletion tests/AllTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
define('PHP_CODESNIFFER_VERBOSITY', 0);
}

require_once 'vendor/autoload.php';
require_once __DIR__.'/../autoload.php';

$tokens = new Tokens();

Expand Down
2 changes: 1 addition & 1 deletion tests/Core/AllTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
define('PHP_CODESNIFFER_VERBOSITY', 0);
}

require_once 'vendor/autoload.php';
require_once __DIR__.'/../../autoload.php';

$tokens = new Tokens();

Expand Down

0 comments on commit 08503d4

Please sign in to comment.