Skip to content

Commit

Permalink
CS fix
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Jul 22, 2023
1 parent ded9dc9 commit 815c0ac
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
40 changes: 20 additions & 20 deletions src/Psalm/Internal/LanguageServer/PathMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,45 @@
/** @internal */
final class PathMapper
{
private string $serverRoot;
private ?string $clientRoot;
private string $server_root;
private ?string $client_root;

public function __construct(string $serverRoot, ?string $clientRoot = null)
public function __construct(string $server_root, ?string $client_root = null)
{
$this->serverRoot = $this->sanitizeFolderPath($serverRoot);
$this->clientRoot = $this->sanitizeFolderPath($clientRoot);
$this->server_root = $this->sanitizeFolderPath($server_root);
$this->client_root = $this->sanitizeFolderPath($client_root);
}

public function configureClientRoot(string $clientRoot): void
public function configureClientRoot(string $client_root): void
{
// ignore if preconfigured
if ($this->clientRoot === null) {
$this->clientRoot = $this->sanitizeFolderPath($clientRoot);
if ($this->client_root === null) {
$this->client_root = $this->sanitizeFolderPath($client_root);
}
}

public function mapClientToServer(string $clientPath): string
public function mapClientToServer(string $client_path): string
{
if ($this->clientRoot === null) {
return $clientPath;
if ($this->client_root === null) {
return $client_path;
}

if (substr($clientPath, 0, strlen($this->clientRoot)) === $this->clientRoot) {
return $this->serverRoot . substr($clientPath, strlen($this->clientRoot));
if (substr($client_path, 0, strlen($this->client_root)) === $this->client_root) {
return $this->server_root . substr($client_path, strlen($this->client_root));
}

return $clientPath;
return $client_path;
}

public function mapServerToClient(string $serverPath): string
public function mapServerToClient(string $server_path): string
{
if ($this->clientRoot === null) {
return $serverPath;
if ($this->client_root === null) {
return $server_path;
}
if (substr($serverPath, 0, strlen($this->serverRoot)) === $this->serverRoot) {
return $this->clientRoot . substr($serverPath, strlen($this->serverRoot));
if (substr($server_path, 0, strlen($this->server_root)) === $this->server_root) {
return $this->client_root . substr($server_path, strlen($this->server_root));
}
return $serverPath;
return $server_path;
}

/** @return ($path is null ? null : string) */
Expand Down
36 changes: 18 additions & 18 deletions tests/LanguageServer/PathMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,33 @@ public function testIgnoresClientRootIfItWasPreconfigures(): void
* @dataProvider mappingProvider
*/
public function testMapsClientToServer(
string $serverRoot,
?string $clientRootPreconfigured,
string $clientRootProvidedLater,
string $clientPath,
string $serverPath
string $server_root,
?string $client_root_reconfigured,
string $client_root_provided_later,
string $client_path,
string $server_ath
): void {
$mapper = new PathMapper($serverRoot, $clientRootPreconfigured);
$mapper->configureClientRoot($clientRootProvidedLater);
$mapper = new PathMapper($server_root, $client_root_reconfigured);
$mapper->configureClientRoot($client_root_provided_later);
$this->assertSame(
$serverPath,
$mapper->mapClientToServer($clientPath)
$server_ath,
$mapper->mapClientToServer($client_path)
);
}

/** @dataProvider mappingProvider */
public function testMapsServerToClient(
string $serverRoot,
?string $clientRootPreconfigured,
string $clientRootProvidedLater,
string $clientPath,
string $serverPath
string $server_root,
?string $client_root_preconfigured,
string $client_root_provided_later,
string $client_path,
string $server_path
): void {
$mapper = new PathMapper($serverRoot, $clientRootPreconfigured);
$mapper->configureClientRoot($clientRootProvidedLater);
$mapper = new PathMapper($server_root, $client_root_preconfigured);
$mapper->configureClientRoot($client_root_provided_later);
$this->assertSame(
$clientPath,
$mapper->mapServerToClient($serverPath)
$client_path,
$mapper->mapServerToClient($server_path)
);
}

Expand Down

0 comments on commit 815c0ac

Please sign in to comment.