Skip to content

Commit

Permalink
feat: add phpstan static analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrl-f5 committed Feb 2, 2021
1 parent 3e9eed8 commit e5d6ce3
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 19 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
php: [ '7.3', '7.4' ]

steps:
- uses: actions/checkout@v2
name: Checkout repository
Expand All @@ -28,6 +28,10 @@ jobs:
- name: Static Code Analysis
run: composer lint

- uses: docker://oskarstark/phpstan-ga
with:
args: analyse src/

test:
runs-on: ${{ matrix.operating-system }}
needs:
Expand All @@ -50,10 +54,10 @@ jobs:
with:
php-version: ${{ matrix.php }}

- name: Copy the inis
- name: Copy the inis
if: runner.os == 'Windows'
run: Copy-Item -Path .\tests\PhpPact\php.ini -Destination C:\tools\php\ -Force

- name: Composer install
uses: ramsey/composer-install@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -32,11 +32,11 @@
"amphp/serialization": "^1.0",
"amphp/socket": "^1.1.3",
"amphp/sync": "^1.4.0",
"guzzlehttp/guzzle": "^7.2.0"
"guzzlehttp/guzzle": "^7.2.0",
"phpunit/phpunit": "^7 | ^8 | ^9"
},
"require-dev": {
"roave/security-advisories": "dev-master",
"phpunit/phpunit": "^9.4.3",
"mockery/mockery": "^1.4.2",
"slim/slim": "^4.6",
"slim/psr7": "^1.2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/PhpPact/Consumer/Hook/ContractDownloader.php
Expand Up @@ -6,7 +6,7 @@
use PhpPact\Http\ClientInterface;
use PhpPact\Http\GuzzleClient;
use PhpPact\Standalone\Exception\MissingEnvVariableException;
use PhpPact\Standalone\MockService\MockServerConfigInterface;
use PhpPact\Standalone\MockService\MockServerConfig;
use PhpPact\Standalone\MockService\MockServerEnvConfig;
use PhpPact\Standalone\MockService\Service\MockServerHttpService;
use PHPUnit\Framework\AssertionFailedError;
Expand All @@ -15,7 +15,7 @@

class ContractDownloader implements AfterLastTestHook
{
/** @var MockServerConfigInterface */
/** @var MockServerConfig */
private $mockServerConfig;

/** @var null|ClientInterface */
Expand Down
3 changes: 1 addition & 2 deletions src/PhpPact/Consumer/Listener/PactTestListener.php
Expand Up @@ -7,7 +7,6 @@
use PhpPact\Http\GuzzleClient;
use PhpPact\Standalone\Exception\MissingEnvVariableException;
use PhpPact\Standalone\MockService\MockServer;
use PhpPact\Standalone\MockService\MockServerConfigInterface;
use PhpPact\Standalone\MockService\MockServerEnvConfig;
use PhpPact\Standalone\MockService\Service\MockServerHttpService;
use PHPUnit\Framework\AssertionFailedError;
Expand All @@ -34,7 +33,7 @@ class PactTestListener implements TestListener
*/
private $testSuiteNames;

/** @var MockServerConfigInterface */
/** @var MockServerEnvConfig */
private $mockServerConfig;

/** @var bool */
Expand Down
6 changes: 3 additions & 3 deletions src/PhpPact/Standalone/MockService/MockServer.php
Expand Up @@ -17,7 +17,7 @@
*/
class MockServer
{
/** @var MockServerConfigInterface */
/** @var MockServerConfig */
private $config;

/** @var InstallManager */
Expand All @@ -32,10 +32,10 @@ class MockServer
/**
* MockServer constructor.
*
* @param MockServerConfigInterface $config
* @param MockServerConfig $config
* @param null|MockServerHttpService $httpService
*/
public function __construct(MockServerConfigInterface $config, MockServerHttpService $httpService = null)
public function __construct(MockServerConfig $config, MockServerHttpService $httpService = null)
{
$this->config = $config;
$this->installManager = new InstallManager();
Expand Down
12 changes: 12 additions & 0 deletions src/PhpPact/Standalone/MockService/MockServerConfigInterface.php
Expand Up @@ -86,4 +86,16 @@ public function setHealthCheckTimeout($timeout): self;
* @return int
*/
public function getHealthCheckTimeout(): int;

/**
* @param int $seconds
*
* @return MockServerConfigInterface
*/
public function setHealthCheckRetrySec($seconds): self;

/**
* @return int
*/
public function getHealthCheckRetrySec(): int;
}
13 changes: 6 additions & 7 deletions src/PhpPact/Standalone/MockService/MockServerEnvConfig.php
Expand Up @@ -19,13 +19,12 @@ class MockServerEnvConfig extends MockServerConfig
*/
public function __construct()
{
$this
->setHost($this->parseEnv('PACT_MOCK_SERVER_HOST'))
->setPort((int) $this->parseEnv('PACT_MOCK_SERVER_PORT'))
->setConsumer($this->parseEnv('PACT_CONSUMER_NAME'))
->setProvider($this->parseEnv('PACT_PROVIDER_NAME'))
->setPactDir($this->parseEnv('PACT_OUTPUT_DIR', false))
->setCors($this->parseEnv('PACT_CORS', false));
$this->setHost($this->parseEnv('PACT_MOCK_SERVER_HOST'));
$this->setPort((int) $this->parseEnv('PACT_MOCK_SERVER_PORT'));
$this->setConsumer($this->parseEnv('PACT_CONSUMER_NAME'));
$this->setProvider($this->parseEnv('PACT_PROVIDER_NAME'));
$this->setPactDir($this->parseEnv('PACT_OUTPUT_DIR', false));
$this->setCors($this->parseEnv('PACT_CORS', false));

if ($logDir = $this->parseEnv('PACT_LOG', false)) {
$this->setLog($logDir);
Expand Down

0 comments on commit e5d6ce3

Please sign in to comment.