Skip to content

Commit

Permalink
Merge pull request #1101 from skaut/dependabot/composer/phpstan/phpst…
Browse files Browse the repository at this point in the history
…an-2.0.2

Bump phpstan/phpstan from 1.12.8 to 2.0.2
  • Loading branch information
marekdedic authored Nov 19, 2024
2 parents 674ded0 + f7d900e commit b2794cf
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 54 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"wp-coding-standards/wpcs": "^3.0",
"humbug/php-scoper": "^0.18.1",
"skaut/wordpress-stubs": "^2.1",
"phpstan/phpstan": "^1.6",
"phpstan/phpstan": "^2.0",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0"
}
}
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/php/class-skautis-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@ protected static function is_compatible_version_of_wp() {
* @return bool Whether the current version of PHP is supported.
*/
protected static function is_compatible_version_of_php() {
// @phpstan-ignore if.alwaysTrue
if ( version_compare( PHP_VERSION, '7.4', '>=' ) ) {
return true;
}

// @phpstan-ignore deadCode.unreachable
return false;
}

Expand Down
15 changes: 3 additions & 12 deletions src/php/src/admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,13 @@ public function add_logout_link_to_admin_bar( \WP_Admin_Bar $wp_admin_bar ) {
if ( ! is_admin_bar_showing() ) {
return;
}

if ( method_exists( $wp_admin_bar, 'get_node' ) ) {
if ( ! is_null( $wp_admin_bar->get_node( 'user-actions' ) ) ) {
$parent = 'user-actions';
} else {
return;
}
} elseif ( 1 === get_option( 'show_avatars' ) ) {
$parent = 'my-account-with-avatar';
} else {
$parent = 'my-account';
if ( is_null( $wp_admin_bar->get_node( 'user-actions' ) ) ) {
return;
}

$wp_admin_bar->add_menu(
array(
'parent' => $parent,
'parent' => 'user-actions',
'id' => SKAUTIS_INTEGRATION_NAME . '_adminBar_logout',
'title' => esc_html__( 'Log Out (too from skautIS)', 'skautis-integration' ),
'href' => $this->wp_login_logout->get_logout_url(),
Expand Down
9 changes: 5 additions & 4 deletions src/php/src/auth/class-connect-and-disconnect-wp-account.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct( Skautis_Gateway $skautis_gateway, Skautis_Login $sk
*
* @return void
*
* @SuppressWarnings(PHPMD.ExitExpression)
* @SuppressWarnings("PHPMD.ExitExpression")
*/
private function set_skautis_user_id_to_wp_account( int $wp_user_id, int $skautis_user_id ) {
$return_url = Helpers::get_return_url();
Expand Down Expand Up @@ -110,7 +110,7 @@ class="button">' . esc_html__( 'Propojit tento účet se skautISem', 'skautis-in
*
* @return void
*
* @SuppressWarnings(PHPMD.ExitExpression)
* @SuppressWarnings("PHPMD.ExitExpression")
*/
public function connect() {
if ( ! $this->skautis_login->is_user_logged_in_skautis() ) {
Expand Down Expand Up @@ -186,7 +186,7 @@ public function get_connect_wp_user_to_skautis_url(): string {
*
* @return void
*
* @SuppressWarnings(PHPMD.ExitExpression)
* @SuppressWarnings("PHPMD.ExitExpression")
*/
public function disconnect() {
if ( is_user_logged_in() ) {
Expand All @@ -199,10 +199,11 @@ public function disconnect() {
} elseif ( ( strpos( $return_url, 'user-edit_php' ) !== false ||
strpos( $return_url, 'user-edit.php' ) !== false ) &&
strpos( $return_url, 'user_id=' ) !== false ) {
$result = array();
if ( 1 !== preg_match( '~user_id=(\d+)~', $return_url, $result ) ) {
return;
}
if ( is_array( $result ) && $result[1] > 0 ) {
if ( $result[1] > 0 ) {
$user_id = absint( $result[1] );
if ( Helpers::user_is_skautis_manager() ) {
delete_user_meta( $user_id, 'skautisUserId_' . $this->skautis_gateway->get_env() );
Expand Down
2 changes: 1 addition & 1 deletion src/php/src/auth/class-skautis-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function get_env(): string {
/**
* Returns the raw SkauIS library instance
*
* @SuppressWarnings(PHPMD.ExitExpression)
* @SuppressWarnings("PHPMD.ExitExpression")
*/
public function get_skautis_instance(): Skautis\Skautis {
if ( ! ( $this->skautis instanceof Skautis\Skautis ) ) {
Expand Down
4 changes: 2 additions & 2 deletions src/php/src/auth/class-skautis-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function set_login_data_to_local_skautis_instance( array $data = array()
*
* @return void
*
* @SuppressWarnings(PHPMD.ExitExpression)
* @SuppressWarnings("PHPMD.ExitExpression")
*/
public function login() {
$return_url = Helpers::get_login_logout_redirect();
Expand Down Expand Up @@ -115,7 +115,7 @@ public function login() {
*
* @return void
*
* @SuppressWarnings(PHPMD.ExitExpression)
* @SuppressWarnings("PHPMD.ExitExpression")
*/
public function login_confirm() {
$return_url = Helpers::get_return_url();
Expand Down
4 changes: 2 additions & 2 deletions src/php/src/auth/class-wp-login-logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct( Skautis_Gateway $skautis_gateway ) {
*
* @return false
*
* @SuppressWarnings(PHPMD.ExitExpression)
* @SuppressWarnings("PHPMD.ExitExpression")
*/
private function login_wp_user_by_skautis_user_id( int $skautis_user_id, $dont_die_on_error = false ) {
$return_url = Helpers::get_return_url();
Expand Down Expand Up @@ -196,7 +196,7 @@ public function try_to_login_to_wp() {
*
* @return void
*
* @SuppressWarnings(PHPMD.ExitExpression)
* @SuppressWarnings("PHPMD.ExitExpression")
*/
public function logout() {
$this->skautis_gateway->logout();
Expand Down
15 changes: 3 additions & 12 deletions src/php/src/frontend/class-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,22 +145,13 @@ public function add_logout_link_to_admin_bar( \WP_Admin_Bar $wp_admin_bar ) {
if ( ! is_admin_bar_showing() ) {
return;
}

if ( method_exists( $wp_admin_bar, 'get_node' ) ) {
if ( ! is_null( $wp_admin_bar->get_node( 'user-actions' ) ) ) {
$parent = 'user-actions';
} else {
return;
}
} elseif ( 1 === get_option( 'show_avatars' ) ) {
$parent = 'my-account-with-avatar';
} else {
$parent = 'my-account';
if ( is_null( $wp_admin_bar->get_node( 'user-actions' ) ) ) {
return;
}

$wp_admin_bar->add_menu(
array(
'parent' => $parent,
'parent' => 'user-actions',
'id' => SKAUTIS_INTEGRATION_NAME . '_adminBar_logout',
'title' => esc_html__( 'Odhlásit se (i ze skautISu)', 'skautis-integration' ),
'href' => $this->wp_login_logout->get_logout_url(),
Expand Down
2 changes: 1 addition & 1 deletion src/php/src/general/class-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function auth_in_process() {
*
* @param \WP_Query $wp_query The request query.
*
* @SuppressWarnings(PHPMD.ExitExpression)
* @SuppressWarnings("PHPMD.ExitExpression")
*
* @return \WP_Query|void
*/
Expand Down
6 changes: 3 additions & 3 deletions src/php/src/modules/Register/class-register.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private function init_hooks() {
*
* @return void
*
* @SuppressWarnings(PHPMD.ExitExpression)
* @SuppressWarnings("PHPMD.ExitExpression")
*/
private function loginUserAfterRegistration() {
$return_url = Helpers::get_login_logout_redirect();
Expand Down Expand Up @@ -216,7 +216,7 @@ public function getRulesManager(): Rules_Manager {
*
* @return void
*
* @SuppressWarnings(PHPMD.ExitExpression)
* @SuppressWarnings("PHPMD.ExitExpression")
*/
public function register() {
if ( ! $this->skautis_login->is_user_logged_in_skautis() ) {
Expand Down Expand Up @@ -269,7 +269,7 @@ public function registerUser() {
*
* @return void
*
* @SuppressWarnings(PHPMD.ExitExpression)
* @SuppressWarnings("PHPMD.ExitExpression")
*/
public function registerUserManually() {
$return_url = Helpers::get_return_url();
Expand Down
4 changes: 2 additions & 2 deletions src/php/src/modules/Register/class-wp-register.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct( Skautis_Gateway $skautis_gateway, UsersRepository $
*
* @return int The ID of the new user.
*
* @SuppressWarnings(PHPMD.ExitExpression)
* @SuppressWarnings("PHPMD.ExitExpression")
*/
private static function resolve_notifications_and_register_user_to_wp( string $user_login, string $user_email ) {
remove_action( 'register_new_user', 'wp_send_new_user_notifications' );
Expand Down Expand Up @@ -171,7 +171,7 @@ private function process_wp_user_registration( array $user, string $wp_role ): b

$user_id = self::resolve_notifications_and_register_user_to_wp( $username, $user['email'] );

if ( 0 === $user_id || ! is_int( $user_id ) ) {
if ( 0 === $user_id ) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/php/src/repository/class-users.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static function ( $participant ) {

if ( isset( $participant->PersonEmail ) && ! empty( $participant->PersonEmail ) ) {
$emails = preg_split( '~(?=\,)~x', $participant->PersonEmail );
if ( ! empty( $emails ) && isset( $emails[0] ) ) {
if ( isset( $emails[0] ) ) {
$user->email = $emails[0];
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/php/src/rules/Rule/class-func.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function is_rule_passed( string $funcs_operator, $data ): bool {
}
}

if ( is_int( $user_pass ) && $user_pass > 0 ) {
if ( $user_pass > 0 ) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/php/src/rules/Rule/class-membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function is_rule_passed( string $operator, $data ): bool {
}
}

if ( is_int( $user_pass ) && $user_pass > 0 ) {
if ( $user_pass > 0 ) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/php/src/rules/Rule/class-qualification.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function is_rule_passed( string $operator, $data ): bool {
}
}

if ( is_int( $user_pass ) && $user_pass > 0 ) {
if ( $user_pass > 0 ) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/php/src/rules/Rule/class-role.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public function is_rule_passed( string $roles_operator, $data ): bool {
}
}

if ( is_int( $user_pass ) && $user_pass > 0 ) {
if ( $user_pass > 0 ) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/php/src/rules/class-revisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static function delete_meta( int $post_id ) {
*
* @return string The field value.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
*/
public static function field( $value, $field, $revision ) {
$revision_id = $revision->ID;
Expand Down
2 changes: 1 addition & 1 deletion src/php/src/utils/class-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public static function get_variable_from_url( string $url, string $variable_name
$result = array();
$url = esc_url_raw( $url );
if ( 1 === preg_match( '~' . $variable_name . '=([^\&,\s,\/,\#,\%,\?]*)~', $url, $result ) ) {
if ( is_array( $result ) && isset( $result[1] ) && '' !== $result[1] ) {
if ( isset( $result[1] ) && '' !== $result[1] ) {
return sanitize_text_field( $result[1] );
}
}
Expand Down

0 comments on commit b2794cf

Please sign in to comment.