Merge pull request #551 from bantu/2.0-code-sniffer

Code Sniffer rules witnessing PSR-4 and related goals

* bantu/2.0-code-sniffer:
  Remove side-effects from test files.
  Do not require test classes to be namespaced.
  Add code sniffer rules for 2.0 goals.
This commit is contained in:
Andreas Fischer 2014-12-17 05:03:45 +01:00
commit a272b58322
4 changed files with 16 additions and 4 deletions

View File

@ -16,6 +16,9 @@
<exclude name="PEAR.Commenting.FileComment.MissingTag" />
<exclude name="PEAR.Commenting.FileComment.MissingVersion" />
<exclude name="PEAR.Commenting.FileComment.SpacingBeforeTags" />
<!-- Test classes do not have to be namespaced. -->
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
</rule>
</ruleset>

View File

@ -48,6 +48,15 @@
<!-- Constructors MUST be called __construct() instead of after the class. -->
<rule ref="Generic.NamingConventions.ConstructorName" />
<!-- Classes etc. MUST be namespaced -->
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace" />
<!-- A file MUST not contain more than one class/interface -->
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses" />
<!-- Files containing classes MUST not have any side-effects -->
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols" />
<!-- Each file MUST end with exactly one newline character -->
<rule ref="PSR2.Files.EndFileNewline" />

View File

@ -9,12 +9,12 @@ use phpseclib\Crypt\AES;
use phpseclib\Crypt\Base;
use phpseclib\Crypt\Rijndael;
require_once 'Crypt/AES.php';
abstract class Unit_Crypt_AES_TestCase extends PhpseclibTestCase
{
static public function setUpBeforeClass()
{
include_once 'Crypt/AES.php';
parent::setUpBeforeClass();
self::reRequireFile('Crypt/Rijndael.php');

View File

@ -5,12 +5,12 @@
* @license http://www.opensource.org/licenses/mit-license.html MIT License
*/
require_once 'Math/BigInteger.php';
abstract class Unit_Math_BigInteger_TestCase extends PhpseclibTestCase
{
static public function setUpBeforeClass()
{
include_once 'Math/BigInteger.php';
parent::setUpBeforeClass();
self::reRequireFile('Math/BigInteger.php');