Skip to content

Commit

Permalink
Added phpcs.xml and fixed some minor formatting issues accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
theseer committed Jan 1, 2013
1 parent 8bb55ee commit 69cd1f9
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 9 deletions.
40 changes: 40 additions & 0 deletions phpcs.xml
@@ -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>
2 changes: 2 additions & 0 deletions src/Application.php
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/AutoloadBuilder.php
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/CLI.php
Expand Up @@ -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);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/ClassFinder.php
Expand Up @@ -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];
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/DependencySorter.php
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion src/Factory.php
Expand Up @@ -168,7 +168,6 @@ public function getBuilder(ClassFinder $finder) {
$builder->setTemplateFile(__DIR__.'/templates/'.$tplType.'/'.$tplFile);
}


$format = $this->config->getDateFormat();
if ($format) {
$builder->setDateTimeFormat($format);
Expand Down

0 comments on commit 69cd1f9

Please sign in to comment.