Skip to content

Commit bf86857

Browse files
committed
Merge origin/main into feature/scope-attributes
Resolves conflicts in Pivot and MorphPivot by combining: - HasGlobalScopes trait from this PR - HasAttributes, HasCallbacks, HasObservers traits from main - delete() method with StoppableEventInterface pattern from main Fixes test class name collision in HasObserversTest.
2 parents 3fecf03 + e99b3e1 commit bf86857

File tree

169 files changed

+2493
-383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+2493
-383
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ composer.lock
66
.phpunit.result.cache
77
!tests/Foundation/fixtures/hyperf1/composer.lock
88
tests/Http/fixtures
9+
.env

phpstan.neon.dist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
parameters:
6-
level: 3
6+
level: 5
77
parallel:
88
jobSize: 20
99
maximumNumberOfProcesses: 32
@@ -26,6 +26,8 @@ parameters:
2626
- %currentWorkingDirectory%/src/support/src/Js.php
2727
- %currentWorkingDirectory%/src/notifications/src/DatabaseNotification.php
2828
ignoreErrors:
29+
# Framework traits provided for userland - not used internally but intentionally available
30+
- '#Trait Hypervel\\[A-Za-z\\\\]+ is used zero times and is not analysed\.#'
2931
- '#Result of method .* \(void\) is used\.#'
3032
- '#Unsafe usage of new static#'
3133
- '#Class [a-zA-Z0-9\\\\_]+ not found.#'

src/api-client/src/PendingRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function withResource(string $resource): static
155155
);
156156
}
157157

158-
if (! is_subclass_of($resource, ApiResource::class)) {
158+
if (! is_subclass_of($resource, ApiResource::class)) { // @phpstan-ignore function.alreadyNarrowedType (validates PHPDoc contract at runtime)
159159
throw new InvalidArgumentException(
160160
sprintf('Resource class `%s` must be a subclass of `%s`', $resource, ApiResource::class)
161161
);

src/auth/src/Access/Gate.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,9 @@ protected function methodAllowsGuests(mixed $class, string $method): bool
367367
return false;
368368
}
369369

370-
if ($method) {
371-
$parameters = $method->getParameters();
370+
$parameters = $method->getParameters();
372371

373-
return isset($parameters[0]) && $this->parameterAllowsGuests($parameters[0]);
374-
}
375-
376-
return false;
372+
return isset($parameters[0]) && $this->parameterAllowsGuests($parameters[0]);
377373
}
378374

379375
/**
@@ -496,10 +492,6 @@ public function getPolicyFor(object|string $class)
496492
$class = get_class($class);
497493
}
498494

499-
if (! is_string($class)) {
500-
return;
501-
}
502-
503495
if (isset($this->policies[$class])) {
504496
return $this->resolvePolicy($this->policies[$class]);
505497
}

src/auth/src/AuthenticationException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class AuthenticationException extends Exception
2222
/**
2323
* The callback that should be used to generate the authentication redirect path.
2424
*
25-
* @var callable
25+
* @var null|callable
2626
*/
2727
protected static $redirectToCallback;
2828

src/auth/src/Middleware/Authorize.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,8 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
5050
/**
5151
* Get the arguments parameter for the gate.
5252
*/
53-
protected function getGateArguments(ServerRequestInterface $request, array $models): array|Model|string
53+
protected function getGateArguments(ServerRequestInterface $request, array $models): array
5454
{
55-
if (is_null($models)) {
56-
return [];
57-
}
58-
5955
return Collection::make($models)->map(function ($model) use ($request) {
6056
return $model instanceof Model ? $model : $this->getModel($request, $model);
6157
})->all();

src/broadcasting/src/BroadcastManager.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
use Pusher\Pusher;
3535

3636
/**
37-
* @mixin \Hypervel\Broadcasting\Contracts\Broadcaster
37+
* @mixin \Hypervel\Broadcasting\Broadcasters\Broadcaster
3838
*/
3939
class BroadcastManager implements BroadcastingFactoryContract
4040
{
@@ -207,11 +207,7 @@ public function queue(mixed $event): void
207207
*/
208208
protected function mustBeUniqueAndCannotAcquireLock(UniqueBroadcastEvent $event): bool
209209
{
210-
return ! (new UniqueLock(
211-
method_exists($event, 'uniqueVia')
212-
? $event->uniqueVia()
213-
: $this->app->get(Cache::class)
214-
))->acquire($event);
210+
return ! (new UniqueLock($event->uniqueVia()))->acquire($event);
215211
}
216212

217213
/**
@@ -387,7 +383,7 @@ protected function createNullDriver(array $config): Broadcaster
387383
*/
388384
protected function getConfig(string $name): ?array
389385
{
390-
if (! is_null($name) && $name !== 'null') {
386+
if ($name !== 'null') {
391387
return $this->app->get(ConfigInterface::class)->get("broadcasting.connections.{$name}");
392388
}
393389

src/broadcasting/src/BroadcastPoolProxy.php

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

77
use Hyperf\HttpServer\Contract\RequestInterface;
88
use Hypervel\Broadcasting\Contracts\Broadcaster;
9+
use Hypervel\Broadcasting\Contracts\HasBroadcastChannel;
910
use Hypervel\ObjectPool\PoolProxy;
1011

1112
class BroadcastPoolProxy extends PoolProxy implements Broadcaster
1213
{
14+
/**
15+
* Register a channel authenticator.
16+
*/
17+
public function channel(HasBroadcastChannel|string $channel, callable|string $callback, array $options = []): static
18+
{
19+
$this->__call(__FUNCTION__, func_get_args());
20+
21+
return $this;
22+
}
23+
1324
public function auth(RequestInterface $request): mixed
1425
{
1526
return $this->__call(__FUNCTION__, func_get_args());

src/broadcasting/src/Broadcasters/Broadcaster.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function channel(HasBroadcastChannel|string $channel, callable|string $ca
7373
{
7474
if ($channel instanceof HasBroadcastChannel) {
7575
$channel = $channel->broadcastChannelRoute();
76-
} elseif (is_string($channel) && class_exists($channel) && is_a($channel, HasBroadcastChannel::class, true)) {
76+
} elseif (class_exists($channel) && is_a($channel, HasBroadcastChannel::class, true)) {
7777
$channel = (new $channel())->broadcastChannelRoute();
7878
}
7979

@@ -134,11 +134,11 @@ protected function extractAuthParameters(string $pattern, string $channel, calla
134134
*/
135135
protected function extractParameters(callable|string $callback): array
136136
{
137-
return match (true) {
138-
is_callable($callback) => (new ReflectionFunction($callback))->getParameters(),
139-
is_string($callback) => $this->extractParametersFromClass($callback),
140-
default => [],
141-
};
137+
if (is_callable($callback)) {
138+
return (new ReflectionFunction($callback))->getParameters();
139+
}
140+
141+
return $this->extractParametersFromClass($callback);
142142
}
143143

144144
/**

src/broadcasting/src/Broadcasters/PusherBroadcaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function resolveAuthenticatedUser(RequestInterface $request): ?array
3838
return null;
3939
}
4040

41-
if (method_exists($this->pusher, 'authenticateUser')) {
41+
if (method_exists($this->pusher, 'authenticateUser')) { // @phpstan-ignore function.alreadyNarrowedType (Pusher 6.x compatibility)
4242
return json_decode(
4343
$this->pusher->authenticateUser($request->input('socket_id'), $user),
4444
true,

0 commit comments

Comments
 (0)