mirror of
https://hk.gh-proxy.com/https://github.com/mcp-wp/mcp-server.git
synced 2025-10-03 21:21:17 +08:00
PHPStan level 9
This commit is contained in:
parent
2488e47ea7
commit
b6835d0173
2 changed files with 7 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
parameters:
|
||||
level: 8
|
||||
level: 9
|
||||
paths:
|
||||
- mcp.php
|
||||
- src/
|
||||
|
|
|
@ -12,6 +12,7 @@ use WP_REST_Response;
|
|||
* REST API tools class.
|
||||
*
|
||||
* @phpstan-import-type ToolDefinition from Server
|
||||
* @phpstan-type ArgumentSchema array{description?: string, type?: string, required?: bool}
|
||||
*/
|
||||
readonly class RestApi {
|
||||
private LoggerInterface $logger;
|
||||
|
@ -156,7 +157,8 @@ readonly class RestApi {
|
|||
if ( array_key_exists( $match, $params ) ) {
|
||||
$route = (string) preg_replace(
|
||||
'/(\(\?P<' . $match . '>.*?\))/',
|
||||
$params[ $match ],
|
||||
// @phpstan-ignore cast.string
|
||||
(string) $params[ $match ],
|
||||
$route,
|
||||
1
|
||||
);
|
||||
|
@ -206,6 +208,7 @@ readonly class RestApi {
|
|||
* @throws \Exception
|
||||
*
|
||||
* @param array<string, mixed> $args REST API route arguments.
|
||||
* @phpstan-param array<string, ArgumentSchema> $args REST API route arguments.
|
||||
* @return array<string, mixed> Normalized schema.
|
||||
*/
|
||||
private function args_to_schema( array $args = [] ): array {
|
||||
|
@ -269,7 +272,8 @@ readonly class RestApi {
|
|||
}
|
||||
|
||||
if ( ! \is_array( $type ) ) {
|
||||
throw new \Exception( 'Invalid type: ' . $type );
|
||||
// @phpstan-ignore binaryOp.invalid
|
||||
throw new \Exception( 'Invalid type: ' . $type);
|
||||
}
|
||||
|
||||
// Find valid values in array.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue