From: Tim Düsterhus Date: Sat, 5 Jan 2013 15:05:07 +0000 (+0100) Subject: Force self:: for own static members X-Git-Tag: 2.0.0_Beta_1~589 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e421b813e71e1079b61fc102a2c819db0969f016;p=GitHub%2FWoltLab%2FWCF.git Force self:: for own static members --- diff --git a/CodeSniff/WCF/ruleset.xml b/CodeSniff/WCF/ruleset.xml index 1cebaefb4e..7f66d7cc19 100644 --- a/CodeSniff/WCF/ruleset.xml +++ b/CodeSniff/WCF/ruleset.xml @@ -20,7 +20,7 @@ - + diff --git a/wcfsetup/install/files/lib/data/package/Package.class.php b/wcfsetup/install/files/lib/data/package/Package.class.php index ff1fd379e0..447bbe1d51 100644 --- a/wcfsetup/install/files/lib/data/package/Package.class.php +++ b/wcfsetup/install/files/lib/data/package/Package.class.php @@ -339,7 +339,7 @@ class Package extends DatabaseObject { $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(WCF_DIR.$package->packageDir)); $file = new File($packageDir.PackageInstallationDispatcher::CONFIG_FILE); $file->write("package)); + $prefix = strtoupper(self::getAbbreviation($package->package)); $file->write("// ".$package->package." (packageID ".$package->packageID.")\n"); $file->write("if (!defined('".$prefix."_DIR')) define('".$prefix."_DIR', dirname(__FILE__).'/');\n"); diff --git a/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php b/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php index 34a4bf4d58..4f201da395 100644 --- a/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php +++ b/wcfsetup/install/files/lib/data/user/group/UserGroup.class.php @@ -269,7 +269,7 @@ class UserGroup extends DatabaseObject { if (!$this->isAccessible()) return false; // cannot delete static groups - if ($this->groupType == UserGroup::EVERYONE || $this->groupType == UserGroup::GUESTS || $this->groupType == UserGroup::USERS) return false; + if ($this->groupType == self::EVERYONE || $this->groupType == self::GUESTS || $this->groupType == self::USERS) return false; return true; } diff --git a/wcfsetup/install/files/lib/data/user/option/UserOption.class.php b/wcfsetup/install/files/lib/data/user/option/UserOption.class.php index 34fb450d87..29d1fe54b1 100644 --- a/wcfsetup/install/files/lib/data/user/option/UserOption.class.php +++ b/wcfsetup/install/files/lib/data/user/option/UserOption.class.php @@ -111,29 +111,29 @@ class UserOption extends Option { */ public function isVisible() { // proceed if option is visible for all - if ($this->visible & UserOption::VISIBILITY_GUEST) { + if ($this->visible & self::VISIBILITY_GUEST) { return true; } // proceed if option is visible for registered users and current user is logged in - if (($this->visible & UserOption::VISIBILITY_REGISTERED) && WCF::getUser()->userID) { + if (($this->visible & self::VISIBILITY_REGISTERED) && WCF::getUser()->userID) { return true; } // check admin permissions - if ($this->visible & UserOption::VISIBILITY_ADMINISTRATOR) { + if ($this->visible & self::VISIBILITY_ADMINISTRATOR) { if (WCF::getSession()->getPermission('admin.general.canViewPrivateUserOptions')) { return true; } } // check owner state - if ($this->visible & UserOption::VISIBILITY_OWNER) { + if ($this->visible & self::VISIBILITY_OWNER) { if ($this->user !== null && $this->user->userID == WCF::getUser()->userID) { return true; } } - + return false; } @@ -144,14 +144,15 @@ class UserOption extends Option { */ public function isEditable() { // check admin permissions - if ($this->editable & UserOption::EDITABILITY_ADMINISTRATOR) { + if ($this->editable & self::EDITABILITY_ADMINISTRATOR) { if (WCF::getSession()->getPermission('admin.general.canViewPrivateUserOptions')) { return true; } } - + // check owner state - if ($this->editable & UserOption::VISIBILITY_OWNER) { + // TODO: Shouldn't this be: EDITABILITY_OWNER? + if ($this->editable & self::VISIBILITY_OWNER) { if ($this->user === null || $this->user->userID == WCF::getUser()->userID) { return true; } diff --git a/wcfsetup/install/files/lib/system/WCF.class.php b/wcfsetup/install/files/lib/system/WCF.class.php index 4b1553bb94..3eb5731529 100644 --- a/wcfsetup/install/files/lib/system/WCF.class.php +++ b/wcfsetup/install/files/lib/system/WCF.class.php @@ -378,10 +378,10 @@ class WCF { */ protected function initStyle() { if (isset($_REQUEST['styleID'])) { - WCF::getSession()->setStyleID(intval($_REQUEST['styleID'])); + self::getSession()->setStyleID(intval($_REQUEST['styleID'])); } - StyleHandler::getInstance()->changeStyle(WCF::getSession()->getStyleID()); + StyleHandler::getInstance()->changeStyle(self::getSession()->getStyleID()); } /** @@ -389,17 +389,17 @@ class WCF { */ protected function initBlacklist() { if (defined('BLACKLIST_IP_ADDRESSES') && BLACKLIST_IP_ADDRESSES != '') { - if (!StringUtil::executeWordFilter(WCF::getSession()->ipAddress, BLACKLIST_IP_ADDRESSES)) { + if (!StringUtil::executeWordFilter(self::getSession()->ipAddress, BLACKLIST_IP_ADDRESSES)) { throw new PermissionDeniedException(); } } if (defined('BLACKLIST_USER_AGENTS') && BLACKLIST_USER_AGENTS != '') { - if (!StringUtil::executeWordFilter(WCF::getSession()->userAgent, BLACKLIST_USER_AGENTS)) { + if (!StringUtil::executeWordFilter(self::getSession()->userAgent, BLACKLIST_USER_AGENTS)) { throw new PermissionDeniedException(); } } if (defined('BLACKLIST_HOSTNAMES') && BLACKLIST_HOSTNAMES != '') { - if (!StringUtil::executeWordFilter(@gethostbyaddr(WCF::getSession()->ipAddress), BLACKLIST_HOSTNAMES)) { + if (!StringUtil::executeWordFilter(@gethostbyaddr(self::getSession()->ipAddress), BLACKLIST_HOSTNAMES)) { throw new PermissionDeniedException(); } } diff --git a/wcfsetup/install/files/lib/system/mail/Mail.class.php b/wcfsetup/install/files/lib/system/mail/Mail.class.php index 288871ca04..fca96a0f1e 100644 --- a/wcfsetup/install/files/lib/system/mail/Mail.class.php +++ b/wcfsetup/install/files/lib/system/mail/Mail.class.php @@ -38,6 +38,7 @@ class Mail { */ protected $body = ''; + // TODO: Should this be a constant? public static $crlf = "\n"; /** @@ -183,7 +184,7 @@ class Mail { */ public static function buildAddress($name, $email, $encodeName = true) { if (!empty($name) && MAIL_USE_FORMATTED_ADDRESS) { - if ($encodeName) $name = Mail::encodeMIMEHeader($name); + if ($encodeName) $name = self::encodeMIMEHeader($name); if (!preg_match('/^[a-z0-9 ]*$/i', $name)) return '"'.str_replace('"', '\"', $name).'" <'.$email.'>'; else return $name . ' <'.$email.'>'; } @@ -453,7 +454,7 @@ class Mail { */ public static function encodeMIMEHeader($string) { if (function_exists('mb_encode_mimeheader')) { - $string = mb_encode_mimeheader($string, 'UTF-8', 'Q', Mail::$crlf); + $string = mb_encode_mimeheader($string, 'UTF-8', 'Q', self::$crlf); } else { $string = '=?UTF-8?Q?'.preg_replace('/[^\r\n]{73}[^=\r\n]{2}/', "$0=\r\n", str_replace("%", "=", str_replace("%0D%0A", "\r\n", str_replace("%20", " ", rawurlencode($string))))).'?='; diff --git a/wcfsetup/install/files/lib/util/FileUtil.class.php b/wcfsetup/install/files/lib/util/FileUtil.class.php index ea772818d3..c282a4af78 100644 --- a/wcfsetup/install/files/lib/util/FileUtil.class.php +++ b/wcfsetup/install/files/lib/util/FileUtil.class.php @@ -458,7 +458,7 @@ final class FileUtil { // detect the UTF-8 BOM. if (($workArray['1'] == $firstByte) && ($workArray['2'] == $secondByte) && ($workArray['3'] == $thirdByte)) { - $tmpname = FileUtil::getTemporaryFilename('stripBoms_'); + $tmpname = self::getTemporaryFilename('stripBoms_'); $tmpStream = fopen($tmpname, 'w+'); fwrite($tmpStream, $sourceContent); rewind($tmpStream); diff --git a/wcfsetup/install/files/lib/util/StringUtil.class.php b/wcfsetup/install/files/lib/util/StringUtil.class.php index f2511f764b..4add58c760 100644 --- a/wcfsetup/install/files/lib/util/StringUtil.class.php +++ b/wcfsetup/install/files/lib/util/StringUtil.class.php @@ -91,16 +91,16 @@ final class StringUtil { if (is_object($string)) $string = $string->__toString(); // escape backslash - $string = StringUtil::replace("\\", "\\\\", $string); + $string = self::replace("\\", "\\\\", $string); // escape singe quote - $string = StringUtil::replace("'", "\'", $string); + $string = self::replace("'", "\'", $string); // escape new lines - $string = StringUtil::replace("\n", '\n', $string); + $string = self::replace("\n", '\n', $string); // escape slashes - $string = StringUtil::replace("/", '\/', $string); + $string = self::replace("/", '\/', $string); return $string; } @@ -406,9 +406,9 @@ final class StringUtil { */ public static function encodeAllChars($string) { $result = ''; - for ($i = 0, $j = StringUtil::length($string); $i < $j; $i++) { - $char = StringUtil::substring($string, $i, 1); - $result .= '&#'.StringUtil::getCharValue($char).';'; + for ($i = 0, $j = self::length($string); $i < $j; $i++) { + $char = self::substring($string, $i, 1); + $result .= '&#'.self::getCharValue($char).';'; } return $result; @@ -529,7 +529,7 @@ final class StringUtil { * @param boolean $breakWords should words be broken in the middle * @return string */ - public static function truncate($string, $length = 80, $etc = StringUtil::HELLIP, $breakWords = false) { + public static function truncate($string, $length = 80, $etc = self::HELLIP, $breakWords = false) { if ($length == 0) { return ''; } @@ -557,15 +557,15 @@ final class StringUtil { * @param string $etc ending string which will be appended after truncating * @return string truncated string */ - public static function truncateHTML($string, $length = 500, $wordWrap = true, $etc = StringUtil::HELLIP) { - if (StringUtil::length(StringUtil::stripHTML($string)) <= $length) { + public static function truncateHTML($string, $length = 500, $wordWrap = true, $etc = self::HELLIP) { + if (self::length(self::stripHTML($string)) <= $length) { return $string; } $openTags = array(); $truncatedString = ''; // initalize length counter with the ending length - $totalLength = StringUtil::length($etc); + $totalLength = self::length($etc); preg_match_all('/(<\/?([\w+]+)[^>]*>)?([^<>]*)/', $string, $tags, PREG_SET_ORDER); @@ -591,7 +591,7 @@ final class StringUtil { $truncatedString .= $tag[1]; // get length of the content without entities. If the content is too long, keep entities intact - $contentLength = StringUtil::length(StringUtil::decodeHTML($tag[3])); + $contentLength = self::length(self::decodeHTML($tag[3])); if ($contentLength + $totalLength > $length) { $left = $length - $totalLength; $entitiesLength = 0; @@ -599,14 +599,14 @@ final class StringUtil { foreach ($entities[0] as $entity) { if ($entity[1] + 1 - $entitiesLength <= $left) { $left--; - $entitiesLength += StringUtil::length($entity[0]); + $entitiesLength += self::length($entity[0]); } else { break; } } } - $truncatedString .= StringUtil::substring($tag[3], 0, $left + $entitiesLength); + $truncatedString .= self::substring($tag[3], 0, $left + $entitiesLength); break; } else { @@ -620,23 +620,23 @@ final class StringUtil { // if word wrap is active search for the last word change if ($wordWrap) { - $lastWhitespace = StringUtil::lastIndexOf($truncatedString, ' '); + $lastWhitespace = self::lastIndexOf($truncatedString, ' '); // check if inside a tag - $lastOpeningTag = StringUtil::lastIndexOf($truncatedString, '<'); + $lastOpeningTag = self::lastIndexOf($truncatedString, '<'); if ($lastOpeningTag < $lastWhitespace) { - $lastClosingTag = StringUtil::lastIndexOf($truncatedString, '>'); + $lastClosingTag = self::lastIndexOf($truncatedString, '>'); if (($lastClosingTag === false || $lastClosingTag > $lastWhitespace) && $lastClosingTag > $lastOpeningTag) { $lastWhitespace = $lastOpeningTag; array_shift($openTags); if ($truncatedString[$lastWhitespace] != ' ') { - $firstPart = StringUtil::substring($truncatedString, 0, $lastWhitespace); - $secondPart = StringUtil::substring($truncatedString, $lastWhitespace + 1); + $firstPart = self::substring($truncatedString, 0, $lastWhitespace); + $secondPart = self::substring($truncatedString, $lastWhitespace + 1); $truncatedString = $firstPart.' '.$secondPart; } } } if ($lastWhitespace !== false) { - $endString = StringUtil::substring($truncatedString, $lastWhitespace); + $endString = self::substring($truncatedString, $lastWhitespace); preg_match_all('/<\/([a-z]+)>/', $endString, $tagOverhead, PREG_SET_ORDER); if (count($tagOverhead)) { foreach ($tagOverhead as $tag) { @@ -645,7 +645,7 @@ final class StringUtil { } } } - $truncatedString = StringUtil::substring($truncatedString, 0, $lastWhitespace); + $truncatedString = self::substring($truncatedString, 0, $lastWhitespace); } }