Skip to content

Commit

Permalink
clean up PHPdoc blocks
Browse files Browse the repository at this point in the history
* consistent use of int/bool over integer/boolean
* consistent indentation of param amd return blocks
* use since tags instead of change, where applicable
* remove redundant change tags
* use version number that actually exist (2.0, 2.3.0, ...)
  • Loading branch information
stklcode committed Nov 20, 2022
1 parent 8c2397f commit 38345db
Show file tree
Hide file tree
Showing 6 changed files with 320 additions and 371 deletions.
57 changes: 26 additions & 31 deletions inc/class-cachify-apc.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ final class Cachify_APC {
/**
* Availability check
*
* @since 2.0.7
* @change 2.0.7
* @return bool TRUE when installed
*
* @return boolean true/false TRUE when installed
* @since 2.0.7
*/
public static function is_available() {
return extension_loaded( 'apc' );
Expand All @@ -28,10 +27,9 @@ public static function is_available() {
/**
* Caching method as string
*
* @since 2.1.2
* @change 2.1.2
* @return string Caching method
*
* @return string Caching method
* @since 2.1.2
*/
public static function stringify_method() {
return 'APC';
Expand All @@ -40,13 +38,13 @@ public static function stringify_method() {
/**
* Store item in cache
*
* @since 2.0
* @change 2.3.0
* @param string $hash Hash of the entry.
* @param string $data Content of the entry.
* @param int $lifetime Lifetime of the entry.
* @param bool $sig_detail Show details in signature.
*
* @param string $hash Hash of the entry.
* @param string $data Content of the entry.
* @param integer $lifetime Lifetime of the entry.
* @param bool $sig_detail Show details in signature.
* @since 2.0
* @since 2.3.0 added $sigDetail parameter
*/
public static function store_item( $hash, $data, $lifetime, $sig_detail ) {
/* Do not store empty data. */
Expand All @@ -66,11 +64,11 @@ public static function store_item( $hash, $data, $lifetime, $sig_detail ) {
/**
* Read item from cache
*
* @since 2.0
* @change 2.0
* @param string $hash Hash of the entry.
*
* @param string $hash Hash of the entry.
* @return mixed Content of the entry
* @return mixed Content of the entry
*
* @since 2.0
*/
public static function get_item( $hash ) {
return ( function_exists( 'apc_exists' ) ? apc_exists( $hash ) : apc_fetch( $hash ) );
Expand All @@ -79,11 +77,10 @@ public static function get_item( $hash ) {
/**
* Delete item from cache
*
* @since 2.0
* @change 2.0
* @param string $hash Hash of the entry.
* @param string $url URL of the entry [optional].
*
* @param string $hash Hash of the entry.
* @param string $url URL of the entry [optional].
* @since 2.0
*/
public static function delete_item( $hash, $url = '' ) {
apc_delete( $hash );
Expand All @@ -92,8 +89,7 @@ public static function delete_item( $hash, $url = '' ) {
/**
* Clear the cache
*
* @since 2.0.0
* @change 2.0.7
* @since 2.0
*/
public static function clear_cache() {
if ( ! self::is_available() ) {
Expand All @@ -106,8 +102,7 @@ public static function clear_cache() {
/**
* Print the cache
*
* @since 2.0
* @change 2.0
* @since 2.0
*/
public static function print_cache() {
return;
Expand All @@ -116,10 +111,9 @@ public static function print_cache() {
/**
* Get the cache size
*
* @since 2.0
* @change 2.0
* @return mixed Cache size
*
* @return mixed Cache size
* @since 2.0
*/
public static function get_stats() {
/* Info */
Expand All @@ -136,11 +130,12 @@ public static function get_stats() {
/**
* Generate signature
*
* @since 2.0
* @change 2.3.0
* @param bool $detail Show details in signature.
*
* @return string Signature string
*
* @param bool $detail Show details in signature.
* @return string Signature string
* @since 2.0
* @since 2.3.0 added $detail parameter
*/
private static function _cache_signature( $detail ) {
return sprintf(
Expand Down
13 changes: 5 additions & 8 deletions inc/class-cachify-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ final class Cachify_CLI {
/**
* Flush Cache Callback
*
* @since 2.3.0
* @change 2.3.0
*
* @param array $args the CLI arguments as array.
* @param array $assoc_args the CLI arguments as associative array.
*
* @since 2.3.0
*/
public static function flush_cache( $args, $assoc_args ) {
// Set default arguments.
Expand All @@ -38,11 +37,10 @@ public static function flush_cache( $args, $assoc_args ) {
/**
* Get cache size
*
* @since 2.3.0
* @change 2.3.0
*
* @param array $args the CLI arguments as array.
* @param array $assoc_args the CLI arguments as associative array.
*
* @since 2.3.0
*/
public static function get_cache_size( $args, $assoc_args ) {
// Set default arguments.
Expand All @@ -62,8 +60,7 @@ public static function get_cache_size( $args, $assoc_args ) {
/**
* Register CLI Commands
*
* @since 2.3.0
* @change 2.3.0
* @since 2.3.0
*/
public static function add_commands() {
// Add flush command.
Expand Down
78 changes: 36 additions & 42 deletions inc/class-cachify-db.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ final class Cachify_DB {
/**
* Availability check
*
* @since 2.0.7
* @change 2.0.7
* @return bool TRUE when installed
*
* @return boolean true/false TRUE when installed
* @since 2.0.7
*/
public static function is_available() {
return true;
Expand All @@ -28,10 +27,9 @@ public static function is_available() {
/**
* Caching method as string
*
* @since 2.1.2
* @change 2.1.2
* @return string Caching method
*
* @return string Caching method
* @since 2.1.2
*/
public static function stringify_method() {
return 'DB';
Expand All @@ -40,17 +38,17 @@ public static function stringify_method() {
/**
* Store item in cache
*
* @since 2.0
* @change 2.0
* @param string $hash Hash of the entry.
* @param string $data Content of the entry.
* @param int $lifetime Lifetime of the entry.
*
* @param string $hash Hash of the entry.
* @param string $data Content of the entry.
* @param integer $lifetime Lifetime of the entry.
* @since 2.0
*/
public static function store_item( $hash, $data, $lifetime ) {
/* Do not store empty data. */
if ( empty( $data ) ) {
trigger_error( __METHOD__ . ': Empty input.', E_USER_WARNING );

return;
}

Expand All @@ -73,11 +71,11 @@ public static function store_item( $hash, $data, $lifetime ) {
/**
* Read item from cache
*
* @since 2.0
* @change 2.0
* @param string $hash Hash of the entry.
*
* @return mixed Content of the entry
*
* @param string $hash Hash of the entry.
* @return mixed Content of the entry
* @since 2.0
*/
public static function get_item( $hash ) {
return get_transient( $hash );
Expand All @@ -86,11 +84,10 @@ public static function get_item( $hash ) {
/**
* Delete item from cache
*
* @since 2.0
* @change 2.0
* @param string $hash Hash of the entry.
* @param string $url URL of the entry [optional].
*
* @param string $hash Hash of the entry.
* @param string $url URL of the entry [optional].
* @since 2.0
*/
public static function delete_item( $hash, $url = '' ) {
delete_transient( $hash );
Expand All @@ -99,8 +96,7 @@ public static function delete_item( $hash, $url = '' ) {
/**
* Clear the cache
*
* @since 2.0
* @change 2.0
* @since 2.0
*/
public static function clear_cache() {
/* Init */
Expand All @@ -113,11 +109,11 @@ public static function clear_cache() {
/**
* Print the cache
*
* @since 2.0
* @change 2.3.0
* @param bool $sig_detail Show details in signature.
* @param array $cache Array of cache values.
*
* @param bool $sig_detail Show details in signature.
* @param array $cache Array of cache values.
* @since 2.0
* @since 2.3.0 added $sig_detail parameter
*/
public static function print_cache( $sig_detail, $cache ) {
/* No array? */
Expand All @@ -141,16 +137,16 @@ public static function print_cache( $sig_detail, $cache ) {
/**
* Get the cache size
*
* @since 2.0
* @change 2.0
* @return int Column size
*
* @return integer Column size
* @since 2.0
*/
public static function get_stats() {
/* Init */
global $wpdb;

/* Read */

return $wpdb->get_var(
'SELECT SUM( CHAR_LENGTH(option_value) ) FROM `' . $wpdb->options . "` WHERE `option_name` LIKE ('\_transient%.cachify')"
);
Expand All @@ -159,12 +155,13 @@ public static function get_stats() {
/**
* Generate signature
*
* @since 2.0
* @change 2.3.0
* @param bool $detail Show details in signature.
* @param array $meta Content of metadata.
*
* @return string Signature string
*
* @param bool $detail Show details in signature.
* @param array $meta Content of metadata.
* @return string Signature string
* @since 2.0
* @since 2.3.0 added $detail parameter
*/
private static function _cache_signature( $detail, $meta ) {
/* No array? */
Expand Down Expand Up @@ -210,10 +207,9 @@ private static function _cache_signature( $detail, $meta ) {
/**
* Return query count
*
* @since 0.1
* @change 2.0
* @return int Number of queries
*
* @return integer Number of queries
* @since 0.1
*/
private static function _page_queries() {
return $GLOBALS['wpdb']->num_queries;
Expand All @@ -222,10 +218,9 @@ private static function _page_queries() {
/**
* Return execution time
*
* @since 0.1
* @change 2.0
* @return int Execution time in seconds
*
* @return integer Execution time in seconds
* @since 0.1
*/
private static function _page_timer() {
return timer_stop( 0, 2 );
Expand All @@ -234,10 +229,9 @@ private static function _page_timer() {
/**
* Return memory consumption
*
* @since 0.7
* @change 2.0
* @return string Formatted memory size
*
* @return string Formatted memory size
* @since 0.7
*/
private static function _page_memory() {
return ( function_exists( 'memory_get_usage' ) ? size_format( memory_get_usage(), 2 ) : 0 );
Expand Down
Loading

0 comments on commit 38345db

Please sign in to comment.