Skip to content

Commit

Permalink
Let PHPStan ignore lines where WordPress core files are required
Browse files Browse the repository at this point in the history
This avoids errors due to requireFile rule. See also:
szepeviktor/phpstan-wordpress#239
  • Loading branch information
chesio committed Oct 14, 2024
1 parent 295738b commit eacd2ea
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion classes/BlueChip/Security/Helpers/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public static function getPluginsInstalledFromWordPressOrg(): array
{
// We're using some wp-admin stuff here, so make sure it's available.
if (!\function_exists('get_plugins')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once ABSPATH . 'wp-admin/includes/plugin.php'; // @phpstan-ignore-line
}

$wordpress_org_plugins = \array_filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function extract(): array
}

if (!\function_exists('extract_from_markers')) {
require_once ABSPATH . 'wp-admin/includes/misc.php';
require_once ABSPATH . 'wp-admin/includes/misc.php'; // @phpstan-ignore-line
}

$lines = extract_from_markers($this->htaccess_file, self::MARKER);
Expand Down Expand Up @@ -79,7 +79,7 @@ public function insert(array $blocked_ip_addresses): bool
}

if (!\function_exists('insert_with_markers')) {
require_once ABSPATH . 'wp-admin/includes/misc.php';
require_once ABSPATH . 'wp-admin/includes/misc.php'; // @phpstan-ignore-line
}

// Prepare rules for given IP addresses.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function __construct(private wpdb $wpdb, private HtaccessSynchronizer $ht
public function install(): void
{
// To have dbDelta()
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
require_once ABSPATH . 'wp-admin/includes/upgrade.php'; // @phpstan-ignore-line

$charset_collate = $this->wpdb->get_charset_collate();

Expand Down
2 changes: 1 addition & 1 deletion classes/BlueChip/Security/Modules/Log/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(private wpdb $wpdb, private string $remote_address,
public function install(): void
{
// To have dbDelta()
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
require_once ABSPATH . 'wp-admin/includes/upgrade.php'; // @phpstan-ignore-line

$charset_collate = $this->wpdb->get_charset_collate();

Expand Down
2 changes: 1 addition & 1 deletion classes/BlueChip/Security/Modules/Login/Bookkeeper.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(private Settings $settings, private wpdb $wpdb)
public function install(): void
{
// To have dbDelta()
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
require_once ABSPATH . 'wp-admin/includes/upgrade.php'; // @phpstan-ignore-line

$charset_collate = $this->wpdb->get_charset_collate();

Expand Down

0 comments on commit eacd2ea

Please sign in to comment.