Skip to content

Commit

Permalink
Merge pull request #47 from LibreSign/refactor/tests-improvement
Browse files Browse the repository at this point in the history
Make psalm more strict
  • Loading branch information
vitormattos authored Dec 31, 2022
2 parents eeec7e2 + 9672344 commit 8a39ad2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="5"
errorLevel="2"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand Down
20 changes: 7 additions & 13 deletions src/RunServerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,12 @@

class RunServerListener implements EventSubscriberInterface
{
/** @var string */
private $pid = '0';
/** @var string */
private static $host;
/** @var int */
private static $port = 0;
/** @var ?int */
private $verbose = null;
/** @var string */
private $rootDir;
/** @var self */
private static $instance;
private string $pid = '0';
private static string $host;
private static int $port = 0;
private ?int $verbose = null;
private string $rootDir;
private static self $instance;

public function __construct(?int $verbose, string $rootDir, string $host)
{
Expand Down Expand Up @@ -99,7 +93,7 @@ public function start(): void

$this->pid = (string)(int) exec($fullCmd);

if (!ctype_digit($this->pid)) {
if (!$this->pid) {
throw new ServerException('Error starting server, received ' . $this->pid . ', expected int PID');
}

Expand Down
5 changes: 4 additions & 1 deletion src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use Exception;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;

Expand Down Expand Up @@ -82,7 +83,9 @@ public function load(ContainerBuilder $container, array $config): void
$rootDir = $this->getRootDir($config);
if (is_numeric($verbose)) {
$output = $container->get('cli.output');
$output->writeln('<info>Root dir: ' . $rootDir . '</info>');
if ($output instanceof OutputInterface) {
$output->writeln('<info>Root dir: ' . $rootDir . '</info>');
}
}
$host = $this->getHost($config);
$definition = (new Definition('PhpBuiltin\RunServerListener'))
Expand Down

0 comments on commit 8a39ad2

Please sign in to comment.