diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-10 14:19:56 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-10 14:19:56 +0200 |
commit | caff1023ea72bb2ea94130e18a2a6e2ccf819e5f (patch) | |
tree | 186d494c2aea5dea7255d3584ef5d595fc6e6194 /build/OCPSinceChecker.php | |
parent | edf8ce32cffdb920e8171207b342abbd7f1fbe73 (diff) | |
download | nextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.tar.gz nextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.zip |
Format control structures, classes, methods and function
To continue this formatting madness, here's a tiny patch that adds
unified formatting for control structures like if and loops as well as
classes, their methods and anonymous functions. This basically forces
the constructs to start on the same line. This is not exactly what PSR2
wants, but I think we can have a few exceptions with "our" style. The
starting of braces on the same line is pracrically standard for our
code.
This also removes and empty lines from method/function bodies at the
beginning and end.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'build/OCPSinceChecker.php')
-rw-r--r-- | build/OCPSinceChecker.php | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/build/OCPSinceChecker.php b/build/OCPSinceChecker.php index 13f58fe2550..ff314170149 100644 --- a/build/OCPSinceChecker.php +++ b/build/OCPSinceChecker.php @@ -40,51 +40,51 @@ class SinceTagCheckVisitor extends \PhpParser\NodeVisitorAbstract { protected $errors = []; public function enterNode(\PhpParser\Node $node) { - if($this->deprecatedClass) { + if ($this->deprecatedClass) { return; } - if($node instanceof \PhpParser\Node\Stmt\Namespace_) { + if ($node instanceof \PhpParser\Node\Stmt\Namespace_) { $this->namespace = $node->name; } - if($node instanceof \PhpParser\Node\Stmt\Interface_ or + if ($node instanceof \PhpParser\Node\Stmt\Interface_ or $node instanceof \PhpParser\Node\Stmt\Class_) { $this->className = $node->name; /** @var \PhpParser\Comment\Doc[] $comments */ $comments = $node->getAttribute('comments'); - if(count($comments) === 0) { + if (count($comments) === 0) { $this->errors[] = 'PHPDoc is needed for ' . $this->namespace . '\\' . $this->className . '::' . $node->name; return; } $comment = $comments[count($comments) - 1]; $text = $comment->getText(); - if(strpos($text, '@deprecated') !== false) { + if (strpos($text, '@deprecated') !== false) { $this->deprecatedClass = true; } - if($this->deprecatedClass === false && strpos($text, '@since') === false && strpos($text, '@deprecated') === false) { + if ($this->deprecatedClass === false && strpos($text, '@since') === false && strpos($text, '@deprecated') === false) { $type = $node instanceof \PhpParser\Node\Stmt\Interface_ ? 'interface' : 'class'; $this->errors[] = '@since or @deprecated tag is needed in PHPDoc for ' . $type . ' ' . $this->namespace . '\\' . $this->className; return; } } - if($node instanceof \PhpParser\Node\Stmt\ClassMethod) { + if ($node instanceof \PhpParser\Node\Stmt\ClassMethod) { /** @var \PhpParser\Node\Stmt\ClassMethod $node */ /** @var \PhpParser\Comment\Doc[] $comments */ $comments = $node->getAttribute('comments'); - if(count($comments) === 0) { + if (count($comments) === 0) { $this->errors[] = 'PHPDoc is needed for ' . $this->namespace . '\\' . $this->className . '::' . $node->name; return; } $comment = $comments[count($comments) - 1]; $text = $comment->getText(); - if(strpos($text, '@since') === false && strpos($text, '@deprecated') === false) { + if (strpos($text, '@since') === false && strpos($text, '@deprecated') === false) { $this->errors[] = '@since or @deprecated tag is needed in PHPDoc for ' . $this->namespace . '\\' . $this->className . '::' . $node->name; return; } @@ -108,7 +108,7 @@ $Regex = new RegexIterator($Iterator, '/^.+\.php$/i', RecursiveRegexIterator::GE $errors = []; -foreach($Regex as $file) { +foreach ($Regex as $file) { $stmts = $parser->parse(file_get_contents($file[0])); $visitor = new SinceTagCheckVisitor(); @@ -119,7 +119,7 @@ foreach($Regex as $file) { $errors = array_merge($errors, $visitor->getErrors()); } -if(count($errors)) { +if (count($errors)) { echo join(PHP_EOL, $errors) . PHP_EOL . PHP_EOL; exit(1); } |