Skip to content

Commit 9817b82

Browse files
authored
Merge branch 'main' into feat-timebox
2 parents c6472e1 + a6352aa commit 9817b82

10 files changed

Lines changed: 51 additions & 29 deletions

File tree

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,10 @@
232232
"audit": {
233233
"ignore": ["PKSA-z3gr-8qht-p93v"]
234234
},
235-
"sort-packages": true
235+
"sort-packages": true,
236+
"allow-plugins": {
237+
"php-http/discovery": true
238+
}
236239
},
237240
"extra": {
238241
"hyperf": {

phpstan.neon.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ parameters:
3939
- '#Method Redis::eval\(\) invoked with [0-9] parameters, 1-3 required.#'
4040
- '#Access to an undefined property Hypervel\\Queue\\Jobs\\DatabaseJobRecord::\$.*#'
4141
- '#Access to an undefined property Hypervel\\Queue\\Contracts\\Job::\$.*#'
42+
# NodeTrait methods - mixed in at app level, not on base Model class
43+
- message: '#Call to an undefined method Hyperf\\Database\\Model\\Model::new(ScopedQuery|NestedSetQuery)\(\)#'
44+
path: src/nested-set/*
4245
- '#Call to an undefined method Hyperf\\Database\\Query\\Builder::where[a-zA-Z0-9\\\\_]+#'
4346
- '#Call to an undefined method Hyperf\\Database\\Query\\Builder::firstOrFail\(\)#'
4447
- '#Access to an undefined property Hyperf\\Collection\\HigherOrderCollectionProxy#'

src/cache/src/Contracts/Lock.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
interface Lock
88
{
9+
/**
10+
* Attempt to acquire the lock.
11+
*/
12+
public function acquire(): bool;
13+
914
/**
1015
* Attempt to acquire the lock.
1116
*/
@@ -16,6 +21,11 @@ public function get(?callable $callback = null): mixed;
1621
*/
1722
public function block(int $seconds, ?callable $callback = null): mixed;
1823

24+
/**
25+
* Specify the number of milliseconds to sleep in between blocked lock acquisition attempts.
26+
*/
27+
public function betweenBlockedAttemptsSleepFor(int $milliseconds): static;
28+
1929
/**
2030
* Release the lock.
2131
*/

src/console/src/Scheduling/CacheEventMutex.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ public function __construct(
3232
*/
3333
public function create(Event $event): bool
3434
{
35-
if ($this->shouldUseLocks($this->cache->store($this->store)->getStore())) {
36-
/* @phpstan-ignore-next-line */
37-
return $this->cache->store($this->store)->getStore()
35+
$store = $this->cache->store($this->store)->getStore();
36+
37+
if ($this->shouldUseLocks($store)) {
38+
/** @var LockProvider&Store $store */ // @phpstan-ignore varTag.nativeType
39+
return $store
3840
->lock($event->mutexName(), $event->expiresAt * 60)
3941
->acquire();
4042
}
@@ -51,9 +53,11 @@ public function create(Event $event): bool
5153
*/
5254
public function exists(Event $event): bool
5355
{
54-
if ($this->shouldUseLocks($this->cache->store($this->store)->getStore())) {
55-
/* @phpstan-ignore-next-line */
56-
return ! $this->cache->store($this->store)->getStore()
56+
$store = $this->cache->store($this->store)->getStore();
57+
58+
if ($this->shouldUseLocks($store)) {
59+
/** @var LockProvider&Store $store */ // @phpstan-ignore varTag.nativeType
60+
return ! $store
5761
->lock($event->mutexName(), $event->expiresAt * 60)
5862
->get(fn () => true);
5963
}
@@ -66,9 +70,11 @@ public function exists(Event $event): bool
6670
*/
6771
public function forget(Event $event): void
6872
{
69-
if ($this->shouldUseLocks($this->cache->store($this->store)->getStore())) {
70-
/* @phpstan-ignore-next-line */
71-
$this->cache->store($this->store)->getStore()
73+
$store = $this->cache->store($this->store)->getStore();
74+
75+
if ($this->shouldUseLocks($store)) {
76+
/** @var LockProvider&Store $store */ // @phpstan-ignore varTag.nativeType
77+
$store
7278
->lock($event->mutexName(), $event->expiresAt * 60)
7379
->forceRelease();
7480

src/filesystem/src/FilesystemManager.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function drive(?string $name = null): Filesystem
7979
/**
8080
* Get a filesystem instance.
8181
*/
82-
public function disk(?string $name = null): FileSystem
82+
public function disk(?string $name = null): Filesystem
8383
{
8484
$name = $name ?: $this->getDefaultDriver();
8585

@@ -100,7 +100,7 @@ public function cloud(): Cloud
100100
/**
101101
* Build an on-demand disk.
102102
*/
103-
public function build(array|string $config): FileSystem
103+
public function build(array|string $config): Filesystem
104104
{
105105
return $this->resolve('ondemand', is_array($config) ? $config : [
106106
'driver' => 'local',
@@ -111,7 +111,7 @@ public function build(array|string $config): FileSystem
111111
/**
112112
* Attempt to get the disk from the local cache.
113113
*/
114-
protected function get(string $name): FileSystem
114+
protected function get(string $name): Filesystem
115115
{
116116
return $this->disks[$name] ?? $this->resolve($name);
117117
}
@@ -121,7 +121,7 @@ protected function get(string $name): FileSystem
121121
*
122122
* @throws InvalidArgumentException
123123
*/
124-
protected function resolve(string $name, ?array $config = null): FileSystem
124+
protected function resolve(string $name, ?array $config = null): Filesystem
125125
{
126126
$config ??= $this->getConfig($name);
127127

@@ -163,15 +163,15 @@ protected function resolve(string $name, ?array $config = null): FileSystem
163163
/**
164164
* Call a custom driver creator.
165165
*/
166-
protected function callCustomCreator(array $config): FileSystem
166+
protected function callCustomCreator(array $config): Filesystem
167167
{
168168
return $this->customCreators[$config['driver']]($this->app, $config);
169169
}
170170

171171
/**
172172
* Create an instance of the local driver.
173173
*/
174-
public function createLocalDriver(array $config, string $name = 'local'): FileSystem
174+
public function createLocalDriver(array $config, string $name = 'local'): Filesystem
175175
{
176176
$visibility = PortableVisibilityConverter::fromArray(
177177
$config['permissions'] ?? [],
@@ -204,7 +204,7 @@ public function createLocalDriver(array $config, string $name = 'local'): FileSy
204204
/**
205205
* Create an instance of the ftp driver.
206206
*/
207-
public function createFtpDriver(array $config): FileSystem
207+
public function createFtpDriver(array $config): Filesystem
208208
{
209209
if (! isset($config['root'])) {
210210
$config['root'] = '';
@@ -219,7 +219,7 @@ public function createFtpDriver(array $config): FileSystem
219219
/**
220220
* Create an instance of the sftp driver.
221221
*/
222-
public function createSftpDriver(array $config): FileSystem
222+
public function createSftpDriver(array $config): Filesystem
223223
{
224224
/* @phpstan-ignore-next-line */
225225
$provider = SftpConnectionProvider::fromArray($config);
@@ -353,7 +353,7 @@ protected function createGcsClient(array $config): GcsClient
353353
/**
354354
* Create a scoped driver.
355355
*/
356-
public function createScopedDriver(array $config): FileSystem
356+
public function createScopedDriver(array $config): Filesystem
357357
{
358358
if (empty($config['disk'])) {
359359
throw new InvalidArgumentException('Scoped disk is missing "disk" configuration option.');

src/prompts/src/Concerns/Fallback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ trait Fallback
1717
/**
1818
* The fallback implementations.
1919
*
20-
* @var array<class-string, Closure($this): mixed>
20+
* @var array<class-string, Closure>
2121
*/
2222
protected static array $fallbacks = [];
2323

src/queue/src/QueueManager.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,10 @@ protected function resolve(string $name): Queue
161161
throw new InvalidArgumentException("The [{$name}] queue connection has not been configured.");
162162
}
163163

164-
/** @phpstan-ignore-next-line */
165164
$resolver = fn () => $this->getConnector($config['driver'])
166165
->connect($config)
167166
->setConnectionName($name)
168-
->setContainer($this->app)
167+
->setContainer($this->app) // @phpstan-ignore method.notFound
169168
->setConfig($config);
170169

171170
if (in_array($config['driver'], $this->poolables)) {

src/queue/src/QueueManagerFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public function __invoke(ContainerInterface $container): QueueManager
2222
$reportHandler = fn (Throwable $e) => $container->get(ExceptionHandler::class)->report($e);
2323
foreach ($connectors as $connector) {
2424
try {
25-
$manager->connection($connector) // @phpstan-ignore-line
26-
->setExceptionCallback($reportHandler);
25+
$manager->connection($connector)
26+
->setExceptionCallback($reportHandler); // @phpstan-ignore method.notFound
2727
} catch (InvalidArgumentException) {
2828
// Ignore exception when the connector is not configured.
2929
}

src/session/src/Middleware/StartSession.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Hyperf\HttpServer\Request;
1212
use Hyperf\HttpServer\Router\Dispatched;
1313
use Hypervel\Cache\Contracts\Factory as CacheFactoryContract;
14+
use Hypervel\Cache\Contracts\LockProvider;
1415
use Hypervel\Cookie\Cookie;
1516
use Hypervel\Foundation\Exceptions\Contracts\ExceptionHandler as ExceptionHandlerContract;
1617
use Hypervel\Session\Contracts\Session;
@@ -82,8 +83,9 @@ protected function handleRequestWhileBlocking(ServerRequestInterface $request, S
8283
$waitFor = ($blockingOptions['wait']
8384
?? $this->manager->defaultRouteBlockWaitSeconds());
8485

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

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

9395
return $this->handleStatefulRequest($request, $session, $handler);
9496
} finally {
95-
$lock?->release();
97+
$lock->release();
9698
}
9799
}
98100

src/telescope/src/Storage/DatabaseEntriesRepository.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ public function find(mixed $id): EntryResult
7272
*/
7373
public function get(?string $type, EntryQueryOptions $options): Collection
7474
{
75-
/* @phpstan-ignore-next-line */
7675
return EntryModel::on($this->connection)
77-
->withTelescopeOptions($type, $options)
76+
->withTelescopeOptions($type, $options) // @phpstan-ignore method.notFound
7877
->take($options->limit)
7978
->orderByDesc('sequence')
8079
->get()->reject(function ($entry) {

0 commit comments

Comments
 (0)