Skip to content

Commit

Permalink
Support customized local configuration files for PHPStan and PHPUnit …
Browse files Browse the repository at this point in the history
…(#502)

* Support customized local configuration files for PHPStan and PHPUnit

* Optimize

* Fix return type declarations in Kafka and Log facades

* Refactor array and collection mixins

* Update type hint for process method in TaskHandleListener

* Update CacheInterface and Cache class

* Refactor ParameterParser class by removing unused code

* Refactor Etcd and Nacos drivers, and fix EnvWriter return statement

* Fix type hinting in exception handling functions

* Fix column value retrieval in FastPaginate.php

* Refactor validation rules in ValidationAspect.php

* Update helper functions and fix deprecated functions

* Refactor log writer to use null coalescing operator for default values

* Fix code formatting and remove unused code

* Update variable type in ResponseSequence class and fix factory function in Functions.php

* Fix code inconsistencies and improve code readability

* Update phpstan.neon.dist to include phpstan-baseline.neon

This commit updates the phpstan.neon.dist file to include the phpstan-baseline.neon file. The previous include statement for vendor/phpstan/phpstan-deprecation-rules/rules.neon has been commented out. This change ensures that the phpstan-baseline.neon file is included in the analysis performed by vendor/bin/phpstan.

* Update PHPStan configuration file

* Fix isInstanceCall method logic

* Refactor access log message formatting

---------

Co-authored-by: Deeka Wong <[email protected]>
  • Loading branch information
huangdijia and huangdijia committed Dec 20, 2023
1 parent 741194a commit a7d2330
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 22 deletions.
6 changes: 0 additions & 6 deletions src/Command/SubscribersCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use FriendsOfHyperf\Trigger\Subscriber\TriggerSubscriber;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Di\Annotation\AnnotationCollector;
use Psr\Container\ContainerInterface;

use function Hyperf\Collection\collect;

Expand All @@ -26,11 +25,6 @@ class SubscribersCommand extends HyperfCommand

protected string $description = 'List all subscribers.';

public function __construct(ContainerInterface $container)
{
parent::__construct();
}

public function handle()
{
$subscribers = AnnotationCollector::getClassesByAnnotation(Subscriber::class);
Expand Down
6 changes: 0 additions & 6 deletions src/Command/TriggersCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use FriendsOfHyperf\Trigger\Annotation\Trigger;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Di\Annotation\AnnotationCollector;
use Psr\Container\ContainerInterface;

use function Hyperf\Collection\collect;
use function Hyperf\Support\class_basename;
Expand All @@ -25,11 +24,6 @@ class TriggersCommand extends HyperfCommand

protected string $description = 'List all triggers.';

public function __construct(ContainerInterface $container)
{
parent::__construct();
}

public function handle()
{
$triggers = AnnotationCollector::getClassesByAnnotation(Trigger::class);
Expand Down
6 changes: 3 additions & 3 deletions src/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Consumer
private bool $stopped = false;

public function __construct(
protected subscriberManager $subscriberManager,
protected SubscriberManager $subscriberManager,
protected TriggerManager $triggerManager,
protected string $connection = 'default',
protected array $options = [],
Expand Down Expand Up @@ -186,9 +186,9 @@ protected function makeReplication(): MySQLReplicationFactory
fn (ConfigBuilder $builder) => $builder->withUser($config['user'] ?? 'root')
->withHost($config['host'] ?? '127.0.0.1')
->withPassword($config['password'] ?? 'root')
->withPort((int) $config['port'] ?? 3306)
->withPort((int) ($config['port'] ?? 3306))
->withSlaveId(random_int(100, 999))
->withHeartbeatPeriod((float) $config['heartbeat_period'] ?? 3)
->withHeartbeatPeriod((float) ($config['heartbeat_period'] ?? 3))
->withDatabasesOnly($databasesOnly)
->withTablesOnly($tablesOnly)
);
Expand Down
4 changes: 3 additions & 1 deletion src/Monitor/HealthMonitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public function __construct(protected ContainerInterface $container, protected C
if ($container->has(StdoutLoggerInterface::class)) {
$this->logger = $container->get(StdoutLoggerInterface::class);
}
$this->timer = new Timer($this->logger);
$this->timer = new Timer(
$this->logger instanceof StdoutLoggerInterface ? $this->logger : null
);
}

public function process(): void
Expand Down
6 changes: 3 additions & 3 deletions src/Mutex/RedisServerMutex.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ public function __construct(
array $options = [],
protected ?StdoutLoggerInterface $logger = null
) {
$this->expires = (int) $options['expires'] ?? 60;
$this->keepaliveInterval = (int) $options['keepalive_interval'] ?? 10;
$this->expires = (int) ($options['expires'] ?? 60);
$this->keepaliveInterval = (int) ($options['keepalive_interval'] ?? 10);
$this->name = $name ?? sprintf('trigger:server:%s', $this->connection);
$this->owner = $owner ?? Util::getInternalIp();
$this->connection = $options['connection'];
$this->timer = new Timer($logger);
$this->retryInterval = (int) $options['retry_interval'] ?? 10;
$this->retryInterval = (int) ($options['retry_interval'] ?? 10);
}

public function attempt(callable $callback = null): void
Expand Down
2 changes: 1 addition & 1 deletion src/Mutex/ServerMutexInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

interface ServerMutexInterface
{
public function attempt();
public function attempt(callable $callback = null);

public function release(bool $force = false);
}
2 changes: 1 addition & 1 deletion src/Subscriber/TriggerSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(
protected ?StdoutLoggerInterface $logger = null
) {
$this->concurrent = new Concurrent(
(int) $consumer->getOption('concurrent.limit') ?? 1
(int) ($consumer->getOption('concurrent.limit') ?? 1)
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/TriggerManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public function register(): void
}

foreach ($queue as $value) {
/** @var Trigger $property */
[$class, $property] = $value;

/** @var Trigger $property */
foreach ($property->events as $eventType) {
$config = $this->config->get('trigger.connections.' . $property->connection);
$property->table ??= class_basename($class);
Expand Down

0 comments on commit a7d2330

Please sign in to comment.