Skip to content

Commit

Permalink
fix PHPDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
luizbills authored Dec 5, 2024
1 parent ba3dff5 commit b5cab8a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion core/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static function get ( $key, $default = null ) {
}

/**
* @return positive-int
* @return int<0, max>
*/
public static function get_size () {
return count( self::$values );
Expand Down
17 changes: 10 additions & 7 deletions core/Dependencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function maybe_start_plugin () {
}

/**
* @return array{success: bool, messages: string[]} The result
* @return array{success: bool, messages: array<int, array{text: string, is_error: bool}>}
* @throws \Exception
*/
public static function check_dependencies () {
Expand Down Expand Up @@ -124,28 +124,31 @@ protected static function handle_shortcut ( $shortcut ) {
}

/**
* @param string[] $messages
* @param array<int, array{text:string, is_error:bool}> $messages
* @return void
*/
protected static function display_notice_missing_deps ( $messages ) {
if ( ! \is_admin() ) return;
if ( ! \current_user_can( 'install_plugins' ) ) return;
if ( 0 === count( $messages ) ) return;

\usort( $messages, function ( $a, $b ) {
return $b['is_error'] <=> $a['is_error'];
} );
\usort(
$messages,
function ( $a, $b ) {
return $b['is_error'] <=> $a['is_error'];
}
);

\add_action( 'admin_notices', function () use ( $messages ) {
echo "<div class='notice notice-error'><p>";
echo sprintf(
/* translators: %s is replaced with plugin name */
__( 'The %s plugin needs the following dependencies to work:', 'your_text_domain' ),
__( 'The %s plugin needs the following dependencies to work:', 'wc-shipping-simulator' ),
"<strong>" . Config::get( 'NAME' ) . "</strong>",
);

$indent = \str_repeat( '&nbsp;', 4 );
$missing = esc_html__( 'Missing', 'your_text_domain' );
$missing = esc_html__( 'Missing', 'wc-shipping-simulator' );
$allowed_html = [
'a' => [ 'href' => [], 'target' => [] ],
'span' => [ 'class' => [], 'style' => [] ],
Expand Down
2 changes: 1 addition & 1 deletion core/Traits/Debug_Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ trait Debug_Helpers {
* Dump and die
*
* @param mixed ...$values
* @return null|never
* @return void|never
*/
public static function dd ( ...$values ) {
if ( ! WP_DEBUG ) return;
Expand Down
4 changes: 2 additions & 2 deletions core/Traits/String_Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ trait String_Helpers {
/**
* @param string $string
* @param string $encoding
* @return string
* @return int<0, max>
*/
public static function str_length ( $string, $encoding = 'UTF-8' ) {
return \mb_strlen( $string, $encoding );
Expand All @@ -34,7 +34,7 @@ public static function str_upper ( $string, $encoding = 'UTF-8' ) {
/**
* @param string $string
* @param string $encoding
* @return string
* @return bool
*/
public static function str_contains ( $string, $search, $encoding = 'UTF-8' ) {
return $search !== '' && mb_strpos( $string, $search, 0, $encoding ) !== false;
Expand Down
2 changes: 1 addition & 1 deletion core/Traits/Throw_Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static function get_error_class () {
* If the condition is falsy, throws a Exception.
*
* @param bool $condition
* @param string $message
* @param callable|mixed $message
* @param \Throwable|null $exception_class
* @return void
* @throws \Throwable
Expand Down
2 changes: 1 addition & 1 deletion core/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.0.1

0 comments on commit b5cab8a

Please sign in to comment.