Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@
"audit": {
"ignore": ["PKSA-z3gr-8qht-p93v"]
},
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"php-http/discovery": true
}
},
"extra": {
"hyperf": {
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ parameters:
- '#Method Redis::eval\(\) invoked with [0-9] parameters, 1-3 required.#'
- '#Access to an undefined property Hypervel\\Queue\\Jobs\\DatabaseJobRecord::\$.*#'
- '#Access to an undefined property Hypervel\\Queue\\Contracts\\Job::\$.*#'
# NodeTrait methods - mixed in at app level, not on base Model class
- message: '#Call to an undefined method Hyperf\\Database\\Model\\Model::new(ScopedQuery|NestedSetQuery)\(\)#'
path: src/nested-set/*
- '#Call to an undefined method Hyperf\\Database\\Query\\Builder::where[a-zA-Z0-9\\\\_]+#'
- '#Call to an undefined method Hyperf\\Database\\Query\\Builder::firstOrFail\(\)#'
- '#Access to an undefined property Hyperf\\Collection\\HigherOrderCollectionProxy#'
Expand Down
10 changes: 10 additions & 0 deletions src/cache/src/Contracts/Lock.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

interface Lock
{
/**
* Attempt to acquire the lock.
*/
public function acquire(): bool;

/**
* Attempt to acquire the lock.
*/
Expand All @@ -16,6 +21,11 @@ public function get(?callable $callback = null): mixed;
*/
public function block(int $seconds, ?callable $callback = null): mixed;

/**
* Specify the number of milliseconds to sleep in between blocked lock acquisition attempts.
*/
public function betweenBlockedAttemptsSleepFor(int $milliseconds): static;

/**
* Release the lock.
*/
Expand Down
24 changes: 15 additions & 9 deletions src/console/src/Scheduling/CacheEventMutex.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public function __construct(
*/
public function create(Event $event): bool
{
if ($this->shouldUseLocks($this->cache->store($this->store)->getStore())) {
/* @phpstan-ignore-next-line */
return $this->cache->store($this->store)->getStore()
$store = $this->cache->store($this->store)->getStore();

if ($this->shouldUseLocks($store)) {
/** @var LockProvider&Store $store */ // @phpstan-ignore varTag.nativeType
return $store
->lock($event->mutexName(), $event->expiresAt * 60)
->acquire();
}
Expand All @@ -51,9 +53,11 @@ public function create(Event $event): bool
*/
public function exists(Event $event): bool
{
if ($this->shouldUseLocks($this->cache->store($this->store)->getStore())) {
/* @phpstan-ignore-next-line */
return ! $this->cache->store($this->store)->getStore()
$store = $this->cache->store($this->store)->getStore();

if ($this->shouldUseLocks($store)) {
/** @var LockProvider&Store $store */ // @phpstan-ignore varTag.nativeType
return ! $store
->lock($event->mutexName(), $event->expiresAt * 60)
->get(fn () => true);
}
Expand All @@ -66,9 +70,11 @@ public function exists(Event $event): bool
*/
public function forget(Event $event): void
{
if ($this->shouldUseLocks($this->cache->store($this->store)->getStore())) {
/* @phpstan-ignore-next-line */
$this->cache->store($this->store)->getStore()
$store = $this->cache->store($this->store)->getStore();

if ($this->shouldUseLocks($store)) {
/** @var LockProvider&Store $store */ // @phpstan-ignore varTag.nativeType
$store
->lock($event->mutexName(), $event->expiresAt * 60)
->forceRelease();

Expand Down
18 changes: 9 additions & 9 deletions src/filesystem/src/FilesystemManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function drive(?string $name = null): Filesystem
/**
* Get a filesystem instance.
*/
public function disk(?string $name = null): FileSystem
public function disk(?string $name = null): Filesystem
{
$name = $name ?: $this->getDefaultDriver();

Expand All @@ -100,7 +100,7 @@ public function cloud(): Cloud
/**
* Build an on-demand disk.
*/
public function build(array|string $config): FileSystem
public function build(array|string $config): Filesystem
{
return $this->resolve('ondemand', is_array($config) ? $config : [
'driver' => 'local',
Expand All @@ -111,7 +111,7 @@ public function build(array|string $config): FileSystem
/**
* Attempt to get the disk from the local cache.
*/
protected function get(string $name): FileSystem
protected function get(string $name): Filesystem
{
return $this->disks[$name] ?? $this->resolve($name);
}
Expand All @@ -121,7 +121,7 @@ protected function get(string $name): FileSystem
*
* @throws InvalidArgumentException
*/
protected function resolve(string $name, ?array $config = null): FileSystem
protected function resolve(string $name, ?array $config = null): Filesystem
{
$config ??= $this->getConfig($name);

Expand Down Expand Up @@ -163,15 +163,15 @@ protected function resolve(string $name, ?array $config = null): FileSystem
/**
* Call a custom driver creator.
*/
protected function callCustomCreator(array $config): FileSystem
protected function callCustomCreator(array $config): Filesystem
{
return $this->customCreators[$config['driver']]($this->app, $config);
}

/**
* Create an instance of the local driver.
*/
public function createLocalDriver(array $config, string $name = 'local'): FileSystem
public function createLocalDriver(array $config, string $name = 'local'): Filesystem
{
$visibility = PortableVisibilityConverter::fromArray(
$config['permissions'] ?? [],
Expand Down Expand Up @@ -204,7 +204,7 @@ public function createLocalDriver(array $config, string $name = 'local'): FileSy
/**
* Create an instance of the ftp driver.
*/
public function createFtpDriver(array $config): FileSystem
public function createFtpDriver(array $config): Filesystem
{
if (! isset($config['root'])) {
$config['root'] = '';
Expand All @@ -219,7 +219,7 @@ public function createFtpDriver(array $config): FileSystem
/**
* Create an instance of the sftp driver.
*/
public function createSftpDriver(array $config): FileSystem
public function createSftpDriver(array $config): Filesystem
{
/* @phpstan-ignore-next-line */
$provider = SftpConnectionProvider::fromArray($config);
Expand Down Expand Up @@ -353,7 +353,7 @@ protected function createGcsClient(array $config): GcsClient
/**
* Create a scoped driver.
*/
public function createScopedDriver(array $config): FileSystem
public function createScopedDriver(array $config): Filesystem
{
if (empty($config['disk'])) {
throw new InvalidArgumentException('Scoped disk is missing "disk" configuration option.');
Expand Down
2 changes: 1 addition & 1 deletion src/prompts/src/Concerns/Fallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait Fallback
/**
* The fallback implementations.
*
* @var array<class-string, Closure($this): mixed>
* @var array<class-string, Closure>
*/
protected static array $fallbacks = [];

Expand Down
3 changes: 1 addition & 2 deletions src/queue/src/QueueManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,10 @@ protected function resolve(string $name): Queue
throw new InvalidArgumentException("The [{$name}] queue connection has not been configured.");
}

/** @phpstan-ignore-next-line */
$resolver = fn () => $this->getConnector($config['driver'])
->connect($config)
->setConnectionName($name)
->setContainer($this->app)
->setContainer($this->app) // @phpstan-ignore method.notFound
->setConfig($config);

if (in_array($config['driver'], $this->poolables)) {
Expand Down
4 changes: 2 additions & 2 deletions src/queue/src/QueueManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public function __invoke(ContainerInterface $container): QueueManager
$reportHandler = fn (Throwable $e) => $container->get(ExceptionHandler::class)->report($e);
foreach ($connectors as $connector) {
try {
$manager->connection($connector) // @phpstan-ignore-line
->setExceptionCallback($reportHandler);
$manager->connection($connector)
->setExceptionCallback($reportHandler); // @phpstan-ignore method.notFound
} catch (InvalidArgumentException) {
// Ignore exception when the connector is not configured.
}
Expand Down
8 changes: 5 additions & 3 deletions src/session/src/Middleware/StartSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Hyperf\HttpServer\Request;
use Hyperf\HttpServer\Router\Dispatched;
use Hypervel\Cache\Contracts\Factory as CacheFactoryContract;
use Hypervel\Cache\Contracts\LockProvider;
use Hypervel\Cookie\Cookie;
use Hypervel\Foundation\Exceptions\Contracts\ExceptionHandler as ExceptionHandlerContract;
use Hypervel\Session\Contracts\Session;
Expand Down Expand Up @@ -82,8 +83,9 @@ protected function handleRequestWhileBlocking(ServerRequestInterface $request, S
$waitFor = ($blockingOptions['wait']
?? $this->manager->defaultRouteBlockWaitSeconds());

/* @phpstan-ignore-next-line */
$lock = $this->cache->store($this->manager->blockDriver())
/** @var \Hypervel\Cache\Contracts\Repository&LockProvider $store */ // @phpstan-ignore varTag.nativeType
$store = $this->cache->store($this->manager->blockDriver());
$lock = $store
->lock('session:' . $session->getId(), (int) $lockFor)
->betweenBlockedAttemptsSleepFor(50);

Expand All @@ -92,7 +94,7 @@ protected function handleRequestWhileBlocking(ServerRequestInterface $request, S

return $this->handleStatefulRequest($request, $session, $handler);
} finally {
$lock?->release();
$lock->release();
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/telescope/src/Storage/DatabaseEntriesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,8 @@ public function find(mixed $id): EntryResult
*/
public function get(?string $type, EntryQueryOptions $options): Collection
{
/* @phpstan-ignore-next-line */
return EntryModel::on($this->connection)
->withTelescopeOptions($type, $options)
->withTelescopeOptions($type, $options) // @phpstan-ignore method.notFound
->take($options->limit)
->orderByDesc('sequence')
->get()->reject(function ($entry) {
Expand Down