Skip to content

Commit

Permalink
Merge pull request #78 from PavelJurasek/php8
Browse files Browse the repository at this point in the history
PHP 8
  • Loading branch information
Spamercz authored Sep 8, 2021
2 parents aa2b449 + c0684ec commit 31f985e
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 76 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/php-package-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Package CI

on:
pull_request:

jobs:
checks:
name: Checks
runs-on: ubuntu-latest
strategy:
matrix:
php: [ 7.4, 8.0 ]
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- uses: getong/[email protected]
with:
rabbitmq version: '3.9.5-management-alpine'
host port: 5672
rabbitmq user: 'guest'
rabbitmq password: 'guest'
rabbitmq vhost: '/'

- run: composer update --no-interaction --no-suggest --no-progress --prefer-dist

- run: sleep 3

- run: make lint

- run: make run-tests

- run: make phpstan
58 changes: 0 additions & 58 deletions .travis.yml

This file was deleted.

14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
lint:
vendor/bin/parallel-lint -e php,phpt --exclude vendor .

phpstan:
vendor/bin/phpstan analyse -l 2 -c phpstan.neon src tests/KdybyTests

run-tests:
vendor/bin/tester -s -c ./tests/php.ini-unix ./tests/KdybyTests/

run-tests-coverage:
vendor/bin/tester --coverage ./coverage.xml --coverage-src ./src -s -p phpdbg -c ./tests/php.ini-unix ./tests/KdybyTests/

coveralls:
vendor/bin/php-coveralls --verbose --config tests/.coveralls.yml
16 changes: 7 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,21 @@
}
],
"require": {
"php": "^7.1",
"nette/di": "~2.4.10 || ^3.0",
"php": "^7.4 | ^8.0",
"nette/di": "^3.0",
"nette/utils": "^3.0",

"php-amqplib/php-amqplib": "~2.6.2"
"php-amqplib/php-amqplib": "~3.0.0"
},
"require-dev": {
"kdyby/console": "~2.8",

"nette/bootstrap": "~2.4 || ~3.0",
"nette/bootstrap": "~3.0",
"latte/latte": "~2.4",
"tracy/tracy": "~2.4",
"phpstan/phpstan-shim": "^0.11.4",
"kdyby/coding-standard": "dev-master",
"phpstan/phpstan": "^0.12.88",
"php-coveralls/php-coveralls": "^2.1",
"nette/tester": "^2.3.2",
"mockery/mockery": "~1.3.0",
"jakub-onderka/php-parallel-lint": "^1.0",
"php-parallel-lint/php-parallel-lint": "^1.3",
"typo3/class-alias-loader": "^1.0",
"nette/caching": "^3.0"
},
Expand All @@ -52,6 +49,7 @@
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
parameters:
ignoreErrors:
- '#Parameter \$callback of method KdybyTests\\RabbitMq\\Mock\\ChannelMock\:\:basic_consume\(\) has invalid typehint type PhpAmqpLib\\Channel\\callback.#'

excludes_analyse:
- *src/Kdyby/RabbitMq/DI/ClassAliasMap.php
Expand Down
4 changes: 2 additions & 2 deletions src/Kdyby/RabbitMq/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ public function channel($id = NULL): Channel
$this->connect();
$id = $id ?: $this->get_free_channel_id();

return $this->channels[$id] = $this->doCreateChannel((string) $id);
return $this->channels[$id] = $this->doCreateChannel($id);
}

protected function doCreateChannel(string $id): Channel
protected function doCreateChannel(int $id): Channel
{
$channel = new Channel($this->connection, $id);

Expand Down
21 changes: 18 additions & 3 deletions tests/KdybyTests/RabbitMq/BaseAmqpTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,24 @@ class BaseAmqpTest extends \KdybyTests\RabbitMq\TestCase
$lazyConnection = new Connection('localhost', 123, 'lazy_user', 'lazy_password');
$consumer = new Consumer($lazyConnection);

Assert::exception(static function () use ($consumer): void {
$consumer->getChannel();
}, \ErrorException::class, 'stream_socket_client(): unable to connect to tcp://localhost:123 (Connection refused)');
if (\PHP_VERSION_ID >= 80000) {
Assert::exception(
static function () use ($consumer): void {
$consumer->getChannel();
},
\PhpAmqpLib\Exception\AMQPIOException::class,
'stream_socket_client(): Unable to connect to tcp://localhost:123 (Connection refused)'
);

} else {
Assert::exception(
static function () use ($consumer): void {
$consumer->getChannel();
},
\PhpAmqpLib\Exception\AMQPIOException::class,
'stream_socket_client(): unable to connect to tcp://localhost:123 (Connection refused)'
);
}
}

}
Expand Down
5 changes: 3 additions & 2 deletions tests/KdybyTests/RabbitMq/Mock/ChannelMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public function exchange_unbind(
$destination,
$source,
$routingKey = '',
$arguments = NULL,
$nowait = false,
$arguments = [],
$ticket = NULL
)
{
Expand Down Expand Up @@ -312,7 +313,7 @@ protected function basic_return(
)
{
$this->calls[] = [__FUNCTION__] + \get_defined_vars();
parent::basic_return($args, $msg);
return parent::basic_return($args, $msg);
}

// phpcs:disable SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint,SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint,PSR1.Methods.CamelCapsMethodName
Expand Down
2 changes: 1 addition & 1 deletion tests/KdybyTests/RabbitMq/Mock/ConnectionMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class ConnectionMock extends \Kdyby\RabbitMq\Connection
{

protected function doCreateChannel(string $id): \Kdyby\RabbitMq\Channel
protected function doCreateChannel(int $id): \Kdyby\RabbitMq\Channel
{
return new ChannelMock($this, $id);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/php.ini-unix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extension=sockets
extension=iconv
extension=tokenizer

0 comments on commit 31f985e

Please sign in to comment.