Skip to content
This repository has been archived by the owner on Jul 23, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1 from shapintv/sf5
Browse files Browse the repository at this point in the history
Allow sf5 + clean
  • Loading branch information
Olivier Dolbeau authored Dec 7, 2019
2 parents 0beba32 + 42e1d59 commit 1dc51ae
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 36 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on: [push, pull_request]
name: Static analysis
jobs:
php-cs-fixer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: PHP-CS-Fixer
uses: docker://jakzal/phpqa:php7.3-alpine
with:
args: php-cs-fixer fix --dry-run --diff-format udiff -vvv

phpstan:
name: PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: PHPStan
uses: docker://oskarstark/phpstan-ga
with:
args: analyze --no-progress
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.PHONY: ${TARGETS}
.DEFAULT_GOAL := help

DIR := ${CURDIR}
QA_IMAGE := jakzal/phpqa:php7.3-alpine

define say_red =
echo "\033[31m$1\033[0m"
endef
Expand All @@ -25,11 +28,16 @@ install: ## Install all applications
@$(call say_green,"Installing PHP dependencies")
@composer install

test: ## Launch tests
@vendor/bin/phpunit

cs-lint: ## Verify check styles
-vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --verbose --diff
@docker run --rm -v $(DIR):/project -w /project $(QA_IMAGE) php-cs-fixer fix --diff-format udiff --dry-run -vvv

cs-fix: ## Apply Check styles
-vendor/bin/php-cs-fixer fix --using-cache=no --verbose --diff
@docker run --rm -v $(DIR):/project -w /project $(QA_IMAGE) php-cs-fixer fix --diff-format udiff -vvv

phpstan: ## Run PHPStan
@docker run --rm -v $(DIR):/project -w /project $(QA_IMAGE) phpstan analyse

test: cs-lint phpstan ## Launch tests
@rm -rf ./tests/app/var ./tests/app/cache
@$(call say_green,"==\> Launch unit tests")
@vendor/bin/phpunit
12 changes: 5 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
],
"require": {
"php": "^7.3",
"symfony/config": "^4.2",
"symfony/http-client": "^4.3"
"symfony/config": "^4.3|^5.0",
"symfony/http-client": "^4.3|^5.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0",
"friendsofphp/php-cs-fixer": "^2.13",
"phpstan/phpstan": "^0.11.1",
"symfony/phpunit-bridge": "^4.2",
"symfony/var-dumper": "^4.2"
"phpunit/phpunit": "^8.5",
"symfony/phpunit-bridge": "^4.4|^5.0",
"symfony/var-dumper": "^4.3|^5.0"
},
"autoload": {
"psr-4": {
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
parameters:
level: 5
inferPrivatePropertyTypeFromConstructor: true
paths:
- %currentWorkingDirectory%/src
- %currentWorkingDirectory%/tests
7 changes: 0 additions & 7 deletions src/Api/HttpApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@

abstract class HttpApi
{
/**
* @var HttpClient
*/
protected $httpClient;

/**
* @var Hydrator
*/
protected $hydrator;

public function __construct(HttpClientInterface $httpClient, Hydrator $hydrator)
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/Domain/BadRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

namespace Shapin\TalkJS\Exception\Domain;

use Symfony\Contracts\HttpClient\ResponseInterface;
use Shapin\TalkJS\Exception\DomainException;
use Symfony\Contracts\HttpClient\ResponseInterface;

class BadRequestException extends \Exception implements DomainException
{
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/Domain/UnknownErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

namespace Shapin\TalkJS\Exception\Domain;

use Symfony\Contracts\HttpClient\ResponseInterface;
use Shapin\TalkJS\Exception\DomainException;
use Symfony\Contracts\HttpClient\ResponseInterface;

final class UnknownErrorException extends \Exception implements DomainException
{
Expand Down
5 changes: 1 addition & 4 deletions src/Hydrator/ModelHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@
final class ModelHydrator implements Hydrator
{
/**
* @param ResponseInterface $response
* @param string $class
*
* @return mixed
*/
public function hydrate(ResponseInterface $response, string $class)
{
if (!isset($response->getHeaders()['content-type'])) {
throw new HydrationException("The ModelHydrator cannot hydrate response with Content-Type: $contentType");
throw new HydrationException('The ModelHydrator cannot hydrate response without Content-Type header.');
}

$contentType = reset($response->getHeaders()['content-type']);
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Conversation/Conversation.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Conversation implements CreatableFromArray
private $photoUrl;

/**
* @var ?string
* @var array
*/
private $welcomeMessages;

Expand Down
9 changes: 1 addition & 8 deletions src/TalkJSClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,13 @@

namespace Shapin\TalkJS;

use Shapin\TalkJS\Hydrator\ModelHydrator;
use Shapin\TalkJS\Hydrator\Hydrator;
use Shapin\TalkJS\Hydrator\ModelHydrator;
use Symfony\Contracts\HttpClient\HttpClientInterface;

final class TalkJSClient
{
/**
* @var HttpClient
*/
private $httpClient;

/**
* @var Hydrator
*/
private $hydrator;

public function __construct(HttpClientInterface $talkjsClient, Hydrator $hydrator = null)
Expand Down
4 changes: 2 additions & 2 deletions tests/FunctionalTests/ConversationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
namespace Shapin\TalkJS\Tests\FunctionalTests;

use Shapin\TalkJS\Model\Conversation\Conversation;
use Shapin\TalkJS\Model\Conversation\ConversationJoined;
use Shapin\TalkJS\Model\Conversation\ConversationLeft;
use Shapin\TalkJS\Model\Conversation\ConversationCollection;
use Shapin\TalkJS\Model\Conversation\ConversationCreatedOrUpdated;
use Shapin\TalkJS\Model\Conversation\ConversationJoined;
use Shapin\TalkJS\Model\Conversation\ConversationLeft;
use Shapin\TalkJS\Model\Conversation\ParticipationUpdated;

final class ConversationTest extends TestCase
Expand Down

0 comments on commit 1dc51ae

Please sign in to comment.