From 72aac25f68facba0a005c2c4352d5d63111cc477 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Mon, 15 Aug 2016 16:45:47 +0200 Subject: [PATCH] added configuration for PHP Coding Standards Fixer, including its fixes, resolving #47 --- .gitattributes | 1 + .php_cs | 23 +++++++++ lib/Configuration.php | 2 +- lib/Data/Database.php | 62 ++++++++++++------------- lib/Data/Filesystem.php | 20 ++++---- lib/Filter.php | 2 +- lib/I18n.php | 12 ++--- lib/Json.php | 2 +- lib/Model/AbstractModel.php | 6 +-- lib/Model/Comment.php | 8 ++-- lib/Model/Paste.php | 16 +++---- lib/Persistence/AbstractPersistence.php | 2 +- lib/Persistence/PurgeLimiter.php | 4 +- lib/Persistence/TrafficLimiter.php | 4 +- lib/PrivateBin.php | 20 ++++---- lib/Request.php | 4 +- lib/Vizhash16x16.php | 16 +++---- 17 files changed, 114 insertions(+), 90 deletions(-) create mode 100644 .php_cs diff --git a/.gitattributes b/.gitattributes index 9c8fa78..345f98d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,4 +8,5 @@ tst/ export-ignore .gitattributes export-ignore .github export-ignore .gitignore export-ignore +.php_cs export-ignore .travis.yml export-ignore diff --git a/.php_cs b/.php_cs new file mode 100644 index 0000000..9dc9322 --- /dev/null +++ b/.php_cs @@ -0,0 +1,23 @@ +in('lib') +; + +return Symfony\CS\Config\Config::create() + ->level(Symfony\CS\FixerInterface::PSR2_LEVEL) + ->fixers(['concat_with_spaces', 'long_array_syntax', 'standardize_not_equal', + 'operators_spaces', 'duplicate_semicolon', + 'remove_leading_slash_use', 'align_equals', + 'single_array_no_trailing_comma', 'phpdoc_indent', 'phpdoc_scalar', + 'phpdoc_to_comment', 'phpdoc_trim', + 'phpdoc_types', 'print_to_echo', 'self_accessor', 'single_quote', + 'spaces_cast', 'ternary_spaces', 'phpdoc_order']) + ->finder($finder) +; diff --git a/lib/Configuration.php b/lib/Configuration.php index 9d979eb..2ca46b4 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -98,7 +98,7 @@ class Configuration */ public function __construct() { - $config = array(); + $config = array(); $configFile = PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini'; if (is_readable($configFile)) { $config = parse_ini_file($configFile, true); diff --git a/lib/Data/Database.php b/lib/Data/Database.php index d774439..95fa47f 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -71,7 +71,7 @@ class Database extends AbstractData public static function getInstance($options = null) { // if needed initialize the singleton - if (!(self::$_instance instanceof Database)) { + if (!(self::$_instance instanceof self)) { self::$_instance = new self; } @@ -89,17 +89,17 @@ class Database extends AbstractData array_key_exists('opt', $options) ) { // set default options - $options['opt'][PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; + $options['opt'][PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; $options['opt'][PDO::ATTR_EMULATE_PREPARES] = false; - $options['opt'][PDO::ATTR_PERSISTENT] = true; - $db_tables_exist = true; + $options['opt'][PDO::ATTR_PERSISTENT] = true; + $db_tables_exist = true; // setup type and dabase connection self::$_type = strtolower( substr($options['dsn'], 0, strpos($options['dsn'], ':')) ); $tableQuery = self::_getTableQuery(self::$_type); - self::$_db = new PDO( + self::$_db = new PDO( $options['dsn'], $options['usr'], $options['pwd'], @@ -168,8 +168,8 @@ class Database extends AbstractData } $opendiscussion = $burnafterreading = false; - $attachment = $attachmentname = ''; - $meta = $paste['meta']; + $attachment = $attachmentname = ''; + $meta = $paste['meta']; unset($meta['postdate']); $expire_date = 0; if (array_key_exists('expire_date', $paste['meta'])) { @@ -222,14 +222,14 @@ class Database extends AbstractData !array_key_exists($pasteid, self::$_cache) ) { self::$_cache[$pasteid] = false; - $paste = self::_select( + $paste = self::_select( 'SELECT * FROM ' . self::_sanitizeIdentifier('paste') . ' WHERE dataid = ?', array($pasteid), true ); if (false !== $paste) { // create object - self::$_cache[$pasteid] = new stdClass; + self::$_cache[$pasteid] = new stdClass; self::$_cache[$pasteid]->data = $paste['data']; $meta = json_decode($paste['meta']); @@ -253,9 +253,9 @@ class Database extends AbstractData self::$_cache[$pasteid]->attachmentname = $paste['attachmentname']; } } - self::$_cache[$pasteid]->meta = $meta; + self::$_cache[$pasteid]->meta = $meta; self::$_cache[$pasteid]->meta->postdate = (int) $paste['postdate']; - $expire_date = (int) $paste['expiredate']; + $expire_date = (int) $paste['expiredate']; if ( $expire_date > 0 ) { @@ -368,12 +368,12 @@ class Database extends AbstractData $comments = array(); if (count($rows)) { foreach ($rows as $row) { - $i = $this->getOpenSlot($comments, (int) $row['postdate']); - $comments[$i] = new stdClass; - $comments[$i]->id = $row['dataid']; - $comments[$i]->parentid = $row['parentid']; - $comments[$i]->data = $row['data']; - $comments[$i]->meta = new stdClass; + $i = $this->getOpenSlot($comments, (int) $row['postdate']); + $comments[$i] = new stdClass; + $comments[$i]->id = $row['dataid']; + $comments[$i]->parentid = $row['parentid']; + $comments[$i]->data = $row['data']; + $comments[$i]->meta = new stdClass; $comments[$i]->meta->postdate = (int) $row['postdate']; if (array_key_exists('nickname', $row) && !empty($row['nickname'])) { $comments[$i]->meta->nickname = $row['nickname']; @@ -415,7 +415,7 @@ class Database extends AbstractData protected function _getExpiredPastes($batchsize) { $pastes = array(); - $rows = self::_select( + $rows = self::_select( 'SELECT dataid FROM ' . self::_sanitizeIdentifier('paste') . ' WHERE expiredate < ? LIMIT ?', array(time(), $batchsize) ); @@ -440,7 +440,7 @@ class Database extends AbstractData private static function _exec($sql, array $params) { $statement = self::$_db->prepare($sql); - $result = $statement->execute($params); + $result = $statement->execute($params); $statement->closeCursor(); return $result; } @@ -486,7 +486,7 @@ class Database extends AbstractData $sql = 'SELECT tabname FROM systables '; break; case 'mssql': - $sql = "SELECT name FROM sysobjects " + $sql = 'SELECT name FROM sysobjects ' . "WHERE type = 'U' ORDER BY name"; break; case 'mysql': @@ -496,22 +496,22 @@ class Database extends AbstractData $sql = 'SELECT table_name FROM all_tables'; break; case 'pgsql': - $sql = "SELECT c.relname AS table_name " - . "FROM pg_class c, pg_user u " + $sql = 'SELECT c.relname AS table_name ' + . 'FROM pg_class c, pg_user u ' . "WHERE c.relowner = u.usesysid AND c.relkind = 'r' " - . "AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname) " + . 'AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname) ' . "AND c.relname !~ '^(pg_|sql_)' " - . "UNION " - . "SELECT c.relname AS table_name " - . "FROM pg_class c " + . 'UNION ' + . 'SELECT c.relname AS table_name ' + . 'FROM pg_class c ' . "WHERE c.relkind = 'r' " - . "AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname) " - . "AND NOT EXISTS (SELECT 1 FROM pg_user WHERE usesysid = c.relowner) " + . 'AND NOT EXISTS (SELECT 1 FROM pg_views WHERE viewname = c.relname) ' + . 'AND NOT EXISTS (SELECT 1 FROM pg_user WHERE usesysid = c.relowner) ' . "AND c.relname !~ '^pg_'"; break; case 'sqlite': $sql = "SELECT name FROM sqlite_master WHERE type='table' " - . "UNION ALL SELECT name FROM sqlite_temp_master " + . 'UNION ALL SELECT name FROM sqlite_temp_master ' . "WHERE type='table' ORDER BY name"; break; default: @@ -569,7 +569,7 @@ class Database extends AbstractData private static function _createPasteTable() { list($main_key, $after_key) = self::_getPrimaryKeyClauses(); - $dataType = self::$_type === 'pgsql' ? 'TEXT' : 'BLOB'; + $dataType = self::$_type === 'pgsql' ? 'TEXT' : 'BLOB'; self::$_db->exec( 'CREATE TABLE ' . self::_sanitizeIdentifier('paste') . ' ( ' . "dataid CHAR(16) NOT NULL$main_key, " . @@ -594,7 +594,7 @@ class Database extends AbstractData private static function _createCommentTable() { list($main_key, $after_key) = self::_getPrimaryKeyClauses(); - $dataType = self::$_type === 'pgsql' ? 'text' : 'BLOB'; + $dataType = self::$_type === 'pgsql' ? 'text' : 'BLOB'; self::$_db->exec( 'CREATE TABLE ' . self::_sanitizeIdentifier('comment') . ' ( ' . "dataid CHAR(16) NOT NULL$main_key, " . diff --git a/lib/Data/Filesystem.php b/lib/Data/Filesystem.php index 2235ff2..3507ab6 100644 --- a/lib/Data/Filesystem.php +++ b/lib/Data/Filesystem.php @@ -49,7 +49,7 @@ class Filesystem extends AbstractData self::$_dir = $options['dir'] . DIRECTORY_SEPARATOR; } // if needed initialize the singleton - if (!(self::$_instance instanceof Filesystem)) { + if (!(self::$_instance instanceof self)) { self::$_instance = new self; self::_init(); } @@ -161,7 +161,7 @@ class Filesystem extends AbstractData public function createComment($pasteid, $parentid, $commentid, $comment) { $storagedir = self::_dataid2discussionpath($pasteid); - $filename = $pasteid . '.' . $commentid . '.' . $parentid; + $filename = $pasteid . '.' . $commentid . '.' . $parentid; if (is_file($storagedir . $filename)) { return false; } @@ -181,7 +181,7 @@ class Filesystem extends AbstractData public function readComments($pasteid) { $comments = array(); - $discdir = self::_dataid2discussionpath($pasteid); + $discdir = self::_dataid2discussionpath($pasteid); if (is_dir($discdir)) { // Delete all files in discussion directory $dir = dir($discdir); @@ -192,13 +192,13 @@ class Filesystem extends AbstractData // - parentid is the comment this comment replies to (It can be pasteid) if (is_file($discdir . $filename)) { $comment = json_decode(file_get_contents($discdir . $filename)); - $items = explode('.', $filename); + $items = explode('.', $filename); // Add some meta information not contained in file. - $comment->id = $items[1]; + $comment->id = $items[1]; $comment->parentid = $items[2]; // Store in array - $key = $this->getOpenSlot($comments, (int) $comment->meta->postdate); + $key = $this->getOpenSlot($comments, (int) $comment->meta->postdate); $comments[$key] = $comment; } } @@ -236,7 +236,7 @@ class Filesystem extends AbstractData */ protected function _getExpiredPastes($batchsize) { - $pastes = array(); + $pastes = array(); $firstLevel = array_filter( scandir(self::$_dir), 'self::_isFirstLevelDir' @@ -244,7 +244,7 @@ class Filesystem extends AbstractData if (count($firstLevel) > 0) { // try at most 10 times the $batchsize pastes before giving up for ($i = 0, $max = $batchsize * 10; $i < $max; ++$i) { - $firstKey = array_rand($firstLevel); + $firstKey = array_rand($firstLevel); $secondLevel = array_filter( scandir(self::$_dir . $firstLevel[$firstKey]), 'self::_isSecondLevelDir' @@ -257,7 +257,7 @@ class Filesystem extends AbstractData } $secondKey = array_rand($secondLevel); - $path = self::$_dir . $firstLevel[$firstKey] . + $path = self::$_dir . $firstLevel[$firstKey] . DIRECTORY_SEPARATOR . $secondLevel[$secondKey]; if (!is_dir($path)) { continue; @@ -270,7 +270,7 @@ class Filesystem extends AbstractData continue; } $thirdKey = array_rand($thirdLevel); - $pasteid = $thirdLevel[$thirdKey]; + $pasteid = $thirdLevel[$thirdKey]; if (in_array($pasteid, $pastes)) { continue; } diff --git a/lib/Filter.php b/lib/Filter.php index 568f124..51106c6 100644 --- a/lib/Filter.php +++ b/lib/Filter.php @@ -77,7 +77,7 @@ class Filter public static function formatHumanReadableSize($size) { $iec = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'); - $i = 0; + $i = 0; while (($size / 1024) >= 1) { $size = $size / 1024; $i++; diff --git a/lib/I18n.php b/lib/I18n.php index 7f2fe87..8b2ecad 100644 --- a/lib/I18n.php +++ b/lib/I18n.php @@ -114,8 +114,8 @@ class I18n $args = func_get_args(); if (is_array(self::$_translations[$messageId])) { $number = (int) $args[1]; - $key = self::_getPluralForm($number); - $max = count(self::$_translations[$messageId]) - 1; + $key = self::_getPluralForm($number); + $max = count(self::$_translations[$messageId]) - 1; if ($key > $max) { $key = $max; } @@ -143,7 +143,7 @@ class I18n // check if the lang cookie was set and that language exists if (array_key_exists('lang', $_COOKIE) && in_array($_COOKIE['lang'], $availableLanguages)) { - $match = $_COOKIE['lang']; + $match = $_COOKIE['lang']; } // find a translation file matching the browsers language preferences else { @@ -153,7 +153,7 @@ class I18n } // load translations - self::$_language = $match; + self::$_language = $match; self::$_translations = ($match == 'en') ? array() : json_decode( file_get_contents(self::_getPath($match . '.json')), true @@ -319,7 +319,7 @@ class I18n protected static function _getMatchingLanguage($acceptedLanguages, $availableLanguages) { $matches = array(); - $any = false; + $any = false; foreach ($acceptedLanguages as $acceptedQuality => $acceptedValues) { $acceptedQuality = floatval($acceptedQuality); if ($acceptedQuality === 0.0) { @@ -372,7 +372,7 @@ class I18n { $a = explode('-', $a); $b = explode('-', $b); - for ($i=0, $n = min(count($a), count($b)); $i < $n; ++$i) { + for ($i = 0, $n = min(count($a), count($b)); $i < $n; ++$i) { if ($a[$i] !== $b[$i]) { break; } diff --git a/lib/Json.php b/lib/Json.php index ab1f485..023304d 100644 --- a/lib/Json.php +++ b/lib/Json.php @@ -33,7 +33,7 @@ class Json public static function encode($input) { $jsonString = json_encode($input); - $errorCode = json_last_error(); + $errorCode = json_last_error(); if ($errorCode === JSON_ERROR_NONE) { return $jsonString; } diff --git a/lib/Model/AbstractModel.php b/lib/Model/AbstractModel.php index c1579b1..1fce05c 100644 --- a/lib/Model/AbstractModel.php +++ b/lib/Model/AbstractModel.php @@ -67,9 +67,9 @@ abstract class AbstractModel */ public function __construct(Configuration $configuration, AbstractData $storage) { - $this->_conf = $configuration; - $this->_store = $storage; - $this->_data = new stdClass; + $this->_conf = $configuration; + $this->_store = $storage; + $this->_data = new stdClass; $this->_data->meta = new stdClass; } diff --git a/lib/Model/Comment.php b/lib/Model/Comment.php index 600e61e..29dcfb8 100644 --- a/lib/Model/Comment.php +++ b/lib/Model/Comment.php @@ -133,7 +133,7 @@ class Comment extends AbstractModel */ public function setPaste(Paste $paste) { - $this->_paste = $paste; + $this->_paste = $paste; $this->_data->meta->pasteid = $paste->getId(); } @@ -199,12 +199,12 @@ class Comment extends AbstractModel $icon = $this->_conf->getKey('icon'); if ($icon != 'none') { $pngdata = ''; - $hmac = TrafficLimiter::getHash(); + $hmac = TrafficLimiter::getHash(); if ($icon == 'identicon') { $identicon = new Identicon(); - $pngdata = $identicon->getImageDataUri($hmac, 16); + $pngdata = $identicon->getImageDataUri($hmac, 16); } elseif ($icon == 'vizhash') { - $vh = new Vizhash16x16(); + $vh = new Vizhash16x16(); $pngdata = 'data:image/png;base64,' . base64_encode( $vh->generate($hmac) ); diff --git a/lib/Model/Paste.php b/lib/Model/Paste.php index 8032667..ce401ca 100644 --- a/lib/Model/Paste.php +++ b/lib/Model/Paste.php @@ -62,11 +62,11 @@ class Paste extends AbstractModel if (!property_exists($data->meta, 'salt')) { $data->meta->salt = ServerSalt::get(); } - $data->comments = array_values($this->getComments()); - $data->comment_count = count($data->comments); + $data->comments = array_values($this->getComments()); + $data->comment_count = count($data->comments); $data->comment_offset = 0; - $data->{'@context'} = 'js/paste.jsonld'; - $this->_data = $data; + $data->{'@context'} = 'js/paste.jsonld'; + $this->_data = $data; return $this->_data; } @@ -85,7 +85,7 @@ class Paste extends AbstractModel } $this->_data->meta->postdate = time(); - $this->_data->meta->salt = serversalt::generate(); + $this->_data->meta->salt = serversalt::generate(); // store paste if ( @@ -247,7 +247,7 @@ class Paste extends AbstractModel throw new Exception('Invalid data.', 73); } $this->_data->meta->burnafterreading = true; - $this->_data->meta->opendiscussion = false; + $this->_data->meta->opendiscussion = false; } } @@ -296,7 +296,7 @@ class Paste extends AbstractModel * * @access public * @throws Exception - * @return boolean + * @return bool */ public function isBurnafterreading() { @@ -313,7 +313,7 @@ class Paste extends AbstractModel * * @access public * @throws Exception - * @return boolean + * @return bool */ public function isOpendiscussion() { diff --git a/lib/Persistence/AbstractPersistence.php b/lib/Persistence/AbstractPersistence.php index a888089..ff90885 100644 --- a/lib/Persistence/AbstractPersistence.php +++ b/lib/Persistence/AbstractPersistence.php @@ -119,7 +119,7 @@ abstract class AbstractPersistence protected static function _store($filename, $data) { self::_initialize(); - $file = self::$_path . DIRECTORY_SEPARATOR . $filename; + $file = self::$_path . DIRECTORY_SEPARATOR . $filename; $writtenBytes = @file_put_contents($file, $data, LOCK_EX); if ($writtenBytes === false || $writtenBytes < strlen($data)) { throw new Exception('unable to write to file ' . $file, 13); diff --git a/lib/Persistence/PurgeLimiter.php b/lib/Persistence/PurgeLimiter.php index e52d43c..1468a68 100644 --- a/lib/Persistence/PurgeLimiter.php +++ b/lib/Persistence/PurgeLimiter.php @@ -72,8 +72,8 @@ class PurgeLimiter extends AbstractPersistence return true; } - $file = 'purge_limiter.php'; - $now = time(); + $file = 'purge_limiter.php'; + $now = time(); $content = ' $time) { @@ -129,7 +129,7 @@ class TrafficLimiter extends AbstractPersistence $result = false; } else { $tl[$hash] = time(); - $result = true; + $result = true; } self::_store( $file, diff --git a/lib/PrivateBin.php b/lib/PrivateBin.php index 5985bba..5d1bfd6 100644 --- a/lib/PrivateBin.php +++ b/lib/PrivateBin.php @@ -168,14 +168,14 @@ class PrivateBin file_put_contents( PATH . $dir . DIRECTORY_SEPARATOR . '.htaccess', 'Allow from none' . PHP_EOL . - 'Deny from all'. PHP_EOL, + 'Deny from all' . PHP_EOL, LOCK_EX ); } } - $this->_conf = new Configuration; - $this->_model = new Model($this->_conf); + $this->_conf = new Configuration; + $this->_model = new Model($this->_conf); $this->_request = new Request; $this->_urlBase = array_key_exists('REQUEST_URI', $_SERVER) ? htmlspecialchars($_SERVER['REQUEST_URI']) : '/'; @@ -223,8 +223,8 @@ class PrivateBin ); } - $data = $this->_request->getParam('data'); - $attachment = $this->_request->getParam('attachment'); + $data = $this->_request->getParam('data'); + $attachment = $this->_request->getParam('attachment'); $attachmentname = $this->_request->getParam('attachmentname'); // Ensure content is not too big. @@ -247,7 +247,7 @@ class PrivateBin } // The user posts a comment. - $pasteid = $this->_request->getParam('pasteid'); + $pasteid = $this->_request->getParam('pasteid'); $parentid = $this->_request->getParam('parentid'); if (!empty($pasteid) && !empty($parentid)) { $paste = $this->_model->getPaste($pasteid); @@ -365,7 +365,7 @@ class PrivateBin try { $paste = $this->_model->getPaste($dataid); if ($paste->exists()) { - $data = $paste->get(); + $data = $paste->get(); $this->_doesExpire = property_exists($data, 'meta') && property_exists($data->meta, 'expire_date'); if (property_exists($data->meta, 'salt')) { unset($data->meta->salt); @@ -407,7 +407,7 @@ class PrivateBin // label all the expiration options $expire = array(); foreach ($this->_conf->getSection('expire_options') as $time => $seconds) { - $expire[$time] = ($seconds == 0) ? I18n::_(ucfirst($time)): Filter::formatHumanReadableTime($time); + $expire[$time] = ($seconds == 0) ? I18n::_(ucfirst($time)) : Filter::formatHumanReadableTime($time); } // translate all the formatter options @@ -462,7 +462,7 @@ class PrivateBin $type = ''; } $content = '{}'; - $file = PUBLIC_PATH . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . $type . '.jsonld'; + $file = PUBLIC_PATH . DIRECTORY_SEPARATOR . 'js' . DIRECTORY_SEPARATOR . $type . '.jsonld'; if (is_readable($file)) { $content = str_replace( '?jsonld=', @@ -492,7 +492,7 @@ class PrivateBin if ($status) { $result['message'] = I18n::_($message); } else { - $result['id'] = $message; + $result['id'] = $message; $result['url'] = $this->_urlBase . '?' . $message; } $result += $other; diff --git a/lib/Request.php b/lib/Request.php index 90e1744..b589315 100644 --- a/lib/Request.php +++ b/lib/Request.php @@ -16,7 +16,7 @@ namespace PrivateBin; * Request * * parses request parameters and provides helper functions for routing -*/ + */ class Request { /** @@ -184,7 +184,7 @@ class Request private function _detectJsonRequest() { $hasAcceptHeader = array_key_exists('HTTP_ACCEPT', $_SERVER); - $acceptHeader = $hasAcceptHeader ? $_SERVER['HTTP_ACCEPT'] : ''; + $acceptHeader = $hasAcceptHeader ? $_SERVER['HTTP_ACCEPT'] : ''; // simple cases if ( diff --git a/lib/Vizhash16x16.php b/lib/Vizhash16x16.php index 6c1b615..f88dfe9 100644 --- a/lib/Vizhash16x16.php +++ b/lib/Vizhash16x16.php @@ -110,10 +110,10 @@ class Vizhash16x16 for ($i = 0; $i < 7; ++$i) { $action = $this->getInt(); - $color = imagecolorallocate($image, $r, $g, $b); - $r = $r0 = ($r0 + $this->getInt() / 25) % 256; - $g = $g0 = ($g0 + $this->getInt() / 25) % 256; - $b = $b0 = ($b0 + $this->getInt() / 25) % 256; + $color = imagecolorallocate($image, $r, $g, $b); + $r = $r0 = ($r0 + $this->getInt() / 25) % 256; + $g = $g0 = ($g0 + $this->getInt() / 25) % 256; + $b = $b0 = ($b0 + $this->getInt() / 25) % 256; $this->drawshape($image, $action, $color); } @@ -180,10 +180,10 @@ class Vizhash16x16 private function degrade($img, $direction, $color1, $color2) { if ($direction == 'h') { - $size = imagesx($img); + $size = imagesx($img); $sizeinv = imagesy($img); } else { - $size = imagesy($img); + $size = imagesy($img); $sizeinv = imagesx($img); } $diffs = array( @@ -228,8 +228,8 @@ class Vizhash16x16 ImageFilledPolygon($image, $points, 4, $color); break; default: - $start = $this->getInt() * 360 /256; - $end = $start + $this->getInt() * 180 / 256; + $start = $this->getInt() * 360 / 256; + $end = $start + $this->getInt() * 180 / 256; ImageFilledArc($image, $this->getX(), $this->getY(), $this->getX(), $this->getY(), $start, $end, $color, IMG_ARC_PIE); } }