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