Skip to content

Commit 1ef8aa7

Browse files
committed
refactor: 🎨 Use assert() for endpoint type narrowing in hook wiring
1 parent e93d6fb commit 1ef8aa7

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

‎modules/ppcp-order-endpoints/src/OrderEndpointsModule.php‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,8 @@ public function run( ContainerInterface $c ): bool {
4242
'wc_ajax_' . ChangeCartEndpoint::ENDPOINT,
4343
static function () use ( $c ) {
4444
$endpoint = $c->get( 'order-endpoints.endpoint.change-cart' );
45-
/**
46-
* The Change Cart Endpoint.
47-
*
48-
* @var ChangeCartEndpoint $endpoint
49-
*/
45+
assert( $endpoint instanceof ChangeCartEndpoint );
46+
5047
$endpoint->handle_request();
5148
}
5249
);
@@ -55,11 +52,8 @@ static function () use ( $c ) {
5552
'wc_ajax_' . ApproveOrderEndpoint::ENDPOINT,
5653
static function () use ( $c ) {
5754
$endpoint = $c->get( 'order-endpoints.endpoint.approve-order' );
58-
/**
59-
* The Approve Order Endpoint.
60-
*
61-
* @var ApproveOrderEndpoint $endpoint
62-
*/
55+
assert( $endpoint instanceof ApproveOrderEndpoint );
56+
6357
$endpoint->handle_request();
6458
}
6559
);
@@ -68,11 +62,8 @@ static function () use ( $c ) {
6862
'wc_ajax_' . CreateOrderEndpoint::ENDPOINT,
6963
static function () use ( $c ) {
7064
$endpoint = $c->get( 'order-endpoints.endpoint.create-order' );
71-
/**
72-
* The Create Order Endpoint.
73-
*
74-
* @var CreateOrderEndpoint $endpoint
75-
*/
65+
assert( $endpoint instanceof CreateOrderEndpoint );
66+
7667
$endpoint->handle_request();
7768
}
7869
);

0 commit comments

Comments
 (0)