Skip to content

Commit

Permalink
- Update dependencies
Browse files Browse the repository at this point in the history
- Add RedisFactory for testing
- Add RedisInMemory for testing
- Add HttpRequestInterface for adapters
- Add monolog CustomTagProcessor
- Fix coding standards
  • Loading branch information
temafey committed Feb 1, 2021
1 parent 32e50e2 commit 96dca89
Show file tree
Hide file tree
Showing 19 changed files with 390 additions and 66 deletions.
23 changes: 16 additions & 7 deletions .docker/php7.3-dev/Dockerfile → .docker/php-dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
FROM php:7.3-cli
FROM php:8.0-cli-alpine

RUN apt-get update && apt-get install -y git unzip
RUN apk update
RUN apk add --no-cache bash
RUN apk add --no-cache build-base
RUN apk add --no-cache autoconf
RUN apk add --no-cache automake

ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_MEMORY_LIMIT -1

RUN mkdir /.composer_cache
ENV COMPOSER_CACHE_DIR /.composer_cache

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# php extensions
# intl
RUN apk add --no-cache icu-dev
RUN docker-php-ext-install intl
RUN docker-php-ext-enable intl

# xdebug
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug

RUN mkdir /.composer_cache
ENV COMPOSER_CACHE_DIR /.composer_cache

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ language: php

matrix:
include:
- php: 7.3
- php: 7.4
- php: 8.0
fast_finish: true

env:
Expand Down
16 changes: 7 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,17 @@ composer: ## Execute composer command
phpunit: ## execute project unit tests
docker-compose run --rm --no-deps php sh -lc "./vendor/bin/phpunit $(conf)"

.PHONY: style
style: ## executes php analizers
.PHONY: phpstan
phpstan: ## executes phpstan analizer
docker-compose run --rm --no-deps php sh -lc './vendor/bin/phpstan analyse -l 6 -c phpstan.neon src tests'

psalm: ## execute psalm analizer
docker-compose run --rm --no-deps php sh -lc './vendor/bin/psalm --config=psalm.xml'

.PHONY: lint
lint: ## checks syntax of PHP files
docker-compose run --rm --no-deps php sh -lc './vendor/bin/parallel-lint ./ --exclude vendor --exclude bin/.phpunit'

.PHONY: layer
layer: ## Check issues with layers (deptrac tool)
docker-compose run --rm --no-deps php sh -lc './vendor/bin/deptrac analyze --formatter-graphviz=0'

.PHONY: logs
logs: ## look for service logs
docker-compose logs -f $(RUN_ARGS)
Expand All @@ -66,7 +64,7 @@ php-shell: ## PHP shell
unit-tests: ## Run unit-tests suite
docker-compose run --rm php sh -lc 'vendor/bin/phpunit --testsuite unit-tests'

static-analysis: style layer coding-standards ## Run phpstan, easycoding standarts code static analysis
static-analysis: psalm phpstan coding-standards ## Run phpstan, psalm, easycoding standarts code static analysis

coding-standards: ## Run check and validate code standards tests
docker-compose run --rm --no-deps php sh -lc 'vendor/bin/ecs check src tests'
Expand All @@ -78,5 +76,5 @@ coding-standards-fixer: ## Run code standards fixer
security-tests: ## The SensioLabs Security Checker
docker-compose run --rm --no-deps php sh -lc 'vendor/bin/security-checker security:check --end-point=http://security.sensiolabs.org/check_lock'

.PHONY: test lint static-analysis phpunit coding-standards composer-validate
test: build lint static-analysis phpunit coding-standards composer-validate stop ## Run all test suites
.PHONY: test lint static-analysis coding-standards composer-validate phpunit
test: build lint static-analysis coding-standards composer-validate phpunit stop ## Run all test suites
19 changes: 10 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,26 @@
"description": "Micro module Base common library",
"license": "proprietary",
"require": {
"php": "^7.3 || ^8.0",
"php": "^7.4 || ^8.0",
"ext-json": "*",
"beberlei/assert": "^3.2",
"ext-intl": "*",
"beberlei/assert": "^3.3",
"psr/log": "^1.1",
"ramsey/uuid": "^3.8 || ^4.0",
"monolog/monolog": "~1.22 || ~2.0"
},
"require-dev": {
"php-parallel-lint/php-console-highlighter": "^0.4",
"php-parallel-lint/php-parallel-lint": "^1.0",
"mockery/mockery": "^1.3",
"phpmd/phpmd": "^2.8",
"php-parallel-lint/php-console-highlighter": "^0.5",
"php-parallel-lint/php-parallel-lint": "^1.2",
"mockery/mockery": "^1.4",
"phpmd/phpmd": "^2.9",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-mockery": "^0.12",
"phpstan/phpstan-phpunit": "^0.12",
"phpunit/phpunit": "^9.4",
"phpunit/phpunit": "^9.3",
"roave/security-advisories": "dev-master",
"symplify/easy-coding-standard": "^7.2",
"vimeo/psalm": "^4.2"
"symplify/easy-coding-standard": "^9.0",
"vimeo/psalm": "^4.4"
},
"config": {
"preferred-install": {
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ version: "3.7"
services:
php:
container_name: ${MICROBASE_COMPOSE_PROJECT_NAME}_php
user: 1000:1000
build:
context: .docker/php7.3-dev
context: .docker/php-dev
env_file:
- .env
volumes:
- ~/.composer/cache/:/.composer_cache/:rw
- .:/app:rw
Expand Down
15 changes: 15 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(__DIR__ . '/vendor/symplify/easy-coding-standard/config/set/clean-code.php');
$containerConfigurator->import(__DIR__ . '/vendor/symplify/easy-coding-standard/config/set/symfony.php');
$containerConfigurator->import(__DIR__ . '/vendor/symplify/easy-coding-standard/config/set/php71.php');
$containerConfigurator->import(__DIR__ . '/vendor/symplify/easy-coding-standard/config/set/psr12.php');
$parameters = $containerConfigurator->parameters();
$parameters->set('skip', [
]);
};
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ includes:

parameters:
excludes_analyse:
- src/Infrastructure/Testing/RedisInMemory.php
- src/Infrastructure/Testing/RedisFactory.php
- tests/unit/Infrastructure/Repository/RedisInMemory.php
- tests/unit/Infrastructure/Factory/RedisFactory.php
5 changes: 2 additions & 3 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
<file name="src/Infrastructure/Testing/RedisFactory.php" />
<file name="src/Infrastructure/Testing/RedisInMemory.php" />
<file name="tests/unit/Infrastructure/Factory/RedisFactory.php" />
<file name="tests/unit/Infrastructure/Repository/RedisInMemory.php" />
</ignoreFiles>
</projectFiles>

Expand All @@ -34,7 +34,6 @@
<MissingReturnType errorLevel="info" />
<MissingPropertyType errorLevel="info" />
<InvalidDocblock errorLevel="info" />
<MisplacedRequiredParam errorLevel="info" />

<PropertyNotSetInConstructor errorLevel="info" />
<MissingConstructor errorLevel="info" />
Expand Down
32 changes: 32 additions & 0 deletions src/Domain/Adapter/HttpRequestInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace MicroModule\Base\Domain\Adapter;

/**
* Interface HttpRequestInterface.
*
* @category Domain\Adapter
*/
interface HttpRequestInterface
{
public const REQUEST_METHOD_GET = 'GET';
public const REQUEST_METHOD_POST = 'POST';
public const RESPONSE_STATUS_SUCCESS = 200;
public const RESPONSE_STATUS_CREATED = 201;
public const RESPONSE_HEADER_CONTENT_TYPE = 'content-type';
public const RESPONSE_HEADER_CONTENT_TYPE_JSON = 'application/json';

/**
* Return request url.
*/
public function getUrl(): string;

/**
* Return request headers.
*
* @return string[]
*/
public function getHeaders(): array;
}
2 changes: 0 additions & 2 deletions src/Domain/Command/CommandInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ interface CommandInterface
{
/**
* Return Uuid.
*
* @return UuidInterface
*/
public function getUuid(): UuidInterface;
}
3 changes: 0 additions & 3 deletions src/Domain/Exception/ParentExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ interface ParentExceptionInterface

/**
* Return parent exception.
*
* @return Throwable
*/
public function getParentException(): Throwable;

/**
* Return context exception array from parent exception object.
*
* @param mixed[] $context
* @param string $contextSerializeType
*
* @return mixed[]
*/
Expand Down
4 changes: 0 additions & 4 deletions src/Domain/Exception/ParentExceptionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ trait ParentExceptionTrait

/**
* Return parent exception.
*
* @return Throwable
*/
public function getParentException(): Throwable
{
Expand All @@ -32,7 +30,6 @@ public function getParentException(): Throwable
* Return context exception array from parent exception object.
*
* @param mixed[] $context
* @param string $contextSerializeType
*
* @return mixed[]
*/
Expand All @@ -54,7 +51,6 @@ public function getParentExceptionContext(array $context = [], string $contextSe
* Serialize if needed context array to string.
*
* @param mixed[] $context
* @param string $contextSerializeType
*
* @return mixed
*/
Expand Down
4 changes: 1 addition & 3 deletions src/Domain/Factory/CommandFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ interface CommandFactoryInterface
/**
* Make CommandBus command instance by constant type.
*
* @param mixed... $args
*
* @return CommandInterface
* @param mixed ...$args
*/
public function makeCommandInstanceByType(...$args): CommandInterface;
}
4 changes: 0 additions & 4 deletions src/Domain/Service/NormalizableServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@ interface NormalizableServiceInterface
* Denormalize array to object.
*
* @param mixed[] $data
*
* @return object
*/
public function denormalize(array $data): object;

/**
* Nermolize object to array.
*
* @param object $object
*
* @return mixed[]
*/
public function normalize(object $object): array;
Expand Down
2 changes: 0 additions & 2 deletions src/Domain/Service/SerializableServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public function deserialize($data): object;
/**
* Serialize object to array.
*
* @param object $object
*
* @return mixed
*/
public function serialize(object $object);
Expand Down
Loading

0 comments on commit 96dca89

Please sign in to comment.