Skip to content

Commit 3c7e85d

Browse files
committed
Use direct API execution instead of facade calls
1 parent 7de47b3 commit 3c7e85d

39 files changed

+212
-209
lines changed

resources/stubs/saucer.stub.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Boson\Internal\Saucer;
5+
namespace Boson\Api;
66

77
use FFI\CData;
88
use FFI\CType;

src/Api/ApplicationExtension.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,36 @@
55
namespace Boson\Api;
66

77
use Boson\Application;
8+
use Boson\Contracts\Id\IdentifiableInterface;
89
use Boson\Dispatcher\EventListener;
10+
use Boson\Internal\StructPointerId;
11+
use FFI\CData;
912

1013
/**
11-
* @template-extends Extension<Application>
14+
* @template TContext of IdentifiableInterface<StructPointerId> = Application
15+
*
16+
* @template-extends Extension<TContext>
1217
*/
1318
abstract class ApplicationExtension extends Extension
1419
{
15-
public function __construct(Application $context, EventListener $listener)
16-
{
17-
parent::__construct($context, $listener);
20+
/**
21+
* Gets reference to the context's ID
22+
*/
23+
protected StructPointerId $id {
24+
get => $this->app->id;
25+
}
26+
27+
/**
28+
* Gets reference to the context's pointer
29+
*/
30+
protected CData $ptr {
31+
get => $this->id->ptr;
32+
}
33+
34+
public function __construct(
35+
protected readonly Application $app,
36+
EventListener $listener,
37+
) {
38+
parent::__construct($listener);
1839
}
1940
}

src/Api/CentralProcessor/AdvancedCpuInfoProviderInterface.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/Api/CentralProcessor/ApplicationCentralProcessor.php renamed to src/Api/CentralProcessor/CentralProcessorApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @internal this is an internal library class, please do not use it in your code
1515
* @psalm-internal Boson
1616
*/
17-
final class ApplicationCentralProcessor extends ApplicationExtension implements
17+
final class CentralProcessorApi extends ApplicationExtension implements
1818
CentralProcessorApiInterface
1919
{
2020
private CentralProcessorInterface $cpu {

src/Api/CentralProcessor/GenericCpuInfoProviderInterface.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/Api/CentralProcessor/VendorCpuInfoProviderInterface.php

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Api/CentralProcessorApiInterface.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44

55
namespace Boson\Api;
66

7-
use Boson\Api\CentralProcessor\AdvancedCpuInfoProviderInterface;
8-
use Boson\Api\CentralProcessor\GenericCpuInfoProviderInterface;
9-
use Boson\Api\CentralProcessor\VendorCpuInfoProviderInterface;
7+
use Boson\Component\CpuInfo\CentralProcessorInterface;
108

119
/**
1210
* Provides information about the main CPU.
1311
*/
1412
interface CentralProcessorApiInterface extends
15-
GenericCpuInfoProviderInterface,
16-
VendorCpuInfoProviderInterface,
17-
AdvancedCpuInfoProviderInterface {}
13+
CentralProcessorInterface {}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
use Boson\Api\ApplicationExtension;
88
use Boson\Api\DialogApiInterface;
9+
use Boson\Api\SaucerInterface;
910
use Boson\Application;
1011
use Boson\Dispatcher\EventListener;
11-
use Boson\Internal\Saucer\SaucerInterface;
1212
use FFI\CData;
1313

1414
/**
1515
* @internal this is an internal library class, please do not use it in your code
1616
* @psalm-internal Boson
1717
*/
18-
final class ApplicationDialog extends ApplicationExtension implements DialogApiInterface
18+
final class DialogApi extends ApplicationExtension implements DialogApiInterface
1919
{
2020
protected CData $ptr {
2121
/** @phpstan-ignore-next-line : PHPStan does not support property inheritance */

src/Api/Extension.php

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,14 @@
1010
use Boson\Dispatcher\EventListener;
1111
use Boson\Dispatcher\Intention;
1212
use Boson\Internal\StructPointerId;
13-
use FFI\CData;
1413

1514
/**
16-
* @template T of IdentifiableInterface<StructPointerId>
15+
* @template TContext of IdentifiableInterface<StructPointerId>
1716
*/
1817
abstract class Extension
1918
{
20-
protected StructPointerId $id {
21-
/** @phpstan-ignore-next-line : Context is a "IdentifiableInterface<StructPointerId>" */
22-
get => $this->context->id;
23-
}
24-
25-
protected CData $ptr {
26-
get => $this->id->ptr;
27-
}
28-
2919
public function __construct(
30-
/**
31-
* @var T
32-
*/
33-
protected readonly IdentifiableInterface $context,
34-
private readonly EventListener $listener,
20+
protected readonly EventListener $listener,
3521
) {}
3622

3723
/**
@@ -48,7 +34,10 @@ protected function listen(string $event, callable $then): CancellableSubscriptio
4834
}
4935

5036
/**
51-
* @param Intention<T> $intention
37+
* Dispatch intention instance and returns {@see false} in
38+
* case of intention has been cancelled.
39+
*
40+
* @param Intention<TContext> $intention
5241
*/
5342
protected function intent(object $intention): bool
5443
{
@@ -58,7 +47,9 @@ protected function intent(object $intention): bool
5847
}
5948

6049
/**
61-
* @param Event<T> $event
50+
* Dispatch immutable event.
51+
*
52+
* @param Event<TContext> $event
6253
*/
6354
protected function dispatch(object $event): void
6455
{

src/Api/OperatingSystem/ApplicationOperatingSystem.php renamed to src/Api/OperatingSystem/OperatingSystemApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* @internal this is an internal library class, please do not use it in your code
1616
* @psalm-internal Boson
1717
*/
18-
final class ApplicationOperatingSystem extends ApplicationExtension implements
18+
final class OperatingSystemApi extends ApplicationExtension implements
1919
OperatingSystemApiInterface
2020
{
2121
private OperatingSystemInterface $os {

0 commit comments

Comments
 (0)