Skip to content

Commit

Permalink
Merge pull request #1627 from adamsilverstein/fix/phpstan
Browse files Browse the repository at this point in the history
Fix phpstan errors
  • Loading branch information
westonruter authored Nov 5, 2024
2 parents 01504c5 + 0d4511b commit ce2880d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions plugins/embed-optimizer/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ function embed_optimizer_update_markup( WP_HTML_Tag_Processor $html_processor, b
'script' => 'embed_optimizer_script',
'iframe' => 'embed_optimizer_iframe',
);
$trigger_error = static function ( string $message ): void {
wp_trigger_error( __FUNCTION__, esc_html( $message ) );
$function_name = __FUNCTION__;
$trigger_error = static function ( string $message ) use ( $function_name ): void {
wp_trigger_error( $function_name, esc_html( $message ) );
};
try {
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ public function get_updated_html(): string {
*
* @since 0.4.0
*
* @phpstan-param callable-string $function_name
*
* @param string $function_name Function name.
* @param string $message Warning message.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ public static function get_post( string $slug ): ?WP_Post {
public static function get_url_metrics_from_post( WP_Post $post ): array {
$this_function = __METHOD__;
$trigger_error = static function ( string $message, int $error_level = E_USER_NOTICE ) use ( $this_function ): void {
// Default to E_USER_NOTICE.
if ( ! in_array( $error_level, array( E_USER_NOTICE, E_USER_WARNING, E_USER_ERROR, E_USER_DEPRECATED ), true ) ) {
$error_level = E_USER_NOTICE;
}
wp_trigger_error( $this_function, esc_html( $message ), $error_level );
};

Expand Down

0 comments on commit ce2880d

Please sign in to comment.