Permalink
Browse files

Added phpcs.xml and fixed some minor formatting issues accordingly

  • Loading branch information...
theseer committed Jan 1, 2013
1 parent 8bb55ee commit 69cd1f903b99dd741e0fdea2a90d8fcff7ff9f23
Showing with 52 additions and 9 deletions.
  1. +40 −0 phpcs.xml
  2. +2 −0 src/Application.php
  3. +3 −1 src/AutoloadBuilder.php
  4. +2 −2 src/CLI.php
  5. +3 −3 src/ClassFinder.php
  6. +2 −2 src/DependencySorter.php
  7. +0 −1 src/Factory.php
View
@@ -0,0 +1,40 @@
+<?xml version="1.0"?>
+<ruleset name="Arne">
+ <description>Arne Blankerts' coding standard</description>
+
+ <rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>
+ <rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/>
+ <rule ref="Generic.CodeAnalysis.JumbledIncrementer"/>
+ <rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
+ <rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
+ <rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
+
+ <rule ref="Generic.Commenting.Todo"/>
+
+ <rule ref="Generic.ControlStructures.InlineControlStructure"/>
+
+ <rule ref="Generic.Files.LineEndings">
+ <properties>
+ <property name="eolChar" value="\n"/>
+ </properties>
+ </rule>
+
+ <rule ref="Generic.Formatting.DisallowMultipleStatements"/>
+ <rule ref="Generic.Formatting.NoSpaceAfterCast"/>
+
+ <rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie" />
+ <rule ref="Generic.Functions.FunctionCallArgumentSpacing" />
+ <rule ref="PEAR.Functions.ValidDefaultValue"/>
+
+ <rule ref="Generic.NamingConventions.ConstructorName"/>
+ <rule ref="PEAR.NamingConventions.ValidClassName"/>
+
+ <rule ref="Generic.PHP.DisallowShortOpenTag"/>
+ <rule ref="Generic.PHP.NoSilencedErrors"/>
+
+ <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
+
+ <!-- Namespace handling broken, so disabled -->
+ <!-- <rule ref="Generic.WhiteSpace.ScopeIndent"/> -->
+ <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
+</ruleset>
View
@@ -92,7 +92,9 @@ private function runSaver($code) {
$this->logger->log("\n\n");
return CLI::RC_OK;
}
+ // @codingStandardsIgnoreStart
$written = @file_put_contents($output, $code);
+ // @codingStandardsIgnoreEnd
if ($written != strlen($code)) {
$this->logger->log("Writing to file '$output' failed.", STDERR);
return CLI::RC_EXEC_ERROR;
View
@@ -252,7 +252,9 @@ private function resolvePath($fname) {
$max = count($basedir);
while ($filedir[$pos] == $basedir[$pos]) {
$pos++;
- if ($pos == $max) break;
+ if ($pos == $max) {
+ break;
+ }
}
if ($pos == 0) {
return str_replace('\\', '/', $fname);
View
@@ -176,10 +176,10 @@ private function configure(\ezcConsoleInput $input) {
}
if ($variables = $input->getOption('var')->value) {
foreach($variables as $var) {
- if (strpos($var,'=')===FALSE) {
+ if (strpos($var, '=')===FALSE) {
throw new \RuntimeException("Variable defintion '$var' is invalid and cannot be processed.");
}
- list($name, $value) = explode('=',$var,2);
+ list($name, $value) = explode('=', $var, 2);
$config->setVariable($name, $value);
}
}
View
@@ -184,7 +184,7 @@ protected function processClass($pos) {
$implementsList = array();
$implements = '';
$mode = 'classname';
- foreach(array_slice($stack,1,-1) as $tok) {
+ foreach(array_slice($stack, 1, -1) as $tok) {
switch ($tok[0]) {
case T_STRING: {
$$mode .= $tok[1];
@@ -243,7 +243,7 @@ protected function processInterface($pos) {
$extends = '';
$extendsList = array();
$mode = 'name';
- foreach(array_slice($stack,1,-1) as $tok) {
+ foreach(array_slice($stack, 1, -1) as $tok) {
switch ($tok[0]) {
case T_NS_SEPARATOR:
case T_STRING: {
@@ -287,7 +287,7 @@ protected function resolveDepdencyName($name) {
if ($name[0] == '\\') {
$name = substr($name, 1);
} else {
- $parts = explode('\\',$name,2);
+ $parts = explode('\\', $name, 2);
$key = array_search($parts[0], $this->aliases);
if (!$key) {
$name = ($this->inNamespace != '' ? $this->inNamespace . '\\' : ''). $name;
View
@@ -76,8 +76,8 @@ public function process() {
protected function resolve($class) {
$this->level++;
- if ($this->level==50) {
- throw new ClassDependencySorterException("Can't resolve more than 50 levels of dependencies",ClassDependencySorterException::TooManyDependencyLevels);
+ if ($this->level == 50) {
+ throw new ClassDependencySorterException("Can't resolve more than 50 levels of dependencies", ClassDependencySorterException::TooManyDependencyLevels);
}
if (isset($this->dependencies[$class])) {
foreach($this->dependencies[$class] as $depclass) {
View
@@ -168,7 +168,6 @@ public function getBuilder(ClassFinder $finder) {
$builder->setTemplateFile(__DIR__.'/templates/'.$tplType.'/'.$tplFile);
}
-
$format = $this->config->getDateFormat();
if ($format) {
$builder->setDateTimeFormat($format);

0 comments on commit 69cd1f9

Please sign in to comment.