@@ -36,7 +36,7 @@ function main(): void {
3636 * @return array<string, string>
3737 */
3838function get_environments (): array {
39- return (array ) apply_filters ( 'wp_environment_switcher_environments ' , [] );
39+ return (array ) apply_filters ( 'wp_environment_switcher_environments ' , [] ); // @phpstan-ignore-line return.type
4040}
4141
4242/**
@@ -49,7 +49,9 @@ function get_environments(): array {
4949 */
5050function get_current_environment (): string {
5151 $ default = match ( true ) {
52+ // @phpstan-ignore-next-line cast.string
5253 ! empty ( $ _ENV ['PANTHEON_ENVIRONMENT ' ] ) => (string ) $ _ENV ['PANTHEON_ENVIRONMENT ' ], // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
54+ // @phpstan-ignore-next-line cast.string
5355 defined ( 'VIP_GO_APP_ENVIRONMENT ' ) => (string ) VIP_GO_APP_ENVIRONMENT ,
5456 default => (string ) wp_get_environment_type (),
5557 };
@@ -76,7 +78,7 @@ function get_translated_url( string $environment_url ): string {
7678 return $ environment_url ;
7779 }
7880
79- return rtrim ( $ environment_url , '/ ' ) . sanitize_text_field ( wp_unslash ( $ _SERVER ['REQUEST_URI ' ] ) );
81+ return rtrim ( $ environment_url , '/ ' ) . sanitize_text_field ( wp_unslash ( $ _SERVER ['REQUEST_URI ' ] ) ); // @phpstan-ignore-line argument.type
8082}
8183
8284/**
@@ -122,6 +124,10 @@ function register_admin_bar(): void {
122124
123125 global $ wp_admin_bar ;
124126
127+ if ( ! $ wp_admin_bar instanceof \WP_Admin_Bar ) {
128+ return ;
129+ }
130+
125131 $ wp_admin_bar ->add_menu (
126132 [
127133 'id ' => 'wp-environment-switcher ' ,
@@ -142,7 +148,7 @@ function register_admin_bar(): void {
142148 $ callback = apply_filters ( 'wp_environment_switcher_url_translation ' , __NAMESPACE__ . '\\get_translated_url ' );
143149
144150 // Fire a warning if the translation callback is not callable.
145- if ( ! is_callable ( $ callback ) ) {
151+ if ( ! is_callable ( $ callback ) ) { // @phpstan-ignore-line function.alreadyNarrowedType
146152 _doing_it_wrong (
147153 __FUNCTION__ ,
148154 esc_html__ ( 'The URL translation callback is not callable. ' , 'wp-environment-switcher ' ),
0 commit comments