Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ parameters:
bootstrapFiles:
- vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
- vendor/php-stubs/woocommerce-stubs/woocommerce-stubs.php
- tests/stubs/wp-cli-stubs.php
ignoreErrors:
- '#Constant [A-Z_]+ not found#'
56 changes: 56 additions & 0 deletions tests/stubs/wp-cli-stubs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* Minimal WP-CLI stubs for static analysis only.
*
* WP-CLI's classes exist only when the CLI is running, so phpstan cannot see
* them. This declares just the symbols class-webdecoy-cli.php uses. Never
* loaded at runtime; referenced from phpstan.neon bootstrapFiles.
*/

// phpcs:ignoreFile

namespace {
class WP_CLI
{
public static function add_command(string $name, $callable): void
{
}

public static function log(string $message): void
{
}

public static function warning(string $message): void
{
}

public static function success(string $message): void
{
}

/**
* @return never
*/
public static function error(string $message)
{
exit(1);
}

/**
* @param array<string, mixed> $assoc_args
*/
public static function confirm(string $question, array $assoc_args = []): void
{
}
}
}

namespace WP_CLI\Utils {
/**
* @param array<int, array<string, mixed>> $items
* @param array<int, string> $fields
*/
function format_items(string $format, array $items, array $fields): void
{
}
}
Loading