1
0
Fork 0

Correct code style

pull/31/head
Felix Becker 2016-09-29 18:14:50 +02:00
parent 5f8e37be9e
commit b99fb94840
9 changed files with 353 additions and 360 deletions

View File

@ -72,8 +72,7 @@ class PhpDocument
$errors = [];
try {
$stmts = $this->parser->parse($this->content);
}
catch(\PhpParser\Error $e) {
} catch(\PhpParser\Error $e) {
// Lexer can throw errors. e.g for unterminated comments
// unfortunately we don't get a location back
$errors[] = $e;

View File

@ -84,5 +84,4 @@ class TextDocument
{
return $this->project->getDocument($textDocument->uri)->getFormattedText();
}
}

View File

@ -39,12 +39,12 @@ class SymbolFinder extends NodeVisitorAbstract
/**
* @var array
*/
private $nameStack = array();
private $nameStack = [];
/**
* @var array
*/
private $nodeStack = array();
private $nodeStack = [];
/**
* @var int
@ -58,26 +58,21 @@ class SymbolFinder extends NodeVisitorAbstract
public function enterNode(Node $node)
{
array_push($this->nodeStack, $node);
$this->nodeStack[] = $node;
$containerName = end($this->nameStack);
// If we enter a named node, push its name onto name stack.
// Else push the current name onto stack.
if (!empty($node->name) && (is_string($node->name) || method_exists($node->name, '__toString')) && !empty((string)$node->name)) {
if (!empty($node->name) && !empty((string)$node->name)) {
if (empty($containerName)) {
array_push($this->nameStack, (string)$node->name);
$this->nameStack[] = (string)$node->name;
} else if ($node instanceof Node\Stmt\ClassMethod) {
$this->nameStack[] = $containerName . '::' . (string)$node->name;
} else {
$this->nameStack[] = $containerName . '\\' . (string)$node->name;
}
else {
if ($node instanceof Node\Stmt\ClassMethod) {
array_push($this->nameStack, $containerName . '::' . (string)$node->name);
}
else {
array_push($this->nameStack, $containerName . '\\' . (string)$node->name);
}
}
}
else {
array_push($this->nameStack, $containerName);
} else {
$this->nameStack[] = $containerName;
}
$class = get_class($node);

View File

@ -13,7 +13,7 @@ function findFilesRecursive(string $path, string $pattern): array {
$dir = new \RecursiveDirectoryIterator($path);
$ite = new \RecursiveIteratorIterator($dir);
$files = new \RegexIterator($ite, $pattern, \RegexIterator::GET_MATCH);
$fileList = array();
$fileList = [];
foreach ($files as $file) {
$fileList = array_merge($fileList, $file);
}

View File

@ -21,8 +21,8 @@ class FileUriTest extends TestCase
$uri = \LanguageServer\pathToUri('/usr/local/bin');
$this->assertEquals('file:///usr/local/bin', $uri);
$uri = \LanguageServer\pathToUri('a/b/c/');
$this->assertEquals('file:///a/b/c', $uri);
$uri = \LanguageServer\pathToUri('a/b/c/test.txt');
$this->assertEquals('file:///a/b/c/test.txt', $uri);
$uri = \LanguageServer\pathToUri('/d/e/f');
$this->assertEquals('file:///d/e/f', $uri);