Skip to content

Commit 42197b5

Browse files
committed
refactor: namespaces PSR classes and corrects versions
1 parent 23f1af0 commit 42197b5

59 files changed

Lines changed: 342 additions & 390 deletions

File tree

Some content is hidden

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

src/wp-includes/ai-client-utils/class-wp-ai-client-ability-function-resolver.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @package WordPress
66
* @subpackage AI
7-
* @since 6.8.0
7+
* @since 7.0.0
88
*/
99

1010
use WordPress\AiClient\Messages\DTO\Message;
@@ -16,22 +16,22 @@
1616
/**
1717
* Resolves and executes WordPress Abilities API function calls from AI models.
1818
*
19-
* @since 6.8.0
19+
* @since 7.0.0
2020
*/
2121
class WP_AI_Client_Ability_Function_Resolver {
2222

2323
/**
2424
* Prefix used to identify ability function calls.
2525
*
26-
* @since 6.8.0
26+
* @since 7.0.0
2727
* @var string
2828
*/
2929
private const ABILITY_PREFIX = 'wpab__';
3030

3131
/**
3232
* Checks if a function call is an ability call.
3333
*
34-
* @since 6.8.0
34+
* @since 7.0.0
3535
*
3636
* @param FunctionCall $call The function call to check.
3737
* @return bool True if the function call is an ability call, false otherwise.
@@ -48,7 +48,7 @@ public static function is_ability_call( FunctionCall $call ): bool {
4848
/**
4949
* Executes a WordPress ability from a function call.
5050
*
51-
* @since 6.8.0
51+
* @since 7.0.0
5252
*
5353
* @param FunctionCall $call The function call to execute.
5454
* @return FunctionResponse The response from executing the ability.
@@ -107,7 +107,7 @@ public static function execute_ability( FunctionCall $call ): FunctionResponse {
107107
/**
108108
* Checks if a message contains any ability function calls.
109109
*
110-
* @since 6.8.0
110+
* @since 7.0.0
111111
*
112112
* @param Message $message The message to check.
113113
* @return bool True if the message contains ability calls, false otherwise.
@@ -128,7 +128,7 @@ public static function has_ability_calls( Message $message ): bool {
128128
/**
129129
* Executes all ability function calls in a message.
130130
*
131-
* @since 6.8.0
131+
* @since 7.0.0
132132
*
133133
* @param Message $message The message containing function calls.
134134
* @return Message A new message with function responses.
@@ -154,7 +154,7 @@ public static function execute_abilities( Message $message ): Message {
154154
*
155155
* Transforms "tec/create_event" to "wpab__tec__create_event".
156156
*
157-
* @since 6.8.0
157+
* @since 7.0.0
158158
*
159159
* @param string $ability_name The ability name to convert.
160160
* @return string The function name.
@@ -168,7 +168,7 @@ public static function ability_name_to_function_name( string $ability_name ): st
168168
*
169169
* Transforms "wpab__tec__create_event" to "tec/create_event".
170170
*
171-
* @since 6.8.0
171+
* @since 7.0.0
172172
*
173173
* @param string $function_name The function name to convert.
174174
* @return string The ability name.

src/wp-includes/ai-client-utils/class-wp-ai-client-discovery-strategy.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
*
55
* @package WordPress
66
* @subpackage AI
7-
* @since 6.8.0
7+
* @since 7.0.0
88
*/
99

1010
use WordPress\AiClientDependencies\Http\Discovery\Psr18ClientDiscovery;
1111
use WordPress\AiClientDependencies\Http\Discovery\Strategy\DiscoveryStrategy;
12-
use Psr\Http\Client\ClientInterface;
12+
use WordPress\AiClientDependencies\Psr\Http\Client\ClientInterface;
1313

1414
/**
1515
* Discovery strategy for WordPress HTTP client.
1616
*
1717
* Registers the WordPress HTTP client adapter with the HTTPlug discovery system
1818
* so the AI Client SDK can find and use it automatically.
1919
*
20-
* @since 6.8.0
20+
* @since 7.0.0
2121
*/
2222
class WP_AI_Client_Discovery_Strategy implements DiscoveryStrategy {
2323

2424
/**
2525
* Initializes and registers the discovery strategy.
2626
*
27-
* @since 6.8.0
27+
* @since 7.0.0
2828
*/
2929
public static function init() {
3030
if ( ! class_exists( '\WordPress\AiClientDependencies\Http\Discovery\Psr18ClientDiscovery' ) ) {
@@ -37,7 +37,7 @@ public static function init() {
3737
/**
3838
* Gets candidates for discovery.
3939
*
40-
* @since 6.8.0
40+
* @since 7.0.0
4141
*
4242
* @param string $type The type of discovery.
4343
* @return array<array<string, mixed>> List of candidates.
@@ -54,12 +54,12 @@ public static function getCandidates( $type ) {
5454
}
5555

5656
$psr17_factories = array(
57-
'Psr\Http\Message\RequestFactoryInterface',
58-
'Psr\Http\Message\ResponseFactoryInterface',
59-
'Psr\Http\Message\ServerRequestFactoryInterface',
60-
'Psr\Http\Message\StreamFactoryInterface',
61-
'Psr\Http\Message\UploadedFileFactoryInterface',
62-
'Psr\Http\Message\UriFactoryInterface',
57+
'WordPress\AiClientDependencies\Psr\Http\Message\RequestFactoryInterface',
58+
'WordPress\AiClientDependencies\Psr\Http\Message\ResponseFactoryInterface',
59+
'WordPress\AiClientDependencies\Psr\Http\Message\ServerRequestFactoryInterface',
60+
'WordPress\AiClientDependencies\Psr\Http\Message\StreamFactoryInterface',
61+
'WordPress\AiClientDependencies\Psr\Http\Message\UploadedFileFactoryInterface',
62+
'WordPress\AiClientDependencies\Psr\Http\Message\UriFactoryInterface',
6363
);
6464

6565
if ( in_array( $type, $psr17_factories, true ) ) {
@@ -76,7 +76,7 @@ public static function getCandidates( $type ) {
7676
/**
7777
* Creates an instance of the WordPress HTTP client.
7878
*
79-
* @since 6.8.0
79+
* @since 7.0.0
8080
*
8181
* @return WP_AI_Client_HTTP_Client
8282
*/

src/wp-includes/ai-client-utils/class-wp-ai-client-event-dispatcher.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44
*
55
* @package WordPress
66
* @subpackage AI
7-
* @since 6.8.0
7+
* @since 7.0.0
88
*/
99

10-
use Psr\EventDispatcher\EventDispatcherInterface;
10+
use WordPress\AiClientDependencies\Psr\EventDispatcher\EventDispatcherInterface;
1111

1212
/**
1313
* WordPress-specific PSR-14 event dispatcher for the AI Client.
1414
*
1515
* Bridges PSR-14 events to WordPress action hooks, enabling plugins to hook
1616
* into AI client lifecycle events.
1717
*
18-
* @since 6.8.0
18+
* @since 7.0.0
1919
*/
2020
class WP_AI_Client_Event_Dispatcher implements EventDispatcherInterface {
2121

@@ -25,7 +25,7 @@ class WP_AI_Client_Event_Dispatcher implements EventDispatcherInterface {
2525
* Converts the event class name to a WordPress action hook name and fires it.
2626
* For example, BeforeGenerateResultEvent becomes wp_ai_client_before_generate_result.
2727
*
28-
* @since 6.8.0
28+
* @since 7.0.0
2929
*
3030
* @param object $event The event object to dispatch.
3131
* @return object The same event object, potentially modified by listeners.
@@ -47,7 +47,7 @@ public function dispatch( object $event ): object {
4747
* - wp_ai_client_before_generate_result
4848
* - wp_ai_client_after_generate_result
4949
*
50-
* @since 6.8.0
50+
* @since 7.0.0
5151
*
5252
* @param object $event The event object.
5353
*/
@@ -59,7 +59,7 @@ public function dispatch( object $event ): object {
5959
/**
6060
* Converts an event object class name to a WordPress action hook name portion.
6161
*
62-
* @since 6.8.0
62+
* @since 7.0.0
6363
*
6464
* @param object $event The event object.
6565
* @return string The hook name portion derived from the event class name.

src/wp-includes/ai-client-utils/class-wp-ai-client-http-client.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
*
55
* @package WordPress
66
* @subpackage AI
7-
* @since 6.8.0
7+
* @since 7.0.0
88
*/
99

10-
use Psr\Http\Client\ClientInterface;
11-
use Psr\Http\Message\RequestInterface;
12-
use Psr\Http\Message\ResponseInterface;
13-
use Psr\Http\Message\ResponseFactoryInterface;
14-
use Psr\Http\Message\StreamFactoryInterface;
10+
use WordPress\AiClientDependencies\Psr\Http\Client\ClientInterface;
11+
use WordPress\AiClientDependencies\Psr\Http\Message\RequestInterface;
12+
use WordPress\AiClientDependencies\Psr\Http\Message\ResponseInterface;
13+
use WordPress\AiClientDependencies\Psr\Http\Message\ResponseFactoryInterface;
14+
use WordPress\AiClientDependencies\Psr\Http\Message\StreamFactoryInterface;
1515
use WordPress\AiClient\Providers\Http\Contracts\ClientWithOptionsInterface;
1616
use WordPress\AiClient\Providers\Http\DTO\RequestOptions;
1717
use WordPress\AiClient\Providers\Http\Exception\NetworkException;
@@ -22,30 +22,30 @@
2222
* Allows WordPress HTTP functions to be used as a PSR-18 compliant HTTP client
2323
* for the AI Client SDK.
2424
*
25-
* @since 6.8.0
25+
* @since 7.0.0
2626
*/
2727
class WP_AI_Client_HTTP_Client implements ClientInterface, ClientWithOptionsInterface {
2828

2929
/**
3030
* Response factory instance.
3131
*
32-
* @since 6.8.0
32+
* @since 7.0.0
3333
* @var ResponseFactoryInterface
3434
*/
3535
private $response_factory;
3636

3737
/**
3838
* Stream factory instance.
3939
*
40-
* @since 6.8.0
40+
* @since 7.0.0
4141
* @var StreamFactoryInterface
4242
*/
4343
private $stream_factory;
4444

4545
/**
4646
* Constructor.
4747
*
48-
* @since 6.8.0
48+
* @since 7.0.0
4949
*
5050
* @param ResponseFactoryInterface $response_factory PSR-17 Response factory.
5151
* @param StreamFactoryInterface $stream_factory PSR-17 Stream factory.
@@ -58,7 +58,7 @@ public function __construct( ResponseFactoryInterface $response_factory, StreamF
5858
/**
5959
* Sends a PSR-7 request and returns a PSR-7 response.
6060
*
61-
* @since 6.8.0
61+
* @since 7.0.0
6262
*
6363
* @param RequestInterface $request The PSR-7 request.
6464
* @return ResponseInterface The PSR-7 response.
@@ -88,7 +88,7 @@ public function sendRequest( RequestInterface $request ): ResponseInterface {
8888
/**
8989
* Sends a PSR-7 request with transport options and returns a PSR-7 response.
9090
*
91-
* @since 6.8.0
91+
* @since 7.0.0
9292
*
9393
* @param RequestInterface $request The PSR-7 request.
9494
* @param RequestOptions $options Transport options for the request.
@@ -121,7 +121,7 @@ public function sendRequestWithOptions( RequestInterface $request, RequestOption
121121
/**
122122
* Prepares WordPress HTTP API arguments from a PSR-7 request.
123123
*
124-
* @since 6.8.0
124+
* @since 7.0.0
125125
*
126126
* @param RequestInterface $request The PSR-7 request.
127127
* @param RequestOptions|null $options Optional transport options for the request.
@@ -152,7 +152,7 @@ private function prepare_wp_args( RequestInterface $request, ?RequestOptions $op
152152
/**
153153
* Prepares headers for WordPress HTTP API.
154154
*
155-
* @since 6.8.0
155+
* @since 7.0.0
156156
*
157157
* @param RequestInterface $request The PSR-7 request.
158158
* @return array<string, string> Headers array for WordPress HTTP API.
@@ -174,7 +174,7 @@ private function prepare_headers( RequestInterface $request ): array {
174174
/**
175175
* Prepares request body for WordPress HTTP API.
176176
*
177-
* @since 6.8.0
177+
* @since 7.0.0
178178
*
179179
* @param RequestInterface $request The PSR-7 request.
180180
* @return string|null The request body.
@@ -196,7 +196,7 @@ private function prepare_body( RequestInterface $request ): ?string {
196196
/**
197197
* Creates a PSR-7 response from a WordPress HTTP response.
198198
*
199-
* @since 6.8.0
199+
* @since 7.0.0
200200
*
201201
* @param array<string, mixed> $wp_response WordPress HTTP API response array.
202202
* @return ResponseInterface PSR-7 response.

src/wp-includes/ai-client-utils/class-wp-ai-client-psr17-factory.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@
44
*
55
* @package WordPress
66
* @subpackage AI
7-
* @since 6.8.0
7+
* @since 7.0.0
88
*/
99

10-
use Psr\Http\Message\RequestFactoryInterface;
11-
use Psr\Http\Message\RequestInterface;
12-
use Psr\Http\Message\ResponseFactoryInterface;
13-
use Psr\Http\Message\ResponseInterface;
14-
use Psr\Http\Message\StreamFactoryInterface;
15-
use Psr\Http\Message\StreamInterface;
16-
use Psr\Http\Message\UriFactoryInterface;
17-
use Psr\Http\Message\UriInterface;
10+
use WordPress\AiClientDependencies\Psr\Http\Message\RequestFactoryInterface;
11+
use WordPress\AiClientDependencies\Psr\Http\Message\RequestInterface;
12+
use WordPress\AiClientDependencies\Psr\Http\Message\ResponseFactoryInterface;
13+
use WordPress\AiClientDependencies\Psr\Http\Message\ResponseInterface;
14+
use WordPress\AiClientDependencies\Psr\Http\Message\StreamFactoryInterface;
15+
use WordPress\AiClientDependencies\Psr\Http\Message\StreamInterface;
16+
use WordPress\AiClientDependencies\Psr\Http\Message\UriFactoryInterface;
17+
use WordPress\AiClientDependencies\Psr\Http\Message\UriInterface;
1818

1919
/**
2020
* Combined PSR-17 factory for creating PSR-7 HTTP message objects.
2121
*
2222
* Implements all four PSR-17 factory interfaces, delegating to the minimal
2323
* WP AI Client PSR-7 implementations.
2424
*
25-
* @since 6.8.0
25+
* @since 7.0.0
2626
*/
2727
class WP_AI_Client_PSR17_Factory implements RequestFactoryInterface, ResponseFactoryInterface, StreamFactoryInterface, UriFactoryInterface {
2828

2929
/**
3030
* Creates a new request.
3131
*
32-
* @since 6.8.0
32+
* @since 7.0.0
3333
*
3434
* @param string $method The HTTP method associated with the request.
3535
* @param UriInterface|string $uri The URI associated with the request.
@@ -42,7 +42,7 @@ public function createRequest( string $method, $uri ): RequestInterface {
4242
/**
4343
* Creates a new response.
4444
*
45-
* @since 6.8.0
45+
* @since 7.0.0
4646
*
4747
* @param int $code HTTP status code. Defaults to 200.
4848
* @param string $reasonPhrase Reason phrase to associate with status code.
@@ -55,7 +55,7 @@ public function createResponse( int $code = 200, string $reasonPhrase = '' ): Re
5555
/**
5656
* Creates a new stream from a string.
5757
*
58-
* @since 6.8.0
58+
* @since 7.0.0
5959
*
6060
* @param string $content String content with which to populate the stream.
6161
* @return StreamInterface
@@ -67,7 +67,7 @@ public function createStream( string $content = '' ): StreamInterface {
6767
/**
6868
* Creates a stream from an existing file.
6969
*
70-
* @since 6.8.0
70+
* @since 7.0.0
7171
*
7272
* @param string $filename Filename or stream URI to use as basis of stream.
7373
* @param string $mode Mode with which to open the underlying filename/stream.
@@ -86,7 +86,7 @@ public function createStreamFromFile( string $filename, string $mode = 'r' ): St
8686
/**
8787
* Creates a new stream from an existing resource.
8888
*
89-
* @since 6.8.0
89+
* @since 7.0.0
9090
*
9191
* @param resource $resource PHP resource to use as basis of stream.
9292
* @return StreamInterface
@@ -104,7 +104,7 @@ public function createStreamFromResource( $resource ): StreamInterface {
104104
/**
105105
* Creates a new URI.
106106
*
107-
* @since 6.8.0
107+
* @since 7.0.0
108108
*
109109
* @param string $uri The URI string.
110110
* @return UriInterface

0 commit comments

Comments
 (0)