Skip to content

Commit 6ecedbb

Browse files
committed
PHPStan: mark current_user_can as impure
1 parent 03e7452 commit 6ecedbb

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/wp-admin/my-sites.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@
138138

139139
$actions = "<a href='" . esc_url( home_url() ) . "'>" . __( 'Visit' ) . '</a>';
140140

141-
// @phpstan-ignore if.alwaysTrue (Capabilities are site-specific)
142141
if ( current_user_can( 'read' ) ) {
143142
$actions .= " | <a href='" . esc_url( admin_url() ) . "'>" . __( 'Dashboard' ) . '</a>';
144143
}

src/wp-admin/upload.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ function () {
210210
<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
211211

212212
<?php
213-
// @phpstan-ignore if.alwaysTrue (Confidence check in case the file is required instead of accessed)
214213
if ( current_user_can( 'upload_files' ) ) {
215214
?>
216215
<a href="<?php echo esc_url( admin_url( 'media-new.php' ) ); ?>" class="page-title-action aria-button-if-js"><?php echo esc_html__( 'Add Media File' ); ?></a>
@@ -418,7 +417,6 @@ function () {
418417
<h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1>
419418

420419
<?php
421-
// @phpstan-ignore if.alwaysTrue (Confidence check in case the file is required instead of accessed)
422420
if ( current_user_can( 'upload_files' ) ) {
423421
?>
424422
<a href="<?php echo esc_url( admin_url( 'media-new.php' ) ); ?>" class="page-title-action"><?php echo esc_html__( 'Add Media File' ); ?></a>

src/wp-includes/capabilities.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,8 @@ function map_meta_cap( $cap, $user_id, ...$args ) {
903903
* @param mixed ...$args Optional further parameters, typically starting with an object ID.
904904
* @return bool Whether the current user has the given capability. If `$capability` is a meta cap and `$object_id` is
905905
* passed, whether the current user has the given meta capability for the given object.
906+
*
907+
* @phpstan-impure
906908
*/
907909
function current_user_can( $capability, ...$args ) {
908910
return user_can( wp_get_current_user(), $capability, ...$args );
@@ -929,6 +931,8 @@ function current_user_can( $capability, ...$args ) {
929931
* @param string $capability Capability name.
930932
* @param mixed ...$args Optional further parameters, typically starting with an object ID.
931933
* @return bool Whether the user has the given capability.
934+
*
935+
* @phpstan-impure
932936
*/
933937
function current_user_can_for_site( $site_id, $capability, ...$args ) {
934938
$switched = is_multisite() ? switch_to_blog( $site_id ) : false;

0 commit comments

Comments
 (0)