more explicit variable types

This commit is contained in:
Shish 2016-06-19 23:05:57 +01:00
parent f8b7909426
commit 6febdec7b5
26 changed files with 61 additions and 57 deletions

View file

@ -151,7 +151,7 @@ interface Config {
* left to the concrete implementation * left to the concrete implementation
*/ */
abstract class BaseConfig implements Config { abstract class BaseConfig implements Config {
var $values = array(); public $values = array();
/** /**
* @param string $name * @param string $name
@ -366,8 +366,8 @@ class StaticConfig extends BaseConfig {
* \endcode * \endcode
*/ */
class DatabaseConfig extends BaseConfig { class DatabaseConfig extends BaseConfig {
/** @var \Database|null */ /** @var Database */
var $database = null; private $database = null;
/** /**
* Load the config table from a database. * Load the config table from a database.

View file

@ -357,7 +357,7 @@ class MemcacheCache implements CacheEngine {
} }
class APCCache implements CacheEngine { class APCCache implements CacheEngine {
var $hits=0, $misses=0; public $hits=0, $misses=0;
public function __construct($args) { public function __construct($args) {
// $args is not used, but is passed in when APC cache is created. // $args is not used, but is passed in when APC cache is created.
@ -755,11 +755,11 @@ class Database {
class MockDatabase extends Database { class MockDatabase extends Database {
/** @var int */ /** @var int */
var $query_id = 0; private $query_id = 0;
/** @var array */ /** @var array */
var $responses = array(); private $responses = array();
/** @var \NoCache|null */ /** @var \NoCache|null */
var $cache = null; public $cache = null;
/** /**
* @param array $responses * @param array $responses

View file

@ -88,15 +88,11 @@ abstract class Extension {
/** this theme's Themelet object */ /** this theme's Themelet object */
public $theme; public $theme;
/** @private */
var $_child;
// in PHP5.3, late static bindings can take care of this; __CLASS__ // in PHP5.3, late static bindings can take care of this; __CLASS__
// used here will refer to the subclass // used here will refer to the subclass
// http://php.net/manual/en/language.oop5.late-static-bindings.php // http://php.net/manual/en/language.oop5.late-static-bindings.php
/** @private */ /** @private */
public function i_am(Extension $child) { public function i_am(Extension $child) {
$this->_child = $child;
if(is_null($this->theme)) $this->theme = $this->get_theme_object($child, false); if(is_null($this->theme)) $this->theme = $this->get_theme_object($child, false);
} }

View file

@ -1,7 +1,7 @@
<?php <?php
class BulkAddTheme extends Themelet { class BulkAddTheme extends Themelet {
var $messages = array(); private $messages = array();
/* /*
* Show a standard page for results to be put into * Show a standard page for results to be put into

View file

@ -1,7 +1,7 @@
<?php <?php
class BulkAddCSVTheme extends Themelet { class BulkAddCSVTheme extends Themelet {
var $messages = array(); private $messages = array();
/* /*
* Show a standard page for results to be put into * Show a standard page for results to be put into

View file

@ -53,9 +53,9 @@ class CommentDeletionEvent extends Event {
class CommentPostingException extends SCoreException {} class CommentPostingException extends SCoreException {}
class Comment { class Comment {
var $owner, $owner_id, $owner_name, $owner_email, $owner_class; public $owner, $owner_id, $owner_name, $owner_email, $owner_class;
var $comment, $comment_id; public $comment, $comment_id;
var $image_id, $poster_ip, $posted; public $image_id, $poster_ip, $posted;
public function __construct($row) { public function __construct($row) {
$this->owner = null; $this->owner = null;
@ -94,7 +94,7 @@ class Comment {
class CommentList extends Extension { class CommentList extends Extension {
/** @var CommentListTheme $theme */ /** @var CommentListTheme $theme */
var $theme; public $theme;
public function onInitExt(InitExtEvent $event) { public function onInitExt(InitExtEvent $event) {
global $config, $database; global $config, $database;

View file

@ -1,11 +1,11 @@
<?php <?php
class CommentListTheme extends Themelet { class CommentListTheme extends Themelet {
var $comments_shown = 0; private $comments_shown = 0;
var $show_anon_id = false; private $show_anon_id = false;
var $anon_id = 1; private $anon_id = 1;
var $anon_cid = 0; private $anon_cid = 0;
var $anon_map = array(); private $anon_map = array();
var $ct = null; private $ct = null;
private function get_anon_colour($ip) { private function get_anon_colour($ip) {
if(is_null($this->ct)) { if(is_null($this->ct)) {

View file

@ -18,9 +18,9 @@ function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b) {
} }
class ExtensionInfo { class ExtensionInfo {
var $ext_name, $name, $link, $author, $email; public $ext_name, $name, $link, $author, $email;
var $description, $documentation, $version, $visibility; public $description, $documentation, $version, $visibility;
var $enabled; public $enabled;
public function __construct($main) { public function __construct($main) {
$matches = array(); $matches = array();

View file

@ -12,8 +12,10 @@
* An image is being added to the database. * An image is being added to the database.
*/ */
class ImageAdditionEvent extends Event { class ImageAdditionEvent extends Event {
var $user; /** @var User */
/** @var \Image */ public $user;
/** @var Image */
public $image; public $image;
/** /**
@ -30,7 +32,7 @@ class ImageAdditionEvent extends Event {
} }
class ImageAdditionException extends SCoreException { class ImageAdditionException extends SCoreException {
var $error; public $error;
/** /**
* @param string $error * @param string $error

View file

@ -11,7 +11,7 @@
// RemoveImageHashBanEvent {{{ // RemoveImageHashBanEvent {{{
class RemoveImageHashBanEvent extends Event { class RemoveImageHashBanEvent extends Event {
var $hash; public $hash;
/** /**
* @param string $hash * @param string $hash
@ -23,8 +23,8 @@ class RemoveImageHashBanEvent extends Event {
// }}} // }}}
// AddImageHashBanEvent {{{ // AddImageHashBanEvent {{{
class AddImageHashBanEvent extends Event { class AddImageHashBanEvent extends Event {
var $hash; public $hash;
var $reason; public $reason;
/** /**
* @param string $hash * @param string $hash

View file

@ -225,7 +225,7 @@ class PostListBuildingEvent extends Event {
} }
class Index extends Extension { class Index extends Extension {
var $stpen = 0; // search term parse event number private $stpen = 0; // search term parse event number
public function onInitExt(InitExtEvent $event) { public function onInitExt(InitExtEvent $event) {
global $config; global $config;

View file

@ -1,7 +1,7 @@
<?php <?php
class IndexTheme extends Themelet { class IndexTheme extends Themelet {
var $page_number, $total_pages, $search_terms; private $page_number, $total_pages, $search_terms;
/** /**
* @param int $page_number * @param int $page_number

View file

@ -14,7 +14,7 @@
// RemoveIPBanEvent {{{ // RemoveIPBanEvent {{{
class RemoveIPBanEvent extends Event { class RemoveIPBanEvent extends Event {
var $id; public $id;
public function __construct($id) { public function __construct($id) {
$this->id = $id; $this->id = $id;
@ -23,9 +23,9 @@ class RemoveIPBanEvent extends Event {
// }}} // }}}
// AddIPBanEvent {{{ // AddIPBanEvent {{{
class AddIPBanEvent extends Event { class AddIPBanEvent extends Event {
var $ip; public $ip;
var $reason; public $reason;
var $end; public $end;
public function __construct(/*string(ip)*/ $ip, /*string*/ $reason, /*string*/ $end) { public function __construct(/*string(ip)*/ $ip, /*string*/ $reason, /*string*/ $end) {
$this->ip = trim($ip); $this->ip = trim($ip);

View file

@ -8,7 +8,7 @@
*/ */
class LogNet extends Extension { class LogNet extends Extension {
var $count = 0; private $count = 0;
public function onLog(LogEvent $event) { public function onLog(LogEvent $event) {
global $user; global $user;

View file

@ -11,7 +11,7 @@
*/ */
class NumericScoreSetEvent extends Event { class NumericScoreSetEvent extends Event {
var $image_id, $user, $score; public $image_id, $user, $score;
/** /**
* @param int $image_id * @param int $image_id

View file

@ -11,7 +11,7 @@
*/ */
class SendPMEvent extends Event { class SendPMEvent extends Event {
var $pm; public $pm;
public function __construct(PM $pm) { public function __construct(PM $pm) {
$this->pm = $pm; $this->pm = $pm;
@ -19,7 +19,7 @@ class SendPMEvent extends Event {
} }
class PM { class PM {
var $id, $from_id, $from_ip, $to_id, $sent_date, $subject, $message, $is_read; public $id, $from_id, $from_ip, $to_id, $sent_date, $subject, $message, $is_read;
public function __construct($from_id=0, $from_ip="0.0.0.0", $to_id=0, $subject="A Message", $message="Some Text", $read=False) { public function __construct($from_id=0, $from_ip="0.0.0.0", $to_id=0, $subject="A Message", $message="Some Text", $read=False) {
# PHP: the P stands for "really", the H stands for "awful" and the other P stands for "language" # PHP: the P stands for "really", the H stands for "awful" and the other P stands for "language"

View file

@ -16,7 +16,7 @@
* This class is just a wrapper around SCoreException. * This class is just a wrapper around SCoreException.
*/ */
class ImageResizeException extends SCoreException { class ImageResizeException extends SCoreException {
var $error; public $error;
/** @param string $error */ /** @param string $error */
public function __construct($error) { public function __construct($error) {

View file

@ -1,6 +1,6 @@
<?php <?php
class Source_HistoryTheme extends Themelet { class Source_HistoryTheme extends Themelet {
var $messages = array(); private $messages = array();
/** /**
* @param Page $page * @param Page $page

View file

@ -1,8 +1,8 @@
<?php <?php
class TagCategoriesTheme extends Themelet { class TagCategoriesTheme extends Themelet {
var $heading = ""; private $heading = "";
var $list = ""; private $list = "";
public function show_tag_categories($page, $tc_dict) { public function show_tag_categories($page, $tc_dict) {
$tc_block_index = 0; $tc_block_index = 0;

View file

@ -5,7 +5,7 @@
*/ */
class Tag_HistoryTheme extends Themelet { class Tag_HistoryTheme extends Themelet {
var $messages = array(); private $messages = array();
/** /**
* @param Page $page * @param Page $page

View file

@ -1,6 +1,6 @@
<?php <?php
class TagListTest extends ShimmiePHPUnitTestCase { class TagListTest extends ShimmiePHPUnitTestCase {
var $pages = array("map", "alphabetic", "popularity", "categories"); private $pages = array("map", "alphabetic", "popularity", "categories");
public function testTagList() { public function testTagList() {
$this->get_page('tags/map'); $this->get_page('tags/map');

View file

@ -81,7 +81,7 @@ class NullUserException extends SCoreException {}
class UserPage extends Extension { class UserPage extends Extension {
/** @var UserPageTheme $theme */ /** @var UserPageTheme $theme */
var $theme; public $theme;
public function onInitExt(InitExtEvent $event) { public function onInitExt(InitExtEvent $event) {
global $config; global $config;

View file

@ -74,8 +74,8 @@ class ImageInfoSetEvent extends Event {
} }
class ImageAdminBlockBuildingEvent extends Event { class ImageAdminBlockBuildingEvent extends Event {
/** @var array */ /** @var string[] */
var $parts = array(); public $parts = array();
/** @var \Image|null */ /** @var \Image|null */
public $image = null; public $image = null;
/** @var null|\User */ /** @var null|\User */

View file

@ -31,14 +31,20 @@ class WikiPage {
/** @var int|string */ /** @var int|string */
public $id; public $id;
var $owner_id; /** @var int */
var $owner_ip; public $owner_id;
var $date;
/** @var string */
public $owner_ip;
/** @var string */
public $date;
/** @var string */ /** @var string */
public $title; public $title;
var $revision; /** @var int */
public $revision;
/** @var bool */ /** @var bool */
public $locked; public $locked;

View file

@ -1,7 +1,7 @@
<?php <?php
class CustomPage extends Page { class CustomPage extends Page {
var $left_enabled = true; public $left_enabled = true;
public function disable_left() { public function disable_left() {
$this->left_enabled = false; $this->left_enabled = false;
} }

View file

@ -1,7 +1,7 @@
<?php <?php
class CustomPage extends Page { class CustomPage extends Page {
var $left_enabled = true; public $left_enabled = true;
public function disable_left() { public function disable_left() {
$this->left_enabled = false; $this->left_enabled = false;
} }