Automatic fixes
parent
c8244f138a
commit
5285aea1f4
|
@ -4,8 +4,8 @@ declare(strict_types = 1);
|
|||
namespace LanguageServer;
|
||||
|
||||
use LanguageServer\Protocol\ {
|
||||
TextEdit,
|
||||
Range,
|
||||
TextEdit,
|
||||
Range,
|
||||
Position
|
||||
};
|
||||
use PHP_CodeSniffer;
|
||||
|
@ -42,9 +42,9 @@ abstract class Formatter
|
|||
|
||||
/**
|
||||
* Calculate position of last character.
|
||||
*
|
||||
*
|
||||
* @param string $content document as string
|
||||
*
|
||||
*
|
||||
* @return \LanguageServer\Protocol\Position
|
||||
*/
|
||||
private static function calculateEndPosition(string $content): Position
|
||||
|
@ -54,10 +54,10 @@ abstract class Formatter
|
|||
}
|
||||
|
||||
/**
|
||||
* Search for PHP_CodeSniffer configuration file at given directory or its parents.
|
||||
* If no configuration found then PSR2 standard is loaded by default.
|
||||
* Search for PHP_CodeSniffer configuration file at given directory or its parents.
|
||||
* If no configuration found then PSR2 standard is loaded by default.
|
||||
*
|
||||
* @param string $path path to file or directory
|
||||
* @param string $path path to file or directory
|
||||
* @return string[]
|
||||
*/
|
||||
private static function findConfiguration(string $path)
|
||||
|
@ -85,5 +85,4 @@ abstract class Formatter
|
|||
$standard = PHP_CodeSniffer::getConfigData('default_standard') ?? 'PSR2';
|
||||
return explode(',', $standard);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ class LanguageServer extends AdvancedJsonRpc\Dispatcher
|
|||
$startTime = microtime(true);
|
||||
$fileNum = 0;
|
||||
|
||||
$processFile = function() use (&$fileList, &$fileNum, &$processFile, $numTotalFiles, $startTime) {
|
||||
$processFile = function () use (&$fileList, &$fileNum, &$processFile, $numTotalFiles, $startTime) {
|
||||
if ($fileNum < $numTotalFiles) {
|
||||
$file = $fileList[$fileNum];
|
||||
$uri = pathToUri($file);
|
||||
|
|
|
@ -178,7 +178,8 @@ class Project
|
|||
* @param string $fqn The fully qualified name of the symbol
|
||||
* @return void
|
||||
*/
|
||||
public function removeSymbol(string $fqn) {
|
||||
public function removeSymbol(string $fqn)
|
||||
{
|
||||
unset($this->symbols[$fqn]);
|
||||
unset($this->references[$fqn]);
|
||||
}
|
||||
|
@ -207,7 +208,8 @@ class Project
|
|||
* @param string $uri The URI
|
||||
* @return void
|
||||
*/
|
||||
public function removeReferenceUri(string $fqn, string $uri) {
|
||||
public function removeReferenceUri(string $fqn, string $uri)
|
||||
{
|
||||
if (!isset($this->references[$fqn])) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@ namespace LanguageServer\Protocol;
|
|||
/**
|
||||
* The kind of a completion entry.
|
||||
*/
|
||||
abstract class CompletionItemKind {
|
||||
abstract class CompletionItemKind
|
||||
{
|
||||
const TEXT = 1;
|
||||
const METHOD = 2;
|
||||
const FUNCTION = 3;
|
||||
|
|
|
@ -4,10 +4,10 @@ namespace LanguageServer\Protocol;
|
|||
|
||||
class ReferenceContext
|
||||
{
|
||||
/**
|
||||
* Include the declaration of the current symbol.
|
||||
/**
|
||||
* Include the declaration of the current symbol.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $includeDeclaration;
|
||||
*/
|
||||
public $includeDeclaration;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class ProtocolStreamReader implements ProtocolReader
|
|||
public function __construct($input)
|
||||
{
|
||||
$this->input = $input;
|
||||
Loop\addReadStream($this->input, function() {
|
||||
Loop\addReadStream($this->input, function () {
|
||||
if (feof($this->input)) {
|
||||
throw new RuntimeException('Stream is closed');
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@ use InvalidArgumentException;
|
|||
* @param string $pattern
|
||||
* @return array
|
||||
*/
|
||||
function findFilesRecursive(string $path, string $pattern): array {
|
||||
function findFilesRecursive(string $path, string $pattern): array
|
||||
{
|
||||
$dir = new \RecursiveDirectoryIterator($path);
|
||||
$ite = new \RecursiveIteratorIterator($dir);
|
||||
$files = new \RegexIterator($ite, $pattern, \RegexIterator::GET_MATCH);
|
||||
|
@ -29,7 +30,8 @@ function findFilesRecursive(string $path, string $pattern): array {
|
|||
* @param string $filepath
|
||||
* @return string
|
||||
*/
|
||||
function pathToUri(string $filepath): string {
|
||||
function pathToUri(string $filepath): string
|
||||
{
|
||||
$filepath = trim(str_replace('\\', '/', $filepath), '/');
|
||||
$parts = explode('/', $filepath);
|
||||
// Don't %-encode the colon after a Windows drive letter
|
||||
|
|
|
@ -36,4 +36,3 @@ class MockProtocolStream implements ProtocolReader, ProtocolWriter
|
|||
$this->listener = $listener;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,13 +9,15 @@ use function LanguageServer\pathToUri;
|
|||
|
||||
class GlobalTest extends ServerTestCase
|
||||
{
|
||||
public function testDefinitionFileBeginning() {
|
||||
public function testDefinitionFileBeginning()
|
||||
{
|
||||
// |<?php
|
||||
$result = $this->textDocument->definition(new TextDocumentIdentifier(pathToUri(realpath(__DIR__ . '/../../../../fixtures/references.php'))), new Position(0, 0));
|
||||
$this->assertEquals([], $result);
|
||||
}
|
||||
|
||||
public function testDefinitionEmptyResult() {
|
||||
public function testDefinitionEmptyResult()
|
||||
{
|
||||
// namespace keyword
|
||||
$result = $this->textDocument->definition(new TextDocumentIdentifier(pathToUri(realpath(__DIR__ . '/../../../../fixtures/references.php'))), new Position(2, 4));
|
||||
$this->assertEquals([], $result);
|
||||
|
|
|
@ -36,7 +36,8 @@ class ParseErrorsTest extends TestCase
|
|||
$this->textDocument = new Server\TextDocument($project, $client);
|
||||
}
|
||||
|
||||
private function openFile($file) {
|
||||
private function openFile($file)
|
||||
{
|
||||
$textDocumentItem = new TextDocumentItem();
|
||||
$textDocumentItem->uri = 'whatever';
|
||||
$textDocumentItem->languageId = 'php';
|
||||
|
|
Loading…
Reference in New Issue