Support PHP 8.2 (#5087)

Co-authored-by: 李铭昕 <715557344@qq.com>
This commit is contained in:
Deeka Wong 2022-12-10 21:24:37 +08:00 committed by GitHub
parent 2bfb5c21be
commit c07162dc5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 61 additions and 23 deletions

View File

@ -15,7 +15,7 @@ jobs:
PHP_VERSION: ${{ matrix.php-version }}
strategy:
matrix:
php-version: [ '8.0', '8.1' ]
php-version: [ '8.0', '8.1', '8.2' ]
mysql-version: [ '5.7', '8.0' ]
max-parallel: 2
fail-fast: false
@ -52,7 +52,7 @@ jobs:
strategy:
matrix:
version: [ '^1.0', '^2.0', '^3.0' ]
php-version: [ '8.0', '8.1' ]
php-version: [ '8.0', '8.1', '8.2' ]
max-parallel: 2
fail-fast: false
steps:
@ -100,7 +100,7 @@ jobs:
strategy:
matrix:
no-dev: [ '--no-dev', '' ]
php-version: [ '8.0', '8.1' ]
php-version: [ '8.0', '8.1', '8.2' ]
max-parallel: 2
fail-fast: false
steps:
@ -147,7 +147,7 @@ jobs:
PHP_VERSION: ${{ matrix.php-version }}
strategy:
matrix:
php-version: [ '8.0', '8.1' ]
php-version: [ '8.0', '8.1', '8.2' ]
version: [ '^1.0', '^2.0' ]
max-parallel: 6
fail-fast: false
@ -182,11 +182,13 @@ jobs:
PHP_VERSION: ${{ matrix.php-version }}
strategy:
matrix:
php-version: [ '8.0', '8.1' ]
php-version: [ '8.0', '8.1', '8.2' ]
log-version: [ '^1.0', '^2.0', '^3.0' ]
exclude:
- php-version: '8.1'
log-version: '^1.0'
- php-version: '8.2'
log-version: '^1.0'
max-parallel: 5
fail-fast: false
steps:
@ -233,7 +235,7 @@ jobs:
PHP_VERSION: ${{ matrix.php-version }}
strategy:
matrix:
php-version: [ '8.0', '8.1' ]
php-version: [ '8.0', '8.1', '8.2' ]
psr-version: [ '^1.0', '^2.0', '^3.0' ]
max-parallel: 3
fail-fast: false

View File

@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest ]
php-version: [ '8.0', '8.1' ]
php-version: [ '8.0', '8.1', '8.2' ]
sw-version: [ 'v4.5.11', 'v4.6.7', 'v4.7.1', 'v4.8.12', 'v5.0.1', 'master' ]
exclude:
- php-version: '8.1'
@ -22,6 +22,14 @@ jobs:
sw-version: 'v4.6.7'
- php-version: '8.1'
sw-version: 'v4.7.1'
- php-version: '8.2'
sw-version: 'v4.5.11'
- php-version: '8.2'
sw-version: 'v4.6.7'
- php-version: '8.2'
sw-version: 'v4.7.1'
- php-version: '8.2'
sw-version: 'v4.8.12'
max-parallel: 12
fail-fast: false
env:

View File

@ -1,3 +1,3 @@
#!/usr/bin/env bash
vendor/bin/php-cs-fixer fix src --dry-run
PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix src --dry-run
composer analyse src

View File

@ -1,6 +1,7 @@
# v3.0.0 - TBD
- [#4238](https://github.com/hyperf/hyperf/issues/4238) Upgraded the minimum php version to `^8.0` for all components;
- [#5087](https://github.com/hyperf/hyperf/pull/5087) Support PHP 8.2;
## BC breaks

View File

@ -41,7 +41,7 @@ class ConsumerManager
$annotation->routingKey && $instance->setRoutingKey($annotation->routingKey);
$annotation->queue && $instance->setQueue($annotation->queue);
! is_null($annotation->enable) && $instance->setEnable($annotation->enable);
property_exists($instance, 'container') && $instance->container = $this->container;
$instance->setContainer($this->container);
$annotation->maxConsumption && $instance->setMaxConsumption($annotation->maxConsumption);
! is_null($annotation->nums) && $instance->setNums($annotation->nums);
$process = $this->createProcess($instance);

View File

@ -53,7 +53,7 @@ abstract class ConsumerMessage extends Message implements ConsumerMessageInterfa
return Result::ACK;
}
public function setQueue(string $queue): self
public function setQueue(string $queue): static
{
$this->queue = $queue;
return $this;
@ -97,7 +97,7 @@ abstract class ConsumerMessage extends Message implements ConsumerMessageInterfa
return $this->enable;
}
public function setEnable(bool $enable): self
public function setEnable(bool $enable): static
{
$this->enable = $enable;
return $this;
@ -108,7 +108,7 @@ abstract class ConsumerMessage extends Message implements ConsumerMessageInterfa
return $this->maxConsumption;
}
public function setMaxConsumption(int $maxConsumption)
public function setMaxConsumption(int $maxConsumption): static
{
$this->maxConsumption = $maxConsumption;
return $this;
@ -119,7 +119,7 @@ abstract class ConsumerMessage extends Message implements ConsumerMessageInterfa
return $this->waitTimeout;
}
public function setWaitTimeout(int|float $timeout)
public function setWaitTimeout(int|float $timeout): static
{
$this->waitTimeout = $timeout;
return $this;
@ -130,12 +130,23 @@ abstract class ConsumerMessage extends Message implements ConsumerMessageInterfa
return $this->nums;
}
public function setNums(int $nums)
public function setNums(int $nums): static
{
$this->nums = $nums;
return $this;
}
public function setContainer(ContainerInterface $container): static
{
$this->container = $container;
return $this;
}
public function getContainer(): ?ContainerInterface
{
return $this->container;
}
protected function reply($data, AMQPMessage $message)
{
$packer = ApplicationContext::getContainer()->get(Packer::class);

View File

@ -13,12 +13,13 @@ namespace Hyperf\Amqp\Message;
use Hyperf\Amqp\Builder\QueueBuilder;
use PhpAmqpLib\Message\AMQPMessage;
use Psr\Container\ContainerInterface;
interface ConsumerMessageInterface extends MessageInterface
{
public function consumeMessage($data, AMQPMessage $message): string;
public function setQueue(string $queue);
public function setQueue(string $queue): static;
public function getQueue(): string;
@ -32,17 +33,21 @@ interface ConsumerMessageInterface extends MessageInterface
public function isEnable(): bool;
public function setEnable(bool $enable);
public function setEnable(bool $enable): static;
public function getMaxConsumption(): int;
public function setMaxConsumption(int $maxConsumption);
public function setMaxConsumption(int $maxConsumption): static;
public function getWaitTimeout(): int|float;
public function setWaitTimeout(int|float $timeout);
public function setWaitTimeout(int|float $timeout): static;
public function setNums(int $nums);
public function setNums(int $nums): static;
public function getNums(): int;
public function setContainer(ContainerInterface $container): static;
public function getContainer(): ?ContainerInterface;
}

View File

@ -21,14 +21,17 @@ use ReflectionMethod;
*/
class ParserCronNumberTest extends TestCase
{
protected $timezone;
protected function setUp(): void
{
$this->timezone = ini_get('date.timezone');
ini_set('date.timezone', 'Asia/Shanghai');
}
protected function tearDown(): void
{
ini_set('date.timezone', '');
ini_set('date.timezone', $this->timezone);
}
public function testParse()

View File

@ -21,14 +21,17 @@ use PHPUnit\Framework\TestCase;
*/
class ParserTest extends TestCase
{
protected $timezone;
protected function setUp(): void
{
$this->timezone = ini_get('date.timezone');
ini_set('date.timezone', 'Asia/Shanghai');
}
protected function tearDown(): void
{
ini_set('date.timezone', '');
ini_set('date.timezone', $this->timezone);
}
public function testParseSecondLevel()

View File

@ -14,6 +14,7 @@ namespace Hyperf\Devtool\Describe;
use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Event\ListenerData;
use Hyperf\Event\ListenerProvider;
use Psr\Container\ContainerInterface;
use Psr\EventDispatcher\ListenerProviderInterface;
use Symfony\Component\Console\Helper\Table;
@ -50,7 +51,7 @@ class ListenersCommand extends HyperfCommand
protected function handleData(ListenerProviderInterface $provider, ?array $events, ?array $listeners): array
{
$data = [];
if (! property_exists($provider, 'listeners')) {
if (! $provider instanceof ListenerProvider) {
return $data;
}
foreach ($provider->listeners as $listener) {

View File

@ -54,7 +54,7 @@ class JsonRpcHttpTransporter implements TransporterInterface
$uri = $node->host . ':' . $node->port . $node->pathPrefix;
$schema = value(function () use ($node) {
$schema = 'http';
if (property_exists($node, 'schema')) {
if ($node->schema !== null) {
$schema = $node->schema;
}
if (! in_array($schema, ['http', 'https'])) {

View File

@ -13,6 +13,8 @@ namespace Hyperf\LoadBalancer;
class Node
{
public ?string $schema = null;
public function __construct(public string $host, public int $port, public int $weight = 0, public string $pathPrefix = '')
{
}

View File

@ -61,6 +61,7 @@ class ConfigFactory{
return null;
}
foreach ($stmts as $node) {
/* @phpstan-ignore-next-line */
if (isset($node->stmts) && is_array($node->stmts) && ! empty($node->stmts)) {
foreach ($node->stmts as $val) {
return $val;

View File

@ -131,6 +131,7 @@ class Serializer implements Normalizer, SerializerInterface, ContextAwareNormali
/**
* @phpstan-ignore-next-line
* @param mixed $data
*/
final public function deserialize($data, string $type, string $format, array $context = []): mixed
{