diff --git a/classes/BlueChip/Security/Modules/Checklist/Manager.php b/classes/BlueChip/Security/Modules/Checklist/Manager.php index 9a64498..75804b1 100644 --- a/classes/BlueChip/Security/Modules/Checklist/Manager.php +++ b/classes/BlueChip/Security/Modules/Checklist/Manager.php @@ -6,6 +6,9 @@ use BlueChip\Security\Modules; use BlueChip\Security\Modules\Cron; +/** + * @template TCheck of \BlueChip\Security\Modules\Checklist\Check + */ class Manager implements Modules\Initializable { /** @@ -14,7 +17,7 @@ class Manager implements Modules\Initializable public const ASYNC_CHECK_ACTION = 'bc_security_run_check'; /** - * @var \BlueChip\Security\Modules\Checklist\Check[] + * @var list */ private $checks; @@ -122,7 +125,7 @@ public function getCheck(string $id): ?Check * Return list of all implemented checks, optionally filtered. * * @param array{meaningful?:bool,monitored?:bool,status?:?bool} $filters [optional] Extra conditions to filter the list by. - * @return Check[] + * @return list */ public function getChecks(array $filters = []): array { diff --git a/phpstan.neon b/phpstan.neon index 1e713ef..d52348c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -10,6 +10,8 @@ parameters: bootstrapFiles: - tests/static-analysis/bootstrap.php - autoload.php + stubFiles: + - %currentWorkingDirectory%/tests/static-analysis/class-wp-list-table.stub ignoreErrors: # Apply "checkMissingIterableValueType: false" to Psr\Log classes for the time being. - '#^Method Psr\\Log\\\w+::\w+\(\) has parameter \$context with no value type specified in iterable type array\.$#' diff --git a/tests/static-analysis/class-wp-list-table.stub b/tests/static-analysis/class-wp-list-table.stub new file mode 100644 index 0000000..0f1c4cb --- /dev/null +++ b/tests/static-analysis/class-wp-list-table.stub @@ -0,0 +1,581 @@ + + */ + public $items; + /** + * Various information about the current table. + * + * @since 3.1.0 + * @var array + */ + protected $_args; + /** + * Various information needed for displaying the pagination. + * + * @since 3.1.0 + * @var array + */ + protected $_pagination_args = array(); + /** + * The current screen. + * + * @since 3.1.0 + * @var object + */ + protected $screen; + /** + * Cached bulk actions. + * + * @since 3.1.0 + * @var array + */ + private $_actions; + /** + * Cached pagination output. + * + * @since 3.1.0 + * @var string + */ + private $_pagination; + /** + * The view switcher modes. + * + * @since 4.1.0 + * @var array + */ + protected $modes = array(); + /** + * Stores the value returned by ->get_column_info(). + * + * @since 4.1.0 + * @var array + */ + protected $_column_headers; + /** + * {@internal Missing Summary} + * + * @var list + */ + protected $compat_fields = array('_args', '_pagination_args', 'screen', '_actions', '_pagination'); + /** + * {@internal Missing Summary} + * + * @var list + */ + protected $compat_methods = array('set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions', 'row_actions', 'months_dropdown', 'view_switcher', 'comments_bubble', 'get_items_per_page', 'pagination', 'get_sortable_columns', 'get_column_info', 'get_table_classes', 'display_tablenav', 'extra_tablenav', 'single_row_columns'); + /** + * Constructor. + * + * The child class should call this constructor from its own constructor to override + * the default $args. + * + * @since 3.1.0 + * + * @param array{plural:string, singular:string, ajax:bool, screen:string}|string $args + */ + public function __construct($args = array()) + { + } + /** + * Make private properties readable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to get. + * @return mixed Property. + */ + public function __get($name) + { + } + /** + * Make private properties settable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to check if set. + * @param mixed $value Property value. + * @return mixed Newly-set property. + */ + public function __set($name, $value) + { + } + /** + * Make private properties checkable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to check if set. + * @return bool Whether the property is set. + */ + public function __isset($name) + { + } + /** + * Make private properties un-settable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Property to unset. + * @return void + */ + public function __unset($name) + { + } + /** + * Make private/protected methods readable for backward compatibility. + * + * @since 4.0.0 + * + * @param string $name Method to call. + * @param array $arguments Arguments to pass when calling. + * @return mixed|bool Return value of the callback, false otherwise. + */ + public function __call($name, $arguments) + { + } + /** + * Checks the current user's permissions + * + * @since 3.1.0 + * @abstract + * @return void + */ + public function ajax_user_can() + { + } + /** + * Prepares the list of items for displaying. + * + * @uses WP_List_Table::set_pagination_args() + * + * @since 3.1.0 + * @abstract + * @return void + */ + public function prepare_items() + { + } + /** + * An internal method that sets all the necessary pagination arguments + * + * @since 3.1.0 + * + * @param array|string $args Array or string of arguments with information about the pagination. + * @return void + */ + protected function set_pagination_args($args) + { + } + /** + * Access the pagination args. + * + * @since 3.1.0 + * + * @param string $key Pagination argument to retrieve. Common values include 'total_items', + * 'total_pages', 'per_page', or 'infinite_scroll'. + * @return int Number of items that correspond to the given pagination argument. + */ + public function get_pagination_arg($key) + { + } + /** + * Whether the table has items to display or not + * + * @since 3.1.0 + * + * @return bool + */ + public function has_items() + { + } + /** + * Message to be displayed when there are no items + * + * @since 3.1.0 + * @return void + */ + public function no_items() + { + } + /** + * Displays the search box. + * + * @since 3.1.0 + * + * @param string $text The 'submit' button label. + * @param string $input_id ID attribute value for the search input field. + * @return void + */ + public function search_box($text, $input_id) + { + } + /** + * Gets the list of views available on this table. + * + * The format is an associative array: + * - `'id' => 'link'` + * + * @since 3.1.0 + * + * @return array + */ + protected function get_views() + { + } + /** + * Displays the list of views available on this table. + * + * @since 3.1.0 + * @return void + */ + public function views() + { + } + /** + * Gets the list of bulk actions available on this table. + * + * The format is an associative array: + * - `'option_name' => 'option_title'` + * + * @since 3.1.0 + * + * @return array + */ + protected function get_bulk_actions() + { + } + /** + * Displays the bulk actions dropdown. + * + * @since 3.1.0 + * + * @param string $which The location of the bulk actions: 'top' or 'bottom'. + * This is designated as optional for backward compatibility. + * @return void + */ + protected function bulk_actions($which = '') + { + } + /** + * Gets the current action selected from the bulk actions dropdown. + * + * @since 3.1.0 + * + * @return string|false The action name. False if no action was selected. + */ + public function current_action() + { + } + /** + * Generates the required HTML for a list of row action links. + * + * @since 3.1.0 + * + * @param string[] $actions An array of action links. + * @param bool $always_visible Whether the actions should be always visible. + * @return string The HTML for the row actions. + */ + protected function row_actions($actions, $always_visible = \false) + { + } + /** + * Displays a dropdown for filtering items in the list table by month. + * + * @since 3.1.0 + * + * @global wpdb $wpdb WordPress database abstraction object. + * @global WP_Locale $wp_locale WordPress date and time locale object. + * + * @param string $post_type The post type. + * @return void + */ + protected function months_dropdown($post_type) + { + } + /** + * Displays a view switcher. + * + * @since 3.1.0 + * + * @param string $current_mode + * @return void + */ + protected function view_switcher($current_mode) + { + } + /** + * Displays a comment count bubble. + * + * @since 3.1.0 + * + * @param int $post_id The post ID. + * @param int $pending_comments Number of pending comments. + * @return void + */ + protected function comments_bubble($post_id, $pending_comments) + { + } + /** + * Gets the current page number. + * + * @since 3.1.0 + * + * @return int + */ + public function get_pagenum() + { + } + /** + * Gets the number of items to display on a single page. + * + * @since 3.1.0 + * + * @param string $option + * @param int $default + * @return int + */ + protected function get_items_per_page($option, $default = 20) + { + } + /** + * Displays the pagination. + * + * @since 3.1.0 + * + * @param string $which + * @return void + */ + protected function pagination($which) + { + } + /** + * Gets a list of columns. + * + * The format is: + * - `'internal-name' => 'Title'` + * + * @since 3.1.0 + * @abstract + * + * @return array + */ + public function get_columns() + { + } + /** + * Gets a list of sortable columns. + * + * The format is: + * - `'internal-name' => 'orderby'` + * - `'internal-name' => array( 'orderby', 'asc' )` - The second element sets the initial sorting order. + * - `'internal-name' => array( 'orderby', true )` - The second element makes the initial order descending. + * + * @since 3.1.0 + * + * @return array + */ + protected function get_sortable_columns() + { + } + /** + * Gets the name of the default primary column. + * + * @since 4.3.0 + * + * @return string Name of the default primary column, in this case, an empty string. + */ + protected function get_default_primary_column_name() + { + } + /** + * Public wrapper for WP_List_Table::get_default_primary_column_name(). + * + * @since 4.4.0 + * + * @return string Name of the default primary column. + */ + public function get_primary_column() + { + } + /** + * Gets the name of the primary column. + * + * @since 4.3.0 + * + * @return string The name of the primary column. + */ + protected function get_primary_column_name() + { + } + /** + * Gets a list of all, hidden and sortable columns, with filter applied. + * + * @since 3.1.0 + * + * @return array + */ + protected function get_column_info() + { + } + /** + * Returns the number of visible columns. + * + * @since 3.1.0 + * + * @return int + */ + public function get_column_count() + { + } + /** + * Prints column headers, accounting for hidden and sortable columns. + * + * @since 3.1.0 + * + * @param bool $with_id Whether to set the ID attribute or not + * @return void + */ + public function print_column_headers($with_id = \true) + { + } + /** + * Displays the table. + * + * @since 3.1.0 + * @return void + */ + public function display() + { + } + /** + * Gets a list of CSS classes for the WP_List_Table table tag. + * + * @since 3.1.0 + * + * @return string[] Array of CSS classes for the table tag. + */ + protected function get_table_classes() + { + } + /** + * Generates the table navigation above or below the table + * + * @since 3.1.0 + * @param string $which + * @return void + */ + protected function display_tablenav($which) + { + } + /** + * Extra controls to be displayed between bulk actions and pagination. + * + * @since 3.1.0 + * + * @param string $which + * @return void + */ + protected function extra_tablenav($which) + { + } + /** + * Generates the tbody element for the list table. + * + * @since 3.1.0 + * @return void + */ + public function display_rows_or_placeholder() + { + } + /** + * Generates the table rows. + * + * @since 3.1.0 + * @return void + */ + public function display_rows() + { + } + /** + * Generates content for a single row of the table. + * + * @since 3.1.0 + * + * @param array $item The current item + * @return void + */ + public function single_row($item) + { + } + /** + * @param array $item + * @param string $column_name + * @return void + */ + protected function column_default($item, $column_name) + { + } + /** + * @param array $item + * @return void + */ + protected function column_cb($item) + { + } + /** + * Generates the columns for a single row of the table. + * + * @since 3.1.0 + * + * @param array $item The current item. + * @return void + */ + protected function single_row_columns($item) + { + } + /** + * Generates and display row actions links for the list table. + * + * @since 4.3.0 + * + * @param array $item The item being acted upon. + * @param string $column_name Current column name. + * @param string $primary Primary column name. + * @return string The row actions HTML, or an empty string + * if the current column is not the primary column. + */ + protected function handle_row_actions($item, $column_name, $primary) + { + } + /** + * Handles an incoming ajax request (called from admin-ajax.php) + * + * @since 3.1.0 + * @return void + */ + public function ajax_response() + { + } + /** + * Sends required variables to JavaScript land. + * + * @since 3.1.0 + * @return void + */ + public function _js_vars() + { + } +}