Skip to content

Commit 7ae16dd

Browse files
committed
Merge branch 'main' of github.com:hypervel/components
2 parents e9e6f2f + 3689cc9 commit 7ae16dd

27 files changed

Lines changed: 814 additions & 50 deletions

File tree

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
"symfony/error-handler": "^6.3",
139139
"symfony/mailer": "^6.2",
140140
"symfony/process": "^6.2",
141+
"symfony/uid": "^7.4",
141142
"tijsverkoyen/css-to-inline-styles": "^2.2.5"
142143
},
143144
"replace": {
@@ -204,6 +205,7 @@
204205
"hyperf/redis": "~3.1.0",
205206
"hyperf/testing": "~3.1.0",
206207
"hyperf/view-engine": "~3.1.0",
208+
"hypervel/facade-documenter": "dev-main",
207209
"league/flysystem": "^3.0",
208210
"league/flysystem-aws-s3-v3": "^3.0",
209211
"league/flysystem-google-cloud-storage": "^3.0",

src/broadcasting/src/BroadcastManager.php

Lines changed: 1 addition & 1 deletion
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
{

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/core/src/Database/Eloquent/Concerns/HasAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function getCasts(): array
6464
return static::$castsCache[static::class] = array_merge([$this->getKeyName() => $this->getKeyType()], $this->casts, $this->casts());
6565
}
6666

67-
return static::$castsCache[static::class] = $this->casts;
67+
return static::$castsCache[static::class] = array_merge($this->casts, $this->casts());
6868
}
6969

7070
/**

src/core/src/Database/Eloquent/Concerns/HasUlids.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,27 @@
66

77
use Hyperf\Stringable\Str;
88

9+
/**
10+
* Provides ULID primary key support for Eloquent models.
11+
*/
912
trait HasUlids
1013
{
1114
/**
12-
* Add a unique identifier to the model before it is created.
15+
* Boot the trait.
1316
*/
14-
public function creating(): void
17+
public static function bootHasUlids(): void
1518
{
16-
foreach ($this->uniqueIds() as $column) {
17-
if (empty($model->{$column})) {
18-
$this->{$column} = $this->newUniqueId();
19+
static::registerCallback('creating', function (self $model): void {
20+
foreach ($model->uniqueIds() as $column) {
21+
if (empty($model->{$column})) {
22+
$model->{$column} = $model->newUniqueId();
23+
}
1924
}
20-
}
25+
});
2126
}
2227

2328
/**
24-
* Generate a new UUID for the model.
29+
* Generate a new ULID for the model.
2530
*/
2631
public function newUniqueId(): string
2732
{

src/core/src/Database/Eloquent/Concerns/HasUuids.php

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

77
use Hyperf\Stringable\Str;
88

9+
/**
10+
* Provides UUID primary key support for Eloquent models.
11+
*/
912
trait HasUuids
1013
{
1114
/**
12-
* Add a unique identifier to the model before it is created.
15+
* Boot the trait.
1316
*/
14-
public function creating(): void
17+
public static function bootHasUuids(): void
1518
{
16-
foreach ($this->uniqueIds() as $column) {
17-
if (empty($model->{$column})) {
18-
$this->{$column} = $this->newUniqueId();
19+
static::registerCallback('creating', function (self $model): void {
20+
foreach ($model->uniqueIds() as $column) {
21+
if (empty($model->{$column})) {
22+
$model->{$column} = $model->newUniqueId();
23+
}
1924
}
20-
}
25+
});
2126
}
2227

2328
/**

src/filesystem/src/FilesystemManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ function (&$parent) use ($config) {
379379
*/
380380
protected function createFlysystem(FlysystemAdapter $adapter, array $config): FilesystemOperator
381381
{
382-
if ($config['read-only'] ?? false === true) {
382+
if (($config['read-only'] ?? false) === true) {
383383
/* @phpstan-ignore-next-line */
384384
$adapter = new ReadOnlyFilesystemAdapter($adapter);
385385
}

src/foundation/src/Testing/Concerns/InteractsWithSession.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,17 @@ public function session(array $data): static
3737
*/
3838
protected function startSession(): static
3939
{
40-
if (! $this->app->get(Session::class)->isStarted()) {
41-
$this->app->get(Session::class)->start();
40+
$session = $this->app->get(Session::class);
41+
42+
if (! $session->isStarted()) {
43+
// Ensure a session ID exists before starting. In production, the
44+
// StartSession middleware sets the ID from the request cookie.
45+
// In tests, we generate one if none exists.
46+
if ($session->getId() === null) {
47+
$session->setId(null);
48+
}
49+
50+
$session->start();
4251
}
4352

4453
return $this;

src/foundation/src/Testing/Constraints/NotSoftDeletedInDatabase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class NotSoftDeletedInDatabase extends Constraint
1919
*/
2020
public function __construct(
2121
protected Connection $database,
22-
array $data,
23-
string $deletedAtColumn
22+
protected array $data,
23+
protected string $deletedAtColumn
2424
) {
2525
}
2626

src/foundation/src/Testing/Constraints/SoftDeletedInDatabase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class SoftDeletedInDatabase extends Constraint
1919
*/
2020
public function __construct(
2121
protected Connection $database,
22-
array $data,
23-
string $deletedAtColumn
22+
protected array $data,
23+
protected string $deletedAtColumn
2424
) {
2525
}
2626

0 commit comments

Comments
 (0)