Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d74673f
chore: ignore phpstan error
albertcht Feb 14, 2026
f0216c5
feat: Add timebox
MatusBoa Mar 1, 2026
6fd177c
Add return types
MatusBoa Mar 1, 2026
9d81e5e
More return types
MatusBoa Mar 1, 2026
48d1b33
CS
MatusBoa Mar 1, 2026
282a165
fix: add missing acquire() and betweenBlockedAttemptsSleepFor() to Lo…
binaryfire Mar 1, 2026
2249877
fix: use intersection type for LockProvider in CacheEventMutex
binaryfire Mar 1, 2026
c62655a
fix: correct Filesystem interface casing in FilesystemManager return …
binaryfire Mar 1, 2026
9b6ca16
fix: add phpstan ignore rule for nested-set NodeTrait methods on Model
binaryfire Mar 1, 2026
bb485ff
fix: simplify Closure type on fallbacks property to avoid static vs t…
binaryfire Mar 1, 2026
8cdaedc
fix: use inline phpstan-ignore for setContainer on Queue contract
binaryfire Mar 1, 2026
d60253e
fix: move phpstan-ignore to correct line for setExceptionCallback
binaryfire Mar 1, 2026
f989cda
fix: use intersection type for LockProvider in StartSession
binaryfire Mar 1, 2026
3f6ff78
fix: use inline phpstan-ignore for scope method withTelescopeOptions
binaryfire Mar 1, 2026
8d5eebf
chore: allow php-http/discovery composer plugin
binaryfire Mar 1, 2026
39af5e0
Merge pull request #360 from binaryfire/fix-phpstan-2140
binaryfire Mar 1, 2026
e5a42f2
Merge branch 'main' into feat-timebox
binaryfire Mar 1, 2026
96fbabf
Merge pull request #359 from MatusBoa/feat-timebox
albertcht Mar 4, 2026
ff75c30
chore: align coding style with newest php-cs-fixer
albertcht Apr 28, 2026
57be66b
improve: improve code via phpstan
albertcht Apr 28, 2026
703949d
fix: fix FileinfoMimeTypeGuesser in coroutines
albertcht Apr 28, 2026
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 @@ -230,7 +230,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
2 changes: 1 addition & 1 deletion src/bus/src/PendingChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function catch(callable $callback): static
*/
public function catchCallbacks(): array
{
return $this->catchCallbacks ?? [];
return $this->catchCallbacks ?: [];
}

/**
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ class RouteServiceProvider extends ServiceProvider
/**
* The route files for the application.
*/
protected array $routes = [
];
protected array $routes = [];

public function boot(): void
{
Expand Down
6 changes: 2 additions & 4 deletions src/horizon/src/EventMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ trait EventMap
Listeners\MonitorWaitTimes::class,
],

Events\WorkerProcessRestarting::class => [
],
Events\WorkerProcessRestarting::class => [],

Events\SupervisorProcessRestarting::class => [
],
Events\SupervisorProcessRestarting::class => [],

Events\LongWaitDetected::class => [
Listeners\SendNotification::class,
Expand Down
2 changes: 0 additions & 2 deletions src/horizon/src/ProcessPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ public function markForTermination(WorkerProcess $process): void
protected function removeProcesses(int $count): void
{
array_splice($this->processes, 0, $count);

$this->processes = array_values($this->processes);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/http-client/src/PendingRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ public function send(string $method, string $url, array $options = []): PromiseI

$shouldRetry = null;

return retry($this->tries ?? 1, function ($attempt) use ($method, $url, $options, &$shouldRetry) {
return retry($this->tries ?: 1, function ($attempt) use ($method, $url, $options, &$shouldRetry) {
try {
return tap(
$this->newResponse($this->sendRequest($method, $url, $options)),
Expand Down Expand Up @@ -780,7 +780,8 @@ function (Response $response) use ($attempt, &$shouldRetry) {

throw $exception;
}
}, $this->retryDelay ?? 100, function ($exception) use (&$shouldRetry) {
}, $this->retryDelay ?: 100, function ($exception) use (&$shouldRetry) {
// @phpstan-ignore-next-line nullCoalesce.variable
$result = $shouldRetry ?? ($this->retryWhenCallback ? call_user_func(
$this->retryWhenCallback,
$exception,
Expand Down
2 changes: 1 addition & 1 deletion src/http-client/src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function data(): array
return $this->json();
}

return $this->data ?? [];
return $this->data ?: [];
}

/**
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
2 changes: 1 addition & 1 deletion src/queue/src/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ protected function shouldDispatchAfterCommit(object|string $job): bool
return $job->afterCommit;
}

return $this->dispatchAfterCommit ?? false;
return $this->dispatchAfterCommit;
}

/**
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
3 changes: 1 addition & 2 deletions src/sentry/config/sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@
ValidationException::class,
],

'ignore_transactions' => [
],
'ignore_transactions' => [],

'ignore_commands' => [
'crontab:run',
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\Session\Contracts\Session;
use Hypervel\Session\SessionManager;
Expand Down Expand Up @@ -78,8 +79,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 @@ -88,7 +90,7 @@ protected function handleRequestWhileBlocking(ServerRequestInterface $request, S

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

Expand Down
11 changes: 6 additions & 5 deletions src/support/src/FileinfoMimeTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Exception;
use finfo;
use Hypervel\Context\Context;
use InvalidArgumentException;
use LogicException;
use RuntimeException;
Expand All @@ -24,10 +25,7 @@
*/
class FileinfoMimeTypeGuesser
{
/**
* @var array<string, finfo>
*/
private static $finfoCache = [];
private const FINFO_CACHE_KEY = '__support.finfo_mime_type_guesser.';

/**
* @param null|string $magicFile A magic file to use with the finfo instance
Expand Down Expand Up @@ -55,7 +53,10 @@ public function guessMimeType(string $path): ?string
}

try {
$finfo = self::$finfoCache[$this->magicFile] ??= new finfo(FILEINFO_MIME_TYPE, $this->magicFile);
$finfo = Context::getOrSet(
self::FINFO_CACHE_KEY . ($this->magicFile ?? ''),
fn () => new finfo(FILEINFO_MIME_TYPE, $this->magicFile)
);
} catch (Exception $e) {
throw new RuntimeException($e->getMessage());
}
Expand Down
Loading
Loading