cute / php.tools

Tooling for PHP - testing, code coverage and formatting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

php.tools

Build statuses

  • Master: Build Status
  • Coverage Coverage Status

Requirements

  • Git
  • PHP >= 5.5.0 to run the formatter. Note that the formatter can parse even a PHP file version 4 in case needed.
  • Optionally, if Exuberant Ctags, vendored PHPUnit and phpDocumentos are available, the functions for unit testing, code coverage and document generation are enabled.

Plugins

Usage

    php ./php.tools [watch [command]]
	ctags - generate ctags
	test - execute PHPUnit
	cover - execute PHPUnit with cover output
	doc - execute phpDocumentor
	watch ctags - execute PHPUnit, but keeps watching for file changes to trigger ctags generator
	watch test - execute PHPUnit, but keeps watching for file changes to trigger the test automatically
	watch cover - execute PHPUnit with cover output, but keeps watching for file changes to trigger the test automatically
	watch doc - execute phpDocumentor, but keeps watching for file changes to trigger the generation automatically
	fmt [filename] - format filename according to project formatting rules
	fmt all - format all files according to project formatting rules
	fmt clean - remove all backup files - *~
	watch fmt [all|filename] - watch for changes and format according to project formatting rules

What does the Code Formatter do?

K&R configuration

Before After
<?php
for($i = 0; $i < 10; $i++)
{
if($i%2==0)
echo "Flipflop";
}
<?php
for ($i = 0; $i < 10; $i++) {
	if ($i%2 == 0) {
		echo "Flipflop";
	}
}
<?php
$a = 10;
$otherVar = 20;
$third = 30;
<?php
$a        = 10;
$otherVar = 20;
$third    = 30;
This can be disabled with the option "disable_auto_align"
<?php
namespace NS\Something;
use \OtherNS\C;
use \OtherNS\B;
use \OtherNS\A;
use \OtherNS\D;

$a = new A(); $b = new C(); $d = new D();

<?php
namespace NS\Something;

use \OtherNS\A; use \OtherNS\C; use \OtherNS\D;

$a = new A(); $b = new C(); $d = new D();

note how it sorts the use clauses, and removes unused ones

PSR configuration

Before After
<?php
for($i = 0; $i < 10; $i++)
{
if($i%2==0)
echo "Flipflop";
}
<?php
for ($i = 0; $i < 10; $i++) {
    if ($i%2 == 0) {
        echo "Flipflop";
    }
}
Note the identation of 4 spaces.
<?php
class A {
function a(){
return 10;
}
}
<?php
class A
{
    public function a()
    {
        return 10;
    }
}
Note the braces position, and the visibility adjustment in the method a().
<?php
namespace NS\Something;
use \OtherNS\C;
use \OtherNS\B;
use \OtherNS\A;
use \OtherNS\D;

$a = new A(); $b = new C(); $d = new D();

<?php
namespace NS\Something;

use \OtherNS\A; use \OtherNS\C; use \OtherNS\D;

$a = new A(); $b = new C(); $d = new D();

note how it sorts the use clauses, and removes unused ones

About

Tooling for PHP - testing, code coverage and formatting

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:PHP 99.0%Language:Shell 0.5%Language:Go 0.5%