Skip to content

Commit 03696b6

Browse files
authored
Merge branch 'master' into testComposer2
2 parents e886c71 + 63a4958 commit 03696b6

26 files changed

+133
-159
lines changed

.github/workflows/phpunit.yml

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,25 @@ jobs:
1010
max-parallel: 4
1111
matrix:
1212
include:
13-
- php: '7.0'
14-
phpseclib: '^2.0'
15-
composer: 'composer:v1'
16-
- php: '7.1'
17-
phpseclib: '^2.0'
18-
composer: 'composer:v1'
19-
- php: '7.2'
20-
phpseclib: '^2.0'
21-
composer: 'composer:v1'
22-
- php: '7.3'
23-
phpseclib: '^3.0'
24-
composer: 'composer:v1'
25-
- php: '7.4'
26-
phpseclib: '^3.0'
27-
composer: 'composer:v1'
28-
- php: '7.4'
29-
phpseclib: '^3.0'
30-
composer: 'composer:v2'
13+
- php: '7.0'
14+
phpseclib: '^2.0'
15+
composer: 'composer:v1'
16+
- php: '7.1'
17+
phpseclib: '^2.0'
18+
composer: 'composer:v1'
19+
- php: '7.2'
20+
phpseclib: '^2.0'
21+
composer: 'composer:v1'
22+
- php: '7.3'
23+
phpseclib: '^3.0'
24+
composer: 'composer:v1'
25+
- php: '7.4'
26+
phpseclib: '^3.0'
27+
composer: 'composer:v1'
28+
- php: '7.4'
29+
phpseclib: '^3.0'
30+
composer: 'composer:v2'
31+
coverage: 'xdebug'
3132
services:
3233
rabbitmq:
3334
image: rabbitmq:3-management
@@ -48,21 +49,39 @@ jobs:
4849
steps:
4950
- name: Checkout
5051
uses: actions/checkout@v2
52+
5153
- name: Install PHP
5254
uses: shivammathur/setup-php@v2
5355
with:
5456
php-version: ${{ matrix.php }}
5557
tools: ${{ matrix.composer }}
5658
extensions: bcmath, curl, dom, mbstring, pcntl, sockets, xml
57-
coverage: none
59+
coverage: ${{ matrix.coverage }}
60+
5861
- name: Check PHP info
5962
run: php tests/phpinfo.php
63+
6064
- name: Start broker service
6165
run: docker start ${{ job.services.rabbitmq.id }}
66+
6267
- name: Composer install
6368
run: composer require --prefer-dist --no-progress --no-suggest phpseclib/phpseclib ${{ matrix.phpseclib }}
69+
6470
- name: Wait for broker service
6571
run: php ./tests/wait_broker.php
72+
6673
- name: PHPUnit tests
6774
run: ./vendor/bin/phpunit --exclude-group proxy
75+
if: matrix.coverage != 'xdebug'
76+
77+
- name: PHPUnit tests and Log Code coverage
78+
run: ./vendor/bin/phpunit --exclude-group proxy --coverage-clover=coverage.xml
79+
if: matrix.coverage == 'xdebug'
80+
81+
- name: Run codecov
82+
uses: codecov/codecov-action@v1
83+
if: matrix.coverage == 'xdebug'
84+
with:
85+
file: './coverage.xml'
86+
fail_ci_if_error: true
6887

.travis.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

PhpAmqpLib/Channel/AbstractChannel.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public static function getProtocolVersion()
139139
}
140140

141141
/**
142-
* @return string
142+
* @return int
143143
*/
144144
public function getChannelId()
145145
{
@@ -213,7 +213,7 @@ public function dispatch($method_sig, $args, $amqpMessage)
213213

214214
$this->dispatch_reader->reuse($args);
215215

216-
if ($amqpMessage == null) {
216+
if ($amqpMessage === null) {
217217
return call_user_func(array($this, $amqp_method), $this->dispatch_reader);
218218
}
219219

@@ -273,8 +273,8 @@ public function wait_content()
273273

274274
$this->wait_content_reader->reuse(mb_substr($payload, 0, 12, 'ASCII'));
275275

276-
$class_id = $this->wait_content_reader->read_short();
277-
$weight = $this->wait_content_reader->read_short();
276+
$this->wait_content_reader->read_short();
277+
$this->wait_content_reader->read_short();
278278

279279
//hack to avoid creating new instances of AMQPReader;
280280
$this->msg_property_reader->reuse(mb_substr($payload, 12, mb_strlen($payload, 'ASCII') - 12, 'ASCII'));
@@ -323,7 +323,7 @@ protected function createMessage($propertyReader, $contentReader)
323323
* Unexpected methods are queued up for later calls to this PHP
324324
* method.
325325
*
326-
* @param array $allowed_methods
326+
* @param array|null $allowed_methods
327327
* @param bool $non_blocking
328328
* @param int|float|null $timeout
329329
* @throws \PhpAmqpLib\Exception\AMQPOutOfBoundsException
@@ -385,7 +385,7 @@ public function wait($allowed_methods = null, $non_blocking = false, $timeout =
385385
}
386386

387387
/**
388-
* @param array $allowed_methods
388+
* @param array|null $allowed_methods
389389
* @return array
390390
*/
391391
protected function process_deferred_methods($allowed_methods)
@@ -398,7 +398,7 @@ protected function process_deferred_methods($allowed_methods)
398398

399399
$method_sig = $qm[0];
400400

401-
if ($allowed_methods == null || in_array($method_sig, $allowed_methods)) {
401+
if ($allowed_methods === null || in_array($method_sig, $allowed_methods, true)) {
402402
unset($this->method_queue[$qk]);
403403
$dispatch = true;
404404
$queued_method = $qm;
@@ -454,7 +454,7 @@ protected function validate_body_frame($frame_type)
454454
*/
455455
protected function validate_frame($frameType, $expectedType, $expectedMessage)
456456
{
457-
if ($frameType != $expectedType) {
457+
if ($frameType !== $expectedType) {
458458
throw new AMQPInvalidFrameException(sprintf(
459459
'Expecting %s, received frame type %s (%s)',
460460
$expectedMessage,
@@ -502,8 +502,8 @@ protected function extract_args($payload)
502502
*/
503503
protected function should_dispatch_method($allowed_methods, $method_sig)
504504
{
505-
return $allowed_methods == null
506-
|| in_array($method_sig, $allowed_methods)
505+
return $allowed_methods === null
506+
|| in_array($method_sig, $allowed_methods, true)
507507
|| $this->constants->isCloseMethod($method_sig);
508508
}
509509

PhpAmqpLib/Connection/AMQPStreamConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class AMQPStreamConnection extends AbstractConnection
1818
* @param string $locale
1919
* @param float $connection_timeout
2020
* @param float $read_write_timeout
21-
* @param null $context
21+
* @param resource|array|null $context
2222
* @param bool $keepalive
2323
* @param int $heartbeat
2424
* @param float $channel_rpc_timeout

PhpAmqpLib/Connection/AbstractConnection.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ public function send_content($channel, $class_id, $weight, $body_size, $packed_p
446446
* @param int $body_size
447447
* @param string $packed_properties
448448
* @param string $body
449-
* @param AMQPWriter $pkt
449+
* @param AMQPWriter|null $pkt
450450
* @return AMQPWriter
451451
*/
452452
public function prepare_content($channel, $class_id, $weight, $body_size, $packed_properties, $body, $pkt)
@@ -524,7 +524,7 @@ protected function send_channel_method_frame($channel, $method_sig, $args = '',
524524
* @param string $channel
525525
* @param array $method_sig
526526
* @param AMQPWriter|string $args
527-
* @param AMQPWriter $pkt
527+
* @param AMQPWriter|null $pkt
528528
* @return AMQPWriter
529529
*/
530530
protected function prepare_channel_method_frame($channel, $method_sig, $args = '', $pkt = null)
@@ -605,7 +605,7 @@ protected function wait_frame($timeout = 0)
605605

606606
$this->input->setTimeout($currentTimeout);
607607

608-
if ($ch != 0xCE) {
608+
if ($ch !== 0xCE) {
609609
throw new AMQPInvalidFrameException(sprintf(
610610
'Framing error, unexpected byte: %x',
611611
$ch
@@ -618,7 +618,7 @@ protected function wait_frame($timeout = 0)
618618
/**
619619
* Waits for a frame from the server destined for a particular channel.
620620
*
621-
* @param string $channel_id
621+
* @param int $channel_id
622622
* @param int|float|null $timeout
623623
* @return array
624624
*/
@@ -635,9 +635,9 @@ protected function wait_channel($channel_id, $timeout = 0)
635635
$this->heartbeat && $this->last_frame
636636
&& microtime(true) - ($this->heartbeat * 2) > $this->last_frame
637637
) {
638-
$this->debug->debug_msg("missed server heartbeat (at threshold * 2)");
638+
$this->debug->debug_msg('missed server heartbeat (at threshold * 2)');
639639
$this->setIsConnected(false);
640-
throw new AMQPHeartbeatMissedException("Missed server heartbeat");
640+
throw new AMQPHeartbeatMissedException('Missed server heartbeat');
641641
}
642642

643643
throw $e;
@@ -647,18 +647,18 @@ protected function wait_channel($channel_id, $timeout = 0)
647647

648648
if ($frame_channel === 0 && $frame_type === 8) {
649649
// skip heartbeat frames and reduce the timeout by the time passed
650-
$this->debug->debug_msg("received server heartbeat");
650+
$this->debug->debug_msg('received server heartbeat');
651651
if ($_timeout > 0) {
652652
$_timeout -= $this->last_frame - $start;
653653
if ($_timeout <= 0) {
654654
// If timeout has been reached, throw the exception without calling wait_frame
655-
throw new AMQPTimeoutException("Timeout waiting on channel");
655+
throw new AMQPTimeoutException('Timeout waiting on channel');
656656
}
657657
}
658658
continue;
659659
}
660660

661-
if ($frame_channel == $channel_id) {
661+
if ($frame_channel === $channel_id) {
662662
return array($frame_type, $payload);
663663
}
664664

@@ -667,7 +667,7 @@ protected function wait_channel($channel_id, $timeout = 0)
667667
// Make sure the channel still exists, it could have been
668668
// closed by a previous Exception.
669669
if (isset($this->channels[$frame_channel])) {
670-
array_push($this->channels[$frame_channel]->frame_queue, array($frame_type, $payload));
670+
$this->channels[$frame_channel]->frame_queue[] = [$frame_type, $payload];
671671
}
672672

673673
// If we just queued up a method for channel 0 (the Connection
@@ -683,7 +683,7 @@ protected function wait_channel($channel_id, $timeout = 0)
683683
* Fetches a channel object identified by the numeric channel_id, or
684684
* create that object if it doesn't already exist.
685685
*
686-
* @param int $channel_id
686+
* @param int|null $channel_id
687687
* @return AMQPChannel
688688
*/
689689
public function channel($channel_id = null)
@@ -692,7 +692,7 @@ public function channel($channel_id = null)
692692
return $this->channels[$channel_id];
693693
}
694694

695-
$channel_id = $channel_id ? $channel_id : $this->get_free_channel_id();
695+
$channel_id = $channel_id ?: $this->get_free_channel_id();
696696
$ch = new AMQPChannel($this, $channel_id, true, $this->channel_rpc_timeout);
697697
$this->channels[$channel_id] = $ch;
698698

@@ -709,12 +709,12 @@ public function channel($channel_id = null)
709709
*/
710710
public function close($reply_code = 0, $reply_text = '', $method_sig = array(0, 0))
711711
{
712-
$result = null;
713712
$this->io->disableHeartbeat();
714713
if (empty($this->protocolWriter) || !$this->isConnected()) {
715-
return $result;
714+
return null;
716715
}
717716

717+
$result = null;
718718
try {
719719
$this->closeChannels();
720720
list($class_id, $method_id, $args) = $this->protocolWriter->connectionClose(
@@ -1126,12 +1126,12 @@ public static function create_connection($hosts, $options = array())
11261126
}
11271127

11281128
foreach ($hosts as $hostdef) {
1129-
AbstractConnection::validate_host($hostdef);
1129+
self::validate_host($hostdef);
11301130
$host = $hostdef['host'];
11311131
$port = $hostdef['port'];
11321132
$user = $hostdef['user'];
11331133
$password = $hostdef['password'];
1134-
$vhost = isset($hostdef['vhost']) ? $hostdef['vhost'] : "/";
1134+
$vhost = isset($hostdef['vhost']) ? $hostdef['vhost'] : '/';
11351135
try {
11361136
$conn = static::try_create_connection($host, $port, $user, $password, $vhost, $options);
11371137
return $conn;

PhpAmqpLib/Helper/DebugHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function debug_msg($msg)
4646
}
4747

4848
/**
49-
* @param array $allowed_methods
49+
* @param array|null $allowed_methods
5050
*/
5151
public function debug_allowed_methods($allowed_methods)
5252
{
@@ -61,7 +61,7 @@ public function debug_allowed_methods($allowed_methods)
6161
}
6262

6363
/**
64-
* @param string $method_sig
64+
* @param string|array $method_sig
6565
*/
6666
public function debug_method_signature1($method_sig)
6767
{
@@ -70,7 +70,7 @@ public function debug_method_signature1($method_sig)
7070

7171
/**
7272
* @param string $msg
73-
* @param string $method_sig
73+
* @param string|array $method_sig
7474
*/
7575
public function debug_method_signature($msg, $method_sig)
7676
{

PhpAmqpLib/Message/AMQPMessage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ public function serialize_properties()
525525
}
526526

527527
$flag_bits |= (1 << $shift);
528-
if ($prototype != 'bit') {
528+
if ($prototype !== 'bit') {
529529
$raw_bytes->{'write_' . $prototype}($val);
530530
}
531531

0 commit comments

Comments
 (0)