Skip to content

Commit 07098a7

Browse files
committed
update framework version
1 parent fc7ad21 commit 07098a7

File tree

8 files changed

+34
-73
lines changed

8 files changed

+34
-73
lines changed

.travis.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ php:
44
- 7.3
55
- 7.4snapshot
66

7-
matrix:
8-
allow_failures:
9-
- php: 7.4snapshot
7+
addons:
8+
apt:
9+
packages:
10+
- rabbitmq-server
1011

1112
cache:
1213
directories:
@@ -23,11 +24,10 @@ install:
2324
- composer show
2425

2526
script:
26-
- ./vendor/bin/phpunit --configuration ./phpunit.xml --coverage-clover=coverage.clover
27-
- if [ "$TRAVIS_PHP_VERSION" == "7.3" ]; then ./vendor/bin/psalm --config=psalm.xml; fi
28-
- if [ "$TRAVIS_PHP_VERSION" == "7.3" ]; then ./vendor/bin/phpstan analyse src --level 7; fi
29-
- if [ "$TRAVIS_PHP_VERSION" == "7.3" ]; then ./vendor/bin/php-cs-fixer fix --allow-risky=yes --dry-run; fi
27+
- ./vendor/bin/phpunit --configuration ./phpunit.xml --coverage-clover=coverage.clover --debug
28+
- if [ "$TRAVIS_PHP_VERSION" == "7.4snapshot"]; then ./vendor/bin/psalm --config=psalm.xml; fi
29+
- if [ "$TRAVIS_PHP_VERSION" == "7.4snapshot"]; then ./vendor/bin/php-cs-fixer fix --allow-risky=yes --dry-run; fi
3030

3131
after_script:
32-
- if [ "$TRAVIS_PHP_VERSION" == "7.3" ]; then wget -c -nc --retry-connrefused --tries=0 https://scrutinizer-ci.com/ocular.phar; fi
33-
- if [ "$TRAVIS_PHP_VERSION" == "7.3" ]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
32+
- if [ "$TRAVIS_PHP_VERSION" == "7.4snapshot"]; then wget -c -nc --retry-connrefused --tries=0 https://scrutinizer-ci.com/ocular.phar; fi
33+
- if [ "$TRAVIS_PHP_VERSION" == "7.4snapshot"]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi

bin/consumer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Loop::run(
4747

4848
yield $kernel->createQueue(
4949
$mainQueue,
50-
QueueBind::create($mainExchange, (string) \getenv('TRANSPORT_ROUTING_KEY'))
50+
new QueueBind($mainExchange, (string) \getenv('TRANSPORT_ROUTING_KEY'))
5151
);
5252

5353
yield $kernel->run($mainQueue);

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
"require": {
88
"php": ">=7.3",
99
"ext-json": "*",
10-
"php-service-bus/service-bus": "v3.3.*",
11-
"php-service-bus/module-phpinnacle-transport": "v3.3.*"
10+
"php-service-bus/service-bus": "v4.0.*",
11+
"php-service-bus/module-phpinnacle-transport": "v4.0.*"
1212
},
1313
"require-dev": {
14-
"php-service-bus/code-style-config": "v0.1.*",
15-
"phpunit/phpunit": "v8.3.*",
16-
"vimeo/psalm": "v3.4.*",
14+
"php-service-bus/code-style-config": "v1.2.*",
15+
"phpunit/phpunit": "v8.4.*",
16+
"vimeo/psalm": "v3.7.*",
1717
"phpstan/phpstan": "v0.11.*"
1818
},
1919
"config": {

docker/application/Dockerfile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
FROM php:7.3-cli-alpine
1+
FROM php:7.4-cli-alpine
22

33
RUN set -xe \
44
&& apk update \
5-
&& apk add libpq postgresql-dev libevent-dev autoconf zlib-dev g++ libtool make libzip-dev git \
5+
&& apk add oniguruma-dev libpq postgresql-dev libevent-dev autoconf zlib-dev g++ libtool make libzip-dev git \
66
# Iconv fix
77
&& apk add --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ gnu-libiconv \
88
&& docker-php-ext-install \
@@ -40,10 +40,4 @@ RUN echo "f80bbb8ea85346bf6082727fdf58857c59649da2" \
4040
&& make install \
4141
&& echo "extension=buffer.so" > /usr/local/etc/php/conf.d/buffer.ini
4242

43-
# Composer install
44-
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
45-
&& chmod +x /usr/local/bin/composer \
46-
&& composer global require hirak/prestissimo \
47-
&& composer clear-cache
48-
4943
COPY ./tools/* /tools/

phpunit.xml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
4-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.4/phpunit.xsd"
2+
<phpunit bootstrap="vendor/autoload.php"
63
backupGlobals="false"
4+
backupStaticAttributes="false"
5+
beStrictAboutTestsThatDoNotTestAnything="false"
76
colors="true"
8-
bootstrap="vendor/autoload.php"
7+
verbose="true"
8+
convertErrorsToExceptions="true"
9+
convertNoticesToExceptions="true"
10+
convertWarningsToExceptions="true"
911
failOnRisky="true"
1012
failOnWarning="true"
11-
beStrictAboutTestsThatDoNotTestAnything="false">
13+
stopOnFailure="false">
1214
<php>
1315
<ini name="error_reporting" value="-1"/>
14-
<env name="TEST_POSTGRES_DSN" value="pgsql://postgres:123456789@localhost:5432/test"/>
15-
<env name="TRANSPORT_CONNECTION_DSN" value="amqp://guest:guest@localhost:5672"/>
16-
<env name="DATABASE_CONNECTION_DSN" value="sqlite:///:memory:"/>
1716
</php>
1817

1918
<testsuites>
20-
<testsuite name="Application testing">
19+
<testsuite name="Service bus skeleton">
2120
<directory>./tests/</directory>
2221
</testsuite>
2322
</testsuites>

psalm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
useDocblockPropertyTypes="true"
66
allowPhpStormGenerics="true"
77
requireVoidReturnType="true"
8+
strictBinaryOperands="true"
89
ignoreInternalFunctionFalseReturn="false"
910
ignoreInternalFunctionNullReturn="false"
1011
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

src/PingService.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace App;
1515

1616
use Amp\Promise;
17-
use ServiceBus\Context\KernelContext;
17+
use ServiceBus\Common\Context\ServiceBusContext;
1818
use ServiceBus\Services\Annotations\CommandHandler;
1919
use ServiceBus\Services\Annotations\EventListener;
2020

@@ -25,27 +25,17 @@ final class PingService
2525
{
2626
/**
2727
* @CommandHandler()
28-
*
29-
* @param Ping $command
30-
* @param KernelContext $context
31-
*
32-
* @return Promise
3328
*/
34-
public function handle(Ping $command, KernelContext $context): Promise
29+
public function handle(Ping $command, ServiceBusContext $context): Promise
3530
{
3631
return $context->delivery(new Pong());
3732
}
3833

3934
/**
40-
* @EventListener()
41-
*
42-
* @param Pong $event
43-
* @param KernelContext $context
44-
*
45-
* @return void
35+
* @EventListener(description="Pong message received")
4636
*/
47-
public function whenPong(Pong $event, KernelContext $context): void
37+
public function whenPong(Pong $event, ServiceBusContext $context): void
4838
{
49-
$context->logContextMessage('Pong message received');
39+
5040
}
5141
}

tools/ToolsPublisher.php

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,18 @@ final class ToolsPublisher
3131
private $encoder;
3232

3333
/**
34-
* @param string $envPath
35-
*
3634
* @throws \Symfony\Component\Dotenv\Exception\FormatException
3735
* @throws \Symfony\Component\Dotenv\Exception\PathException
3836
*/
3937
public function __construct(string $envPath)
4038
{
41-
(new Dotenv())->load($envPath);
39+
(new Dotenv(true))->load($envPath);
4240

4341
$this->encoder = new SymfonyMessageSerializer();
4442
}
4543

4644
/**
4745
* Send message to queue.
48-
*
49-
* @param object $message
50-
* @param string|null $traceId
51-
* @param string|null $topic
52-
* @param string|null $routingKey
53-
*
54-
* @throws \ServiceBus\MessageSerializer\Exceptions\EncodeMessageFailed
55-
* @throws \ServiceBus\Transport\Common\Exceptions\InvalidConnectionParameters
56-
* @throws \ServiceBus\Transport\Common\Exceptions\SendMessageFailed
57-
* @throws \Throwable
58-
*
59-
* @return void
60-
*
6146
*/
6247
public function sendMessage(object $message, string $traceId = null, ?string $topic = null, ?string $routingKey = null): void
6348
{
@@ -67,7 +52,7 @@ public function sendMessage(object $message, string $traceId = null, ?string $to
6752
/** @noinspection PhpUnhandledExceptionInspection */
6853
wait(
6954
$this->transport()->send(
70-
OutboundPackage::create(
55+
new OutboundPackage(
7156
$this->encoder->encode($message),
7257
[Transport::SERVICE_BUS_TRACE_HEADER => $traceId ?? uuid()],
7358
new AmqpTransportLevelDestination($topic, $routingKey),
@@ -77,14 +62,6 @@ public function sendMessage(object $message, string $traceId = null, ?string $to
7762
);
7863
}
7964

80-
/**
81-
* @noinspection PhpDocMissingThrowsInspection
82-
*
83-
* @throws \ServiceBus\Transport\Common\Exceptions\InvalidConnectionParameters
84-
*
85-
* @return Transport
86-
*
87-
*/
8865
private function transport(): Transport
8966
{
9067
if (null === $this->transport)

0 commit comments

Comments
 (0)