Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More strict psalm #35

Merged
merged 1 commit into from
Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Install dependencies
run: composer install

- name: Psalm
uses: docker://vimeo/psalm-github-actions
with:
composer_require_dev: true
run: vendor/bin/psalm --output-format=github
5 changes: 4 additions & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;

return (new Config())
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'declare_strict_types' => true,
'ordered_imports' => [
'imports_order' => [
'class',
Expand Down
3 changes: 3 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Mougrim <rinat@mougrim.ru>
*/
Expand Down
3 changes: 3 additions & 0 deletions config/factory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Mougrim <rinat@mougrim.ru>
*/
Expand Down
5 changes: 4 additions & 1 deletion config/logger.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* @author Mougrim <rinat@mougrim.ru>
*/
Expand All @@ -8,6 +10,7 @@
use Amp\ByteStream\ResourceOutputStream;
use Amp\Log\StreamHandler;
use Monolog\Logger;
use Psr\Log\LogLevel;
use const STDOUT;
use function class_exists;

Expand All @@ -19,6 +22,6 @@

return (new Logger('xdebug-proxy'))
->pushHandler(
(new StreamHandler(new ResourceOutputStream(STDOUT), Logger::NOTICE))
(new StreamHandler(new ResourceOutputStream(STDOUT), LogLevel::NOTICE))
->setFormatter(new LoggerFormatter())
);
4 changes: 4 additions & 0 deletions grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ grumphp:
config: .php-cs-fixer.php
psalm:
config: psalm.xml
no_cache: true
show_info: true
ignore_patterns:
- tests/
extensions: []
5 changes: 4 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="4"
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand All @@ -12,4 +12,7 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<UnnecessaryVarAnnotation errorLevel="suppress" />
</issueHandlers>
</psalm>
3 changes: 3 additions & 0 deletions softMocksConfig/config.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Mougrim <rinat@mougrim.ru>
*/
Expand Down
3 changes: 3 additions & 0 deletions softMocksConfig/factory.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Mougrim <rinat@mougrim.ru>
*/
Expand Down
6 changes: 5 additions & 1 deletion softMocksConfig/logger.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

declare(strict_types=1);

/**
* @author Mougrim <rinat@mougrim.ru>
*/
Expand All @@ -8,6 +11,7 @@
use Amp\ByteStream\ResourceOutputStream;
use Amp\Log\StreamHandler;
use Monolog\Logger;
use Psr\Log\LogLevel;
use const STDOUT;
use function class_exists;

Expand All @@ -19,6 +23,6 @@

return (new Logger('xdebug-proxy'))
->pushHandler(
(new StreamHandler(new ResourceOutputStream(STDOUT), Logger::NOTICE))
(new StreamHandler(new ResourceOutputStream(STDOUT), LogLevel::NOTICE))
->setFormatter(new LoggerFormatter())
);
16 changes: 12 additions & 4 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Mougrim\XdebugProxy\Config;

/**
Expand All @@ -22,11 +24,17 @@ class Config
],
];

protected $config;
protected $xdebugServer;
protected $ideRegistrationServer;
protected $ideServer;
/** @var array<array-key, array> */
protected array $config;
protected Server $xdebugServer;
protected Server $ideRegistrationServer;
protected IdeServer $ideServer;

/**
* @param array<array-key, array> $config
* @psalm-suppress MixedArgument
* @psalm-suppress MixedArgumentTypeCoercion
*/
public function __construct(array $config)
{
$this->config = $config;
Expand Down
15 changes: 13 additions & 2 deletions src/Config/IdeServer.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
<?php

declare(strict_types=1);

namespace Mougrim\XdebugProxy\Config;

/**
* @author Mougrim <rinat@mougrim.ru>
*/
class IdeServer
{
protected $config;
protected $defaultConfig;
/** @var array{defaultIde: string|null, predefinedIdeList: array<string, string>|null} */
protected array $config;
/** @var array{defaultIde: string, predefinedIdeList: array<string, string>} */
protected array $defaultConfig;

/**
* @param array{defaultIde: string|null, predefinedIdeList: array<string, string>|null} $config
* @param array{defaultIde: string, predefinedIdeList: array<string, string>} $defaultConfig
*/
public function __construct(array $config, array $defaultConfig)
{
$this->config = $config;
Expand All @@ -21,6 +29,9 @@ public function getDefaultIde(): string
return $this->config['defaultIde'] ?? $this->defaultConfig['defaultIde'];
}

/**
* @return array<string, string>
*/
public function getPredefinedIdeList(): array
{
return $this->config['predefinedIdeList'] ?? $this->defaultConfig['predefinedIdeList'];
Expand Down
12 changes: 10 additions & 2 deletions src/Config/Server.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
<?php

declare(strict_types=1);

namespace Mougrim\XdebugProxy\Config;

/**
* @author Mougrim <rinat@mougrim.ru>
*/
class Server
{
protected $config;
protected $defaultConfig;
/** @var array{listen: string|null} */
protected array $config;
/** @var array{listen: string} */
protected array $defaultConfig;

/**
* @param array{listen: string|null} $config
* @param array{listen: string} $defaultConfig
*/
public function __construct(array $config, array $defaultConfig)
{
$this->config = $config;
Expand Down
12 changes: 10 additions & 2 deletions src/Config/SoftMocks.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
<?php

declare(strict_types=1);

namespace Mougrim\XdebugProxy\Config;

/**
* @author Mougrim <rinat@mougrim.ru>
*/
class SoftMocks
{
protected $config;
protected $defaultConfig;
/** @var array{initScript: string|null} */
protected array $config;
/** @var array{initScript: string} */
protected array $defaultConfig;

/**
* @param array{initScript: string|null} $config
* @param array{initScript: string} $defaultConfig
*/
public function __construct(array $config, array $defaultConfig)
{
$this->config = $config;
Expand Down
9 changes: 8 additions & 1 deletion src/Config/SoftMocksConfig.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Mougrim\XdebugProxy\Config;

/**
Expand All @@ -11,8 +13,13 @@ class SoftMocksConfig extends Config
'initScript' => '',
];

protected $softMocks;
protected SoftMocks $softMocks;

/**
* @param array<array-key, array> $config
* @psalm-suppress MixedArgument
* @psalm-suppress MixedArgumentTypeCoercion
*/
public function __construct(array $config)
{
parent::__construct($config);
Expand Down
5 changes: 5 additions & 0 deletions src/Factory/DefaultFactory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Mougrim\XdebugProxy\Factory;

use Mougrim\XdebugProxy\Config\Config;
Expand All @@ -19,6 +21,9 @@
*/
class DefaultFactory implements Factory
{
/**
* @param array<array-key, array> $config
*/
public function createConfig(array $config): Config
{
return new Config($config);
Expand Down
5 changes: 5 additions & 0 deletions src/Factory/Factory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Mougrim\XdebugProxy\Factory;

use Mougrim\XdebugProxy\Config\Config;
Expand All @@ -18,6 +20,9 @@
*/
interface Factory
{
/**
* @param array<array-key, array> $config
*/
public function createConfig(array $config): Config;

public function createXmlConverter(LoggerInterface $logger): XmlConverter;
Expand Down
4 changes: 4 additions & 0 deletions src/Factory/SoftMocksFactory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Mougrim\XdebugProxy\Factory;

use Mougrim\XdebugProxy\Config\Config;
Expand All @@ -20,6 +22,8 @@ class SoftMocksFactory extends DefaultFactory
* @noinspection PhpMissingParentCallCommonInspection
* {@inheritdoc}
*
* @param array<array-key, array> $config
*
* @return SoftMocksConfig
*/
public function createConfig(array $config): Config
Expand Down
5 changes: 5 additions & 0 deletions src/Handler/CommandToXdebugParser.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Mougrim\XdebugProxy\Handler;

/**
Expand All @@ -12,5 +14,8 @@ interface CommandToXdebugParser
*/
public function parseCommand(string $request): array;

/**
* @param array<string, string> $arguments
*/
public function buildCommand(string $command, array $arguments): string;
}
Loading