From e37c5cb9d08b36f9b95d622983d832669d3b9a5d Mon Sep 17 00:00:00 2001 From: jgen Date: Mon, 28 Apr 2014 02:23:45 -0400 Subject: [PATCH] More linting! --- core/imageboard.pack.php | 3 +++ ext/artists/main.php | 26 ++++++++++++++++++++------ ext/setup/main.php | 6 +++++- ext/shimmie_api/main.php | 2 +- ext/tag_editcloud/main.php | 18 +++++++++--------- ext/tag_history/main.php | 8 ++++---- ext/upload/main.php | 1 - 7 files changed, 42 insertions(+), 22 deletions(-) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index 3e90c199..6b1d6764 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -58,6 +58,9 @@ class Image { /** @var string */ public $ext; + /** @var string[]|null */ + public $tag_array; + public $owner_id, $owner_ip; public $posted, $posted_timestamp; public $source; diff --git a/ext/artists/main.php b/ext/artists/main.php index 43edec08..7bb6238b 100644 --- a/ext/artists/main.php +++ b/ext/artists/main.php @@ -9,9 +9,19 @@ * */ class AuthorSetEvent extends Event { - var $image, $user, $author; + /** @var \Image */ + public $image; + /** @var \User */ + public $user; + /** @var string */ + public $author; - public function __construct(Image $image, User $user, /*string*/ $author) + /** + * @param Image $image + * @param User $user + * @param string $author + */ + public function __construct(Image $image, User $user, /*string*/ $author) { $this->image = $image; $this->user = $user; @@ -937,9 +947,12 @@ class Artists extends Extension { return $result; } - /* - * HERE WE GET THE ID OF THE ARTIST - */ + /** + * HERE WE GET THE ID OF THE ARTIST. + * + * @param string $name + * @return string|int + */ private function get_artist_id($name){ global $database; $artistID = $database->get_row("SELECT id FROM artists WHERE name = ?" @@ -1203,7 +1216,8 @@ class Artists extends Extension { /* * HERE WE GET THE INFO OF THE ALIAS */ - private function get_alias($artistID){ + private function get_alias($artistID) + { if (!is_numeric($artistID)) return; global $database; diff --git a/ext/setup/main.php b/ext/setup/main.php index 70b94e96..cf2f9fdc 100644 --- a/ext/setup/main.php +++ b/ext/setup/main.php @@ -12,8 +12,12 @@ * activated; new config options are in $_POST */ class ConfigSaveEvent extends Event { - var $config; + /** @var \Config */ + public $config; + /** + * @param Config $config + */ public function __construct(Config $config) { $this->config = $config; } diff --git a/ext/shimmie_api/main.php b/ext/shimmie_api/main.php index 0ea29ead..7e426288 100644 --- a/ext/shimmie_api/main.php +++ b/ext/shimmie_api/main.php @@ -42,7 +42,7 @@ class _SafeImage { $this->posted = $img->posted_timestamp; $this->source = $img->source; $this->owner_id = $img->owner_id; - $this->tags = $img->tag_array; + $this->tags = $img->get_tag_array(); } } diff --git a/ext/tag_editcloud/main.php b/ext/tag_editcloud/main.php index 31ef1248..24646be6 100644 --- a/ext/tag_editcloud/main.php +++ b/ext/tag_editcloud/main.php @@ -122,15 +122,15 @@ class TagEditCloud extends Extension { $size = sprintf("%.2f", max($row['scaled'],0.5)); $js = htmlspecialchars('tageditcloud_toggle_tag(this,'.json_encode($full_tag).')',ENT_QUOTES); //Ugly, but it works - if(array_search($row['tag'],$image->tag_array) !== FALSE) { + if(array_search($row['tag'],$image->get_tag_array()) !== FALSE) { if($used_first) { - $precloud .= " $h_tag \n"; + $precloud .= " {$h_tag} \n"; continue; } else { - $entry = " $h_tag \n"; + $entry = " {$h_tag} \n"; } } else { - $entry = " $h_tag \n"; + $entry = " {$h_tag} \n"; } if($counter++ <= $def_count) { @@ -141,21 +141,21 @@ class TagEditCloud extends Extension { } if($precloud != '') { - $html .= "
$precloud
"; + $html .= "
{$precloud}
"; } if($postcloud != '') { - $postcloud = ""; + $postcloud = ""; } - $html .= "
$cloud$postcloud
"; + $html .= "
{$cloud}{$postcloud}
"; if($sort_method != 'a' && $counter > $def_count) { $rem = $counter - $def_count; - $html .= "
[show $rem more tags]"; + $html .= "
[show {$rem} more tags]"; } - return "
$html
"; // FIXME: stupidasallhell + return "
{$html}
"; // FIXME: stupidasallhell } /** diff --git a/ext/tag_history/main.php b/ext/tag_history/main.php index c68fa501..eefc3165 100644 --- a/ext/tag_history/main.php +++ b/ext/tag_history/main.php @@ -347,7 +347,7 @@ class Tag_History extends Extension { * This function is called just before an images tag are changed. * * @param Image $image - * @param null|string|string[] $tags + * @param string|string[] $tags */ private function add_tag_history(Image $image, $tags) { global $database, $config, $user; @@ -355,7 +355,7 @@ class Tag_History extends Extension { $new_tags = Tag::implode($tags); $old_tags = Tag::implode($image->get_tag_array()); - if($new_tags == $old_tags) return; + if($new_tags == $old_tags) { return; } if(empty($old_tags)) { /* no old tags, so we are probably adding the image for the first time */ @@ -366,7 +366,7 @@ class Tag_History extends Extension { } $allowed = $config->get_int("history_limit"); - if($allowed == 0) return; + if($allowed == 0) { return; } // if the image has no history, make one with the old tags $entries = $database->get_one("SELECT COUNT(*) FROM tag_histories WHERE image_id = ?", array($image->id)); @@ -386,7 +386,7 @@ class Tag_History extends Extension { $entries++; // if needed remove oldest one - if($allowed == -1) return; + if($allowed == -1) { return; } if($entries > $allowed) { // TODO: Make these queries better /* diff --git a/ext/upload/main.php b/ext/upload/main.php index 69a226ba..48f79ec4 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -376,7 +376,6 @@ class Upload extends Extension { "No data found -- perhaps the site has hotlink protection?"); $ok = false; }else{ - global $user; $pathinfo = pathinfo($url); $metadata = array(); $metadata['filename'] = $filename;